• 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 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 #ifndef ChromeClientAndroid_h
27 #define ChromeClientAndroid_h
28 
29 #include "ChromeClient.h"
30 
31 #include "GeolocationPermissions.h"
32 #include "Threading.h"
33 #include "Timer.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         virtual void chromeDestroyed();
48 
49         virtual void setWindowRect(const FloatRect&);
50         virtual FloatRect windowRect();
51 
52         virtual FloatRect pageRect();
53 
54         virtual float scaleFactor();
55 
56         virtual void focus();
57         virtual void unfocus();
58 
59         virtual bool canTakeFocus(FocusDirection);
60         virtual void takeFocus(FocusDirection);
61 
62         // The Frame pointer provides the ChromeClient with context about which
63         // Frame wants to create the new Page.  Also, the newly created window
64         // should not be shown to the user until the ChromeClient of the newly
65         // created Page has its show method called.
66         virtual Page* createWindow(Frame*, const FrameLoadRequest&, const WindowFeatures&);
67         virtual void show();
68 
69         virtual bool canRunModal();
70         virtual void runModal();
71 
72         virtual void setToolbarsVisible(bool);
73         virtual bool toolbarsVisible();
74 
75         virtual void setStatusbarVisible(bool);
76         virtual bool statusbarVisible();
77 
78         virtual void setScrollbarsVisible(bool);
79         virtual bool scrollbarsVisible();
80 
81         virtual void setMenubarVisible(bool);
82         virtual bool menubarVisible();
83 
84         virtual void setResizable(bool);
85 
86         virtual void addMessageToConsole(MessageSource, MessageType, MessageLevel, const String& message, unsigned int lineNumber, const String& sourceID);
87 
88         virtual bool canRunBeforeUnloadConfirmPanel();
89         virtual bool runBeforeUnloadConfirmPanel(const String& message, Frame* frame);
90 
91         virtual void closeWindowSoon();
92 
93         virtual void runJavaScriptAlert(Frame*, const String&);
94         virtual bool runJavaScriptConfirm(Frame*, const String&);
95         virtual bool runJavaScriptPrompt(Frame*, const String& message, const String& defaultValue, String& result);
96         virtual void setStatusbarText(const String&);
97         virtual bool shouldInterruptJavaScript();
98         virtual bool tabsToLinks() const;
99 
100         virtual IntRect windowResizerRect() const;
101 
102         // Methods used by HostWindow.
103         virtual void repaint(const IntRect&, bool contentChanged, bool immediate = false, bool repaintContentOnly = false);
104         virtual void scroll(const IntSize& scrollDelta, const IntRect& rectToScroll, const IntRect& clipRect);
105         virtual IntPoint screenToWindow(const IntPoint&) const;
106         virtual IntRect windowToScreen(const IntRect&) const;
107         virtual PlatformWidget platformWindow() const;
108         virtual void contentsSizeChanged(Frame*, const IntSize&) const;
109         virtual void scrollRectIntoView(const IntRect&, const ScrollView*) const;
110         // End methods used by HostWindow.
111 
112         virtual void mouseDidMoveOverElement(const HitTestResult&, unsigned int);
113 
114         virtual void setToolTip(const String&, TextDirection);
115 
116         virtual void print(Frame*);
117 #if ENABLE(DATABASE)
118         virtual void exceededDatabaseQuota(Frame*, const String&);
119 #endif
120 #if ENABLE(OFFLINE_WEB_APPLICATIONS)
121         virtual void reachedMaxAppCacheSize(int64_t spaceNeeded);
122 #endif
123 
124 	virtual void populateVisitedLinks();
125 
126         // Methods used to request and provide Geolocation permissions.
127         virtual void requestGeolocationPermissionForFrame(Frame*, Geolocation*);
128         // Android-specific
129         void provideGeolocationPermissions(const String &origin, bool allow, bool remember);
130         void storeGeolocationPermissions();
131         void onMainFrameLoadStarted();
132 
133         virtual void runOpenPanel(Frame*, PassRefPtr<FileChooser>);
134         virtual bool setCursor(PlatformCursorHandle);
135 
136         // Notification that the given form element has changed. This function
137         // will be called frequently, so handling should be very fast.
138         virtual void formStateDidChange(const Node*);
139 
createHTMLParserQuirks()140         virtual PassOwnPtr<HTMLParserQuirks> createHTMLParserQuirks() { return 0; }
141 
142         // Android-specific
143         void setWebFrame(android::WebFrame* webframe);
144         void wakeUpMainThreadWithNewQuota(long newQuota);
145     private:
146         android::WebFrame* m_webFrame;
147         WTF::ThreadCondition m_quotaThreadCondition;
148         WTF::Mutex m_quotaThreadLock;
149         long m_newQuota;
150         // The Geolocation permissions manager.
151         OwnPtr<GeolocationPermissions> m_geolocationPermissions;
152     };
153 
154 }
155 
156 #endif
157