• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2010 Apple Inc. All rights reserved.
3  * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  *
14  * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
15  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
16  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
18  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
20  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
21  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
22  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
23  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
24  * THE POSSIBILITY OF SUCH DAMAGE.
25  */
26 
27 #ifndef WebChromeClient_h
28 #define WebChromeClient_h
29 
30 #include <WebCore/ChromeClient.h>
31 #include <WebCore/ViewportArguments.h>
32 #include <wtf/text/WTFString.h>
33 
34 namespace WebKit {
35 
36 class WebFrame;
37 class WebPage;
38 
39 class WebChromeClient : public WebCore::ChromeClient {
40 public:
WebChromeClient(WebPage * page)41     WebChromeClient(WebPage* page)
42         : m_cachedMainFrameHasHorizontalScrollbar(false)
43         , m_cachedMainFrameHasVerticalScrollbar(false)
44         , m_page(page)
45     {
46     }
47 
page()48     WebPage* page() const { return m_page; }
49 
webView()50     virtual void* webView() const { return 0; }
51 
52 private:
53     virtual void chromeDestroyed();
54 
55     virtual void setWindowRect(const WebCore::FloatRect&);
56     virtual WebCore::FloatRect windowRect();
57 
58     virtual WebCore::FloatRect pageRect();
59 
60     virtual float scaleFactor();
61 
62     virtual void focus();
63     virtual void unfocus();
64 
65     virtual bool canTakeFocus(WebCore::FocusDirection);
66     virtual void takeFocus(WebCore::FocusDirection);
67 
68     virtual void focusedNodeChanged(WebCore::Node*);
69     virtual void focusedFrameChanged(WebCore::Frame*);
70 
71     // The Frame pointer provides the ChromeClient with context about which
72     // Frame wants to create the new Page.  Also, the newly created window
73     // should not be shown to the user until the ChromeClient of the newly
74     // created Page has its show method called.
75     virtual WebCore::Page* createWindow(WebCore::Frame*, const WebCore::FrameLoadRequest&, const WebCore::WindowFeatures&, const WebCore::NavigationAction&);
76     virtual void show();
77 
78     virtual bool canRunModal();
79     virtual void runModal();
80 
81     virtual void setToolbarsVisible(bool);
82     virtual bool toolbarsVisible();
83 
84     virtual void setStatusbarVisible(bool);
85     virtual bool statusbarVisible();
86 
87     virtual void setScrollbarsVisible(bool);
88     virtual bool scrollbarsVisible();
89 
90     virtual void setMenubarVisible(bool);
91     virtual bool menubarVisible();
92 
93     virtual void setResizable(bool);
94 
95     virtual void addMessageToConsole(WebCore::MessageSource, WebCore::MessageType, WebCore::MessageLevel, const String& message, unsigned int lineNumber, const String& sourceID);
96 
97     virtual bool canRunBeforeUnloadConfirmPanel();
98     virtual bool runBeforeUnloadConfirmPanel(const String& message, WebCore::Frame* frame);
99 
100     virtual void closeWindowSoon();
101 
102     virtual void runJavaScriptAlert(WebCore::Frame*, const String&);
103     virtual bool runJavaScriptConfirm(WebCore::Frame*, const String&);
104     virtual bool runJavaScriptPrompt(WebCore::Frame*, const String& message, const String& defaultValue, String& result);
105     virtual void setStatusbarText(const String&);
106     virtual bool shouldInterruptJavaScript();
107 
108     virtual WebCore::KeyboardUIMode keyboardUIMode();
109 
110     virtual WebCore::IntRect windowResizerRect() const;
111 
112     // Methods used by HostWindow.
113     virtual void invalidateWindow(const WebCore::IntRect&, bool);
114     virtual void invalidateContentsAndWindow(const WebCore::IntRect&, bool);
115     virtual void invalidateContentsForSlowScroll(const WebCore::IntRect&, bool);
116     virtual void scroll(const WebCore::IntSize& scrollOffset, const WebCore::IntRect& scrollRect, const WebCore::IntRect& clipRect);
117 #if ENABLE(TILED_BACKING_STORE)
118     virtual void delegatedScrollRequested(const WebCore::IntPoint& scrollOffset);
119 #endif
120     virtual WebCore::IntPoint screenToWindow(const WebCore::IntPoint&) const;
121     virtual WebCore::IntRect windowToScreen(const WebCore::IntRect&) const;
122     virtual PlatformPageClient platformPageClient() const;
123     virtual void contentsSizeChanged(WebCore::Frame*, const WebCore::IntSize&) const;
124     virtual void scrollRectIntoView(const WebCore::IntRect&, const WebCore::ScrollView*) const; // Currently only Mac has a non empty implementation.
125     // End methods used by HostWindow.
126 
127     virtual bool shouldMissingPluginMessageBeButton() const;
128     virtual void missingPluginButtonClicked(WebCore::Element*) const;
129 
130     virtual void scrollbarsModeDidChange() const;
131     virtual void mouseDidMoveOverElement(const WebCore::HitTestResult&, unsigned modifierFlags);
132 
133     virtual void setToolTip(const String&, WebCore::TextDirection);
134 
135     virtual void print(WebCore::Frame*);
136 
137 #if ENABLE(DATABASE)
138     virtual void exceededDatabaseQuota(WebCore::Frame*, const String& databaseName);
139 #endif
140 
141 #if ENABLE(OFFLINE_WEB_APPLICATIONS)
142     virtual void reachedMaxAppCacheSize(int64_t spaceNeeded);
143     virtual void reachedApplicationCacheOriginQuota(WebCore::SecurityOrigin*);
144 #endif
145 
146 #if ENABLE(DASHBOARD_SUPPORT)
147     virtual void dashboardRegionsChanged();
148 #endif
149 
150     virtual void populateVisitedLinks();
151 
152     virtual WebCore::FloatRect customHighlightRect(WebCore::Node*, const WTF::AtomicString& type, const WebCore::FloatRect& lineRect);
153     virtual void paintCustomHighlight(WebCore::Node*, const WTF::AtomicString& type, const WebCore::FloatRect& boxRect, const WebCore::FloatRect& lineRect,
154                                       bool behindText, bool entireLine);
155 
156     virtual bool shouldReplaceWithGeneratedFileForUpload(const String& path, String& generatedFilename);
157     virtual String generateReplacementFile(const String& path);
158 
159     virtual bool paintCustomScrollbar(WebCore::GraphicsContext*, const WebCore::FloatRect&, WebCore::ScrollbarControlSize,
160                                       WebCore::ScrollbarControlState, WebCore::ScrollbarPart pressedPart, bool vertical,
161                                       float value, float proportion, WebCore::ScrollbarControlPartMask);
162     virtual bool paintCustomScrollCorner(WebCore::GraphicsContext*, const WebCore::FloatRect&);
163 
164     virtual bool paintCustomOverhangArea(WebCore::GraphicsContext*, const WebCore::IntRect&, const WebCore::IntRect&, const WebCore::IntRect&);
165 
166     // This is an asynchronous call. The ChromeClient can display UI asking the user for permission
167     // to use Geolococation. The ChromeClient must call Geolocation::setShouldClearCache() appropriately.
168     virtual void requestGeolocationPermissionForFrame(WebCore::Frame*, WebCore::Geolocation*);
169     virtual void cancelGeolocationPermissionRequestForFrame(WebCore::Frame*, WebCore::Geolocation*);
170 
171     virtual void runOpenPanel(WebCore::Frame*, PassRefPtr<WebCore::FileChooser>);
172     virtual void chooseIconForFiles(const Vector<String>&, WebCore::FileChooser*);
173 
174     virtual void setCursor(const WebCore::Cursor&);
175 
176     // Notification that the given form element has changed. This function
177     // will be called frequently, so handling should be very fast.
178     virtual void formStateDidChange(const WebCore::Node*);
179 
180     virtual void formDidFocus(const WebCore::Node*);
181     virtual void formDidBlur(const WebCore::Node*);
182 
183     virtual bool selectItemWritingDirectionIsNatural();
184     virtual bool selectItemAlignmentFollowsMenuWritingDirection();
185     virtual PassRefPtr<WebCore::PopupMenu> createPopupMenu(WebCore::PopupMenuClient*) const;
186     virtual PassRefPtr<WebCore::SearchPopupMenu> createSearchPopupMenu(WebCore::PopupMenuClient*) const;
187 
188 #if ENABLE(CONTEXT_MENUS)
189     virtual void showContextMenu();
190 #endif
191 
192 #if USE(ACCELERATED_COMPOSITING)
193     virtual void attachRootGraphicsLayer(WebCore::Frame*, WebCore::GraphicsLayer*);
194     virtual void setNeedsOneShotDrawingSynchronization();
195     virtual void scheduleCompositingLayerSync();
196 #endif
197 
198 #if ENABLE(NOTIFICATIONS)
199     virtual WebCore::NotificationPresenter* notificationPresenter() const;
200 #endif
201 
202 #if ENABLE(TOUCH_EVENTS)
203     virtual void needTouchEvents(bool);
204 #endif
205 
206 #if PLATFORM(WIN)
207     virtual void setLastSetCursorToCurrentCursor();
208 #endif
209 
210 #if ENABLE(FULLSCREEN_API)
211     virtual bool supportsFullScreenForElement(const WebCore::Element*, bool withKeyboard);
212     virtual void enterFullScreenForElement(WebCore::Element*);
213     virtual void exitFullScreenForElement(WebCore::Element*);
214     virtual void setRootFullScreenLayer(WebCore::GraphicsLayer*);
215 #endif
216 
217     virtual void dispatchViewportDataDidChange(const WebCore::ViewportArguments&) const;
218 
219     virtual void didCompleteRubberBandForMainFrame(const WebCore::IntSize&) const;
220 
221     String m_cachedToolTip;
222     mutable RefPtr<WebFrame> m_cachedFrameSetLargestFrame;
223     mutable bool m_cachedMainFrameHasHorizontalScrollbar;
224     mutable bool m_cachedMainFrameHasVerticalScrollbar;
225 
226     WebPage* m_page;
227 };
228 
229 } // namespace WebKit
230 
231 #endif // WebChromeClient_h
232