• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2007, 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 #ifndef ChromeClientAndroid_h
27 #define ChromeClientAndroid_h
28 
29 #include "ChromeClient.h"
30 
31 #include "GeolocationPermissions.h"
32 #include "Timer.h"
33 #include <wtf/Threading.h>
34 
35 namespace WebCore {
36     class Geolocation;
37 }
38 
39 using namespace WebCore;
40 
41 namespace android {
42     class WebFrame;
43 
44     class ChromeClientAndroid : public ChromeClient {
45     public:
ChromeClientAndroid()46         ChromeClientAndroid() : m_webFrame(0), m_geolocationPermissions(0)
47 #if USE(ACCELERATED_COMPOSITING)
48                                 , m_rootGraphicsLayer(0)
49                                 , m_askToDrawAgain(false)
50                                 , m_syncTimer(this, &ChromeClientAndroid::syncTimerFired)
51 #endif
52                                 , m_triedToReclaimDBQuota(false)
53                                 { }
54         virtual void chromeDestroyed();
55 
56         virtual void setWindowRect(const FloatRect&);
57         virtual FloatRect windowRect();
58 
59         virtual FloatRect pageRect();
60 
61         virtual float scaleFactor();
62 
63 #ifdef ANDROID_USER_GESTURE
64         virtual void focus(bool userGesture);
65 #else
66         virtual void focus();
67 #endif
68         virtual void unfocus();
69 
70         virtual bool canTakeFocus(FocusDirection);
71         virtual void takeFocus(FocusDirection);
72 
73         virtual void focusedNodeChanged(Node*);
74 
75         // The Frame pointer provides the ChromeClient with context about which
76         // Frame wants to create the new Page.  Also, the newly created window
77         // should not be shown to the user until the ChromeClient of the newly
78         // created Page has its show method called.
79         virtual Page* createWindow(Frame*, const FrameLoadRequest&, const WindowFeatures&);
80         virtual void show();
81 
82         virtual bool canRunModal();
83         virtual void runModal();
84 
85         virtual void setToolbarsVisible(bool);
86         virtual bool toolbarsVisible();
87 
88         virtual void setStatusbarVisible(bool);
89         virtual bool statusbarVisible();
90 
91         virtual void setScrollbarsVisible(bool);
92         virtual bool scrollbarsVisible();
93 
94         virtual void setMenubarVisible(bool);
95         virtual bool menubarVisible();
96 
97         virtual void setResizable(bool);
98 
99         virtual void addMessageToConsole(MessageSource, MessageType, MessageLevel, const String& message, unsigned int lineNumber, const String& sourceID);
100 
101         virtual bool canRunBeforeUnloadConfirmPanel();
102         virtual bool runBeforeUnloadConfirmPanel(const String& message, Frame* frame);
103 
104         virtual void closeWindowSoon();
105 
106         virtual void runJavaScriptAlert(Frame*, const String&);
107         virtual bool runJavaScriptConfirm(Frame*, const String&);
108         virtual bool runJavaScriptPrompt(Frame*, const String& message, const String& defaultValue, String& result);
109         virtual void setStatusbarText(const String&);
110         virtual bool shouldInterruptJavaScript();
111         virtual bool tabsToLinks() const;
112 
113         virtual IntRect windowResizerRect() const;
114 
115         // Methods used by HostWindow.
116         virtual void repaint(const IntRect&, bool contentChanged, bool immediate = false, bool repaintContentOnly = false);
117         virtual void scroll(const IntSize& scrollDelta, const IntRect& rectToScroll, const IntRect& clipRect);
118         virtual IntPoint screenToWindow(const IntPoint&) const;
119         virtual IntRect windowToScreen(const IntRect&) const;
120         virtual PlatformPageClient platformPageClient() const;
121         virtual void contentsSizeChanged(Frame*, const IntSize&) const;
122         virtual void scrollRectIntoView(const IntRect&, const ScrollView*) const;
123         // End methods used by HostWindow.
124 
125         virtual void scrollbarsModeDidChange() const;
126         virtual void mouseDidMoveOverElement(const HitTestResult&, unsigned int);
127 
128         virtual void setToolTip(const String&, TextDirection);
129 
130         virtual void print(Frame*);
131 #if ENABLE(DATABASE)
132         virtual void exceededDatabaseQuota(Frame*, const String&);
133 #endif
134 #if ENABLE(OFFLINE_WEB_APPLICATIONS)
135         virtual void reachedMaxAppCacheSize(int64_t spaceNeeded);
136 #endif
137 
138 	virtual void populateVisitedLinks();
139 
140 #if ENABLE(TOUCH_EVENTS)
141         virtual void needTouchEvents(bool);
142 #endif
143 
144         // Methods used to request and provide Geolocation permissions.
145         virtual void requestGeolocationPermissionForFrame(Frame*, Geolocation*);
146         virtual void cancelGeolocationPermissionRequestForFrame(Frame*);
147         // Android-specific
148         void provideGeolocationPermissions(const String &origin, bool allow, bool remember);
149         void storeGeolocationPermissions();
150         void onMainFrameLoadStarted();
151 
152         virtual void runOpenPanel(Frame*, PassRefPtr<FileChooser>);
153         virtual bool setCursor(PlatformCursorHandle);
154 
155         // Notification that the given form element has changed. This function
156         // will be called frequently, so handling should be very fast.
157         virtual void formStateDidChange(const Node*);
158 
createHTMLParserQuirks()159         virtual PassOwnPtr<HTMLParserQuirks> createHTMLParserQuirks() { return 0; }
160 
161         // Android-specific
162         void setWebFrame(android::WebFrame* webframe);
163         void wakeUpMainThreadWithNewQuota(long newQuota);
164 
165 #if USE(ACCELERATED_COMPOSITING)
166         virtual void attachRootGraphicsLayer(WebCore::Frame*, WebCore::GraphicsLayer* g);
167         virtual void setNeedsOneShotDrawingSynchronization();
168         virtual void scheduleCompositingLayerSync();
169         void syncTimerFired(Timer<ChromeClientAndroid>*);
170 #endif
171 
172     private:
173         android::WebFrame* m_webFrame;
174         // The Geolocation permissions manager.
175         OwnPtr<GeolocationPermissions> m_geolocationPermissions;
176 #if USE(ACCELERATED_COMPOSITING)
177         WebCore::GraphicsLayer* m_rootGraphicsLayer;
178         bool m_askToDrawAgain;
179         Timer<ChromeClientAndroid> m_syncTimer;
180 #endif
181         WTF::ThreadCondition m_quotaThreadCondition;
182         WTF::Mutex m_quotaThreadLock;
183         long m_newQuota;
184         bool m_triedToReclaimDBQuota;
185     };
186 
187 }
188 
189 #endif
190