OSDN Git Service

Turn on webcore's request management and remove our hacks.
[android-x86/external-webkit.git] / WebKit / android / jni / WebCoreFrameBridge.h
1 /*
2  * Copyright 2006, The Android Open Source Project
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  *  * Redistributions of source code must retain the above copyright
8  *    notice, this list of conditions and the following disclaimer.
9  *  * Redistributions in binary form must reproduce the above copyright
10  *    notice, this list of conditions and the following disclaimer in the
11  *    documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
14  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
17  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24  */
25
26 // TODO: change name to WebFrame.h
27
28 #ifndef WEBFRAME_H
29 #define WEBFRAME_H
30
31 #include "FrameLoaderClient.h"
32 #include "PlatformString.h"
33 #include "WebCoreRefObject.h"
34 #include <jni.h>
35
36 namespace WebCore {
37     class HistoryItem;
38     class Image;
39     class Page;
40     class RenderPart;
41     class ResourceHandle;
42     class ResourceRequest;
43 }
44
45 namespace android {
46
47 class WebCoreResourceLoader;
48 class WebViewCore;
49
50 // one instance of WebFrame per Page for calling into Java's BrowserFrame
51 class WebFrame : public WebCoreRefObject {
52   public:
53     // these ids need to be in sync with the constants in BrowserFrame.java
54     enum RAW_RES_ID {
55         NODOMAIN = 1,
56         LOADERROR,
57     };
58     WebFrame(JNIEnv* env, jobject obj, jobject historyList, WebCore::Page* page);
59     ~WebFrame();
60
61     // helper function
62     static WebFrame* getWebFrame(const WebCore::Frame* frame);
63
64     virtual WebCoreResourceLoader* startLoadingResource(WebCore::ResourceHandle*,
65             const WebCore::ResourceRequest& request,
66             bool synchronous);
67
68     void reportError(int errorCode, const WebCore::String& description,
69             const WebCore::String& failingUrl);
70
71     void loadStarted(WebCore::Frame* frame);
72
73     void transitionToCommitted(WebCore::Frame* frame);
74
75     void didFinishLoad(WebCore::Frame* frame);
76
77     void addHistoryItem(WebCore::HistoryItem* item);
78
79     void removeHistoryItem(int index);
80
81     void updateHistoryIndex(int newIndex);
82
83     void setTitle(const WebCore::String& title);
84
85     void windowObjectCleared(WebCore::Frame* frame);
86
87         void setProgress(float newProgress);
88
89     const WebCore::String userAgentForURL(const WebCore::KURL* url);
90
91     void didReceiveIcon(WebCore::Image* icon);
92     
93     void updateVisitedHistory(const WebCore::KURL& url, bool reload);
94
95     virtual bool canHandleRequest(const WebCore::ResourceRequest& request);
96
97     WebCore::Frame* createWindow(bool dialog, bool userGesture);
98
99     void requestFocus() const;
100
101     void closeWindow(WebViewCore* webViewCore);
102
103     void decidePolicyForFormResubmission(WebCore::FramePolicyFunction func);
104
105     void setUserAgent(WebCore::String userAgent) { mUserAgent = userAgent; }
106
107     WebCore::String getRawResourceFilename(RAW_RES_ID) const;
108
109     /**
110      * When the user initiates a click (via trackball, enter-press, or touch),
111      * we set mUserInitiatedClick to true.  If a load happens due to this click,
112      * then we ask the application if it wants to override
113      * the load. Otherwise, we attempt to load the resource internally.
114      * We also check it to determine whether or not to allow webkit to request
115      * a scroll.  If it was user initated, the scroll is allowed.
116      */
117     void setUserInitiatedClick(bool userInitiatedClick) { mUserInitiatedClick = userInitiatedClick; }
118
119     bool userInitiatedClick() { return mUserInitiatedClick; }
120     
121     WebCore::Page* page() const { return mPage; }
122
123 private:
124     struct JavaBrowserFrame;
125     JavaBrowserFrame* mJavaFrame;
126     WebCore::Page* mPage;
127     WebCore::String mUserAgent;
128     bool mUserInitiatedClick;
129 };
130
131 }   // namespace android
132
133 #endif // WEBFRAME_H