• 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 "PopupMenu.h"
32 #include "SearchPopupMenu.h"
33 #include "Timer.h"
34 #include <wtf/PassRefPtr.h>
35 #include <wtf/Threading.h>
36 
37 namespace WebCore {
38 class PopupMenuClient;
39 class Geolocation;
40 }
41 
42 using namespace WebCore;
43 
44 namespace android {
45     class WebFrame;
46 
47     class ChromeClientAndroid : public ChromeClient {
48     public:
ChromeClientAndroid()49         ChromeClientAndroid() : m_webFrame(0)
50 #if USE(ACCELERATED_COMPOSITING)
51                               , m_rootGraphicsLayer(0)
52                               , m_needsLayerSync(false)
53 #endif
54                               , m_triedToReclaimDBQuota(false)
55                               { }
56         virtual void chromeDestroyed();
57 
58         virtual void setWindowRect(const FloatRect&);
59         virtual FloatRect windowRect();
60 
61         virtual FloatRect pageRect();
62 
63         virtual float scaleFactor();
64 
65         virtual void focus();
66         virtual void unfocus();
67         virtual void formDidBlur(const WebCore::Node*);
68         virtual bool canTakeFocus(FocusDirection);
69         virtual void takeFocus(FocusDirection);
70 
71         virtual void focusedNodeChanged(Node*);
72         virtual void focusedFrameChanged(Frame*);
73 
74         // The Frame pointer provides the ChromeClient with context about which
75         // Frame wants to create the new Page.  Also, the newly created window
76         // should not be shown to the user until the ChromeClient of the newly
77         // created Page has its show method called.
78         virtual Page* createWindow(Frame*, const FrameLoadRequest&, const WindowFeatures&, const NavigationAction&);
79         virtual void show();
80 
81         virtual bool canRunModal();
82         virtual void runModal();
83 
84         virtual void setToolbarsVisible(bool);
85         virtual bool toolbarsVisible();
86 
87         virtual void setStatusbarVisible(bool);
88         virtual bool statusbarVisible();
89 
90         virtual void setScrollbarsVisible(bool);
91         virtual bool scrollbarsVisible();
92 
93         virtual void setMenubarVisible(bool);
94         virtual bool menubarVisible();
95 
96         virtual void setResizable(bool);
97 
98         virtual void addMessageToConsole(MessageSource, MessageType, MessageLevel, const String& message, unsigned int lineNumber, const String& sourceID);
99 
100         virtual bool canRunBeforeUnloadConfirmPanel();
101         virtual bool runBeforeUnloadConfirmPanel(const String& message, Frame* frame);
102 
103         virtual void closeWindowSoon();
104 
105         virtual void runJavaScriptAlert(Frame*, const String&);
106         virtual bool runJavaScriptConfirm(Frame*, const String&);
107         virtual bool runJavaScriptPrompt(Frame*, const String& message, const String& defaultValue, String& result);
108         virtual void setStatusbarText(const String&);
109         virtual bool shouldInterruptJavaScript();
110         virtual KeyboardUIMode keyboardUIMode();
111 
112         virtual IntRect windowResizerRect() const;
113 
114         // Methods used by HostWindow.
115         virtual void invalidateWindow(const WebCore::IntRect&, bool);
116         virtual void invalidateContentsAndWindow(const WebCore::IntRect&, bool);
117         virtual void invalidateContentsForSlowScroll(const WebCore::IntRect&, bool);
118         virtual void scroll(const IntSize& scrollDelta, const IntRect& rectToScroll, const IntRect& clipRect);
119         virtual IntPoint screenToWindow(const IntPoint&) const;
120         virtual IntRect windowToScreen(const IntRect&) const;
121         virtual PlatformPageClient platformPageClient() const;
122         virtual void contentsSizeChanged(Frame*, const IntSize&) const;
123         virtual void scrollRectIntoView(const IntRect&, const ScrollView*) const;
124         // End methods used by HostWindow.
125 
126         virtual void dispatchViewportDataDidChange(const ViewportArguments&) const;
127 
128         virtual void scrollbarsModeDidChange() const;
129         virtual void mouseDidMoveOverElement(const HitTestResult&, unsigned int);
130 
131         virtual void setToolTip(const String&, TextDirection);
132 
133         virtual void print(Frame*);
134 #if ENABLE(DATABASE)
135         virtual void exceededDatabaseQuota(Frame*, const String&);
136 #endif
137 #if ENABLE(OFFLINE_WEB_APPLICATIONS)
138         virtual void reachedMaxAppCacheSize(int64_t spaceNeeded);
139         virtual void reachedApplicationCacheOriginQuota(SecurityOrigin*);
140 #endif
141 
142 	virtual void populateVisitedLinks();
143 
144 #if ENABLE(TOUCH_EVENTS)
145         virtual void needTouchEvents(bool);
146 #endif
147 
148         // Methods used to request and provide Geolocation permissions.
149         // Not used with client-based Geolocation
requestGeolocationPermissionForFrame(Frame *,Geolocation *)150         virtual void requestGeolocationPermissionForFrame(Frame*, Geolocation*) { ASSERT_NOT_REACHED(); }
cancelGeolocationPermissionRequestForFrame(WebCore::Frame *,WebCore::Geolocation *)151         virtual void cancelGeolocationPermissionRequestForFrame(WebCore::Frame*, WebCore::Geolocation*) { ASSERT_NOT_REACHED(); }
152 
153         virtual void runOpenPanel(Frame*, PassRefPtr<FileChooser>);
154         virtual void setCursor(const Cursor&);
155         virtual void chooseIconForFiles(const WTF::Vector<WTF::String>&, FileChooser*);
156 
157         // Notification that the given form element has changed. This function
158         // will be called frequently, so handling should be very fast.
159         virtual void formStateDidChange(const Node*);
160 
161         // Android-specific
162         void setWebFrame(android::WebFrame* webframe);
webFrame()163         android::WebFrame* webFrame() { return m_webFrame; }
164         void wakeUpMainThreadWithNewQuota(long long newQuota);
165 
166 #if USE(ACCELERATED_COMPOSITING)
167         virtual void attachRootGraphicsLayer(WebCore::Frame*, WebCore::GraphicsLayer* g);
168         virtual void setNeedsOneShotDrawingSynchronization();
169         virtual void scheduleCompositingLayerSync();
allowsAcceleratedCompositing()170         virtual bool allowsAcceleratedCompositing() const { return true; }
171         WebCore::GraphicsLayer* layersSync();
172 #endif
173 
174         virtual bool selectItemWritingDirectionIsNatural();
175         virtual bool selectItemAlignmentFollowsMenuWritingDirection();
176         virtual PassRefPtr<WebCore::PopupMenu> createPopupMenu(WebCore::PopupMenuClient*) const;
177         virtual PassRefPtr<WebCore::SearchPopupMenu> createSearchPopupMenu(WebCore::PopupMenuClient*) const;
178 
179 #if ENABLE(CONTEXT_MENUS)
180         virtual void showContextMenu();
181 #endif
182 
183 #if ENABLE(FULLSCREEN_API)
184         virtual void exitFullScreenForElement(Element*);
185 #endif
186 
187 #if ENABLE(VIDEO)
188         virtual bool supportsFullscreenForNode(const WebCore::Node*);
189         virtual void enterFullscreenForNode(WebCore::Node*);
190         virtual void exitFullscreenForNode(WebCore::Node*);
191 #endif
192 
webView()193         virtual void* webView() const { return 0; }
194 
195     private:
196         android::WebFrame* m_webFrame;
197 #if USE(ACCELERATED_COMPOSITING)
198         WebCore::GraphicsLayer* m_rootGraphicsLayer;
199         bool m_needsLayerSync;
200 #endif
201         WTF::ThreadCondition m_quotaThreadCondition;
202         WTF::Mutex m_quotaThreadLock;
203         unsigned long long m_newQuota;
204         bool m_isNewQuotaSet;
205         bool m_triedToReclaimDBQuota;
206     };
207 
208 }
209 
210 #endif
211