• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 isHighPriority,
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 updateVisitedHistory(const WebCore::KURL& url, bool reload);
95 
96     virtual bool canHandleRequest(const WebCore::ResourceRequest& request);
97 
98     WebCore::Frame* createWindow(bool dialog, bool userGesture);
99 
100     void requestFocus() const;
101 
102     void closeWindow(WebViewCore* webViewCore);
103 
104     void decidePolicyForFormResubmission(WebCore::FramePolicyFunction func);
105 
setUserAgent(WebCore::String userAgent)106     void setUserAgent(WebCore::String userAgent) { mUserAgent = userAgent; }
107 
108     WebCore::String getRawResourceFilename(RAW_RES_ID) const;
109 
110     /**
111      * When the user initiates a click (via trackball, enter-press, or touch),
112      * we set mUserInitiatedClick to true.  If a load happens due to this click,
113      * then we ask the application if it wants to override
114      * the load. Otherwise, we attempt to load the resource internally.
115      * We also check it to determine whether or not to allow webkit to request
116      * a scroll.  If it was user initated, the scroll is allowed.
117      */
setUserInitiatedClick(bool userInitiatedClick)118     void setUserInitiatedClick(bool userInitiatedClick) { mUserInitiatedClick = userInitiatedClick; }
119 
userInitiatedClick()120     bool userInitiatedClick() { return mUserInitiatedClick; }
121 
page()122     WebCore::Page* page() const { return mPage; }
123 
124 private:
125     struct JavaBrowserFrame;
126     JavaBrowserFrame* mJavaFrame;
127     WebCore::Page* mPage;
128     WebCore::String mUserAgent;
129     bool mUserInitiatedClick;
130 };
131 
132 }   // namespace android
133 
134 #endif // WEBFRAME_H
135