OSDN Git Service

Merge change 23625 into eclair
[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         DRAWABLEDIR,
58     };
59     WebFrame(JNIEnv* env, jobject obj, jobject historyList, WebCore::Page* page);
60     ~WebFrame();
61
62     // helper function
63     static WebFrame* getWebFrame(const WebCore::Frame* frame);
64
65     virtual WebCoreResourceLoader* startLoadingResource(WebCore::ResourceHandle*,
66             const WebCore::ResourceRequest& request,
67             bool synchronous);
68
69     void reportError(int errorCode, const WebCore::String& description,
70             const WebCore::String& failingUrl);
71
72     void loadStarted(WebCore::Frame* frame);
73
74     void transitionToCommitted(WebCore::Frame* frame);
75
76     void didFinishLoad(WebCore::Frame* frame);
77
78     void addHistoryItem(WebCore::HistoryItem* item);
79
80     void removeHistoryItem(int index);
81
82     void updateHistoryIndex(int newIndex);
83
84     void setTitle(const WebCore::String& title);
85
86     void windowObjectCleared(WebCore::Frame* frame);
87
88         void setProgress(float newProgress);
89
90     const WebCore::String userAgentForURL(const WebCore::KURL* url);
91
92     void didReceiveIcon(WebCore::Image* icon);
93
94     void didReceiveTouchIconURL(const WebCore::String& url);
95     
96     void updateVisitedHistory(const WebCore::KURL& url, bool reload);
97
98     virtual bool canHandleRequest(const WebCore::ResourceRequest& request);
99
100     WebCore::Frame* createWindow(bool dialog, bool userGesture);
101
102     void requestFocus() const;
103
104     void closeWindow(WebViewCore* webViewCore);
105
106     void decidePolicyForFormResubmission(WebCore::FramePolicyFunction func);
107
108     void setUserAgent(WebCore::String userAgent) { mUserAgent = userAgent; }
109
110     WebCore::String getRawResourceFilename(RAW_RES_ID) const;
111
112     /**
113      * When the user initiates a click (via trackball, enter-press, or touch),
114      * we set mUserInitiatedClick to true.  If a load happens due to this click,
115      * then we ask the application if it wants to override
116      * the load. Otherwise, we attempt to load the resource internally.
117      * We also check it to determine whether or not to allow webkit to request
118      * a scroll.  If it was user initated, the scroll is allowed.
119      */
120     void setUserInitiatedClick(bool userInitiatedClick) { mUserInitiatedClick = userInitiatedClick; }
121
122     bool userInitiatedClick() { return mUserInitiatedClick; }
123     
124     WebCore::Page* page() const { return mPage; }
125
126 private:
127     struct JavaBrowserFrame;
128     JavaBrowserFrame* mJavaFrame;
129     WebCore::Page* mPage;
130     WebCore::String mUserAgent;
131     bool mUserInitiatedClick;
132 };
133
134 }   // namespace android
135
136 #endif // WEBFRAME_H