• 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 THE COPYRIGHT OWNER 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 "PlatformBridge.h"
33 #include "WebCoreRefObject.h"
34 #include <jni.h>
35 #include <wtf/RefCounted.h>
36 
37 namespace WebCore {
38     class HistoryItem;
39     class Image;
40     class Page;
41     class RenderPart;
42     class ResourceHandle;
43     class ResourceLoaderAndroid;
44     class ResourceRequest;
45 }
46 
47 namespace android {
48 
49 class WebViewCore;
50 
51 // one instance of WebFrame per Page for calling into Java's BrowserFrame
52 class WebFrame : public WebCoreRefObject {
53   public:
54     WebFrame(JNIEnv* env, jobject obj, jobject historyList, WebCore::Page* page);
55     ~WebFrame();
56 
57     // helper function
58     static WebFrame* getWebFrame(const WebCore::Frame* frame);
59 
60     virtual PassRefPtr<WebCore::ResourceLoaderAndroid> startLoadingResource(WebCore::ResourceHandle*,
61             const WebCore::ResourceRequest& request, bool mainResource,
62             bool synchronous);
63 
64     void reportError(int errorCode, const WebCore::String& description,
65             const WebCore::String& failingUrl);
66 
67     void loadStarted(WebCore::Frame* frame);
68 
69     void transitionToCommitted(WebCore::Frame* frame);
70 
71     void didFinishLoad(WebCore::Frame* frame);
72 
73     void addHistoryItem(WebCore::HistoryItem* item);
74 
75     void removeHistoryItem(int index);
76 
77     void updateHistoryIndex(int newIndex);
78 
79     void setTitle(const WebCore::String& title);
80 
81     void windowObjectCleared(WebCore::Frame* frame);
82 
83 	void setProgress(float newProgress);
84 
85     const WebCore::String userAgentForURL(const WebCore::KURL* url);
86 
87     void didReceiveIcon(WebCore::Image* icon);
88 
89     void didReceiveTouchIconURL(const WebCore::String& url, bool precomposed);
90 
91     void updateVisitedHistory(const WebCore::KURL& url, bool reload);
92 
93     virtual bool canHandleRequest(const WebCore::ResourceRequest& request);
94 
95     WebCore::Frame* createWindow(bool dialog, bool userGesture);
96 
97     void requestFocus() const;
98 
99     void closeWindow(WebViewCore* webViewCore);
100 
101     void decidePolicyForFormResubmission(WebCore::FramePolicyFunction func);
102 
setUserAgent(WebCore::String userAgent)103     void setUserAgent(WebCore::String userAgent) { mUserAgent = userAgent; }
104 
105     WebCore::String getRawResourceFilename(WebCore::PlatformBridge::rawResId) const;
106 
107     float density() 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      */
setUserInitiatedClick(bool userInitiatedClick)117     void setUserInitiatedClick(bool userInitiatedClick) { mUserInitiatedClick = userInitiatedClick; }
118 
userInitiatedClick()119     bool userInitiatedClick() { return mUserInitiatedClick; }
120 
page()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
134