2 * Copyright (C) 2009 Google Inc. All rights reserved.
3 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * * Redistributions in binary form must reproduce the above
12 * copyright notice, this list of conditions and the following disclaimer
13 * in the documentation and/or other materials provided with the
15 * * Neither the name of Google Inc. nor the names of its
16 * contributors may be used to endorse or promote products derived from
17 * this software without specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 #ifndef ChromeClientImpl_h
33 #define ChromeClientImpl_h
35 #include "ChromeClientChromium.h"
36 #include "PopupMenu.h"
37 #include "SearchPopupMenu.h"
40 class AccessibilityObject;
44 class PopupMenuClient;
47 struct WindowFeatures;
53 struct WebPopupMenuInfo;
55 // Handles window-level notifications from WebCore on behalf of a WebView.
56 class ChromeClientImpl : public WebCore::ChromeClientChromium {
58 explicit ChromeClientImpl(WebViewImpl* webView);
59 virtual ~ChromeClientImpl();
61 virtual void* webView() const;
63 // ChromeClient methods:
64 virtual void chromeDestroyed();
65 virtual void setWindowRect(const WebCore::FloatRect&);
66 virtual WebCore::FloatRect windowRect();
67 virtual WebCore::FloatRect pageRect();
69 virtual void unfocus();
70 virtual bool canTakeFocus(WebCore::FocusDirection);
71 virtual void takeFocus(WebCore::FocusDirection);
72 virtual void focusedNodeChanged(WebCore::Node*);
73 virtual void focusedFrameChanged(WebCore::Frame*);
74 virtual WebCore::Page* createWindow(
75 WebCore::Frame*, const WebCore::FrameLoadRequest&, const WebCore::WindowFeatures&, const WebCore::NavigationAction&);
77 virtual bool canRunModal();
78 virtual void runModal();
79 virtual void setToolbarsVisible(bool);
80 virtual bool toolbarsVisible();
81 virtual void setStatusbarVisible(bool);
82 virtual bool statusbarVisible();
83 virtual void setScrollbarsVisible(bool);
84 virtual bool scrollbarsVisible();
85 virtual void setMenubarVisible(bool);
86 virtual bool menubarVisible();
87 virtual void setResizable(bool);
88 virtual void addMessageToConsole(
89 WebCore::MessageSource, WebCore::MessageType, WebCore::MessageLevel,
90 const WTF::String& message, unsigned lineNumber,
91 const WTF::String& sourceID);
92 virtual bool canRunBeforeUnloadConfirmPanel();
93 virtual bool runBeforeUnloadConfirmPanel(
94 const WTF::String& message, WebCore::Frame*);
95 virtual void closeWindowSoon();
96 virtual void runJavaScriptAlert(WebCore::Frame*, const WTF::String&);
97 virtual bool runJavaScriptConfirm(WebCore::Frame*, const WTF::String&);
98 virtual bool runJavaScriptPrompt(
99 WebCore::Frame*, const WTF::String& message,
100 const WTF::String& defaultValue, WTF::String& result);
101 virtual void setStatusbarText(const WTF::String& message);
102 virtual bool shouldInterruptJavaScript();
103 virtual WebCore::KeyboardUIMode keyboardUIMode();
104 virtual WebCore::IntRect windowResizerRect() const;
105 #if ENABLE(REGISTER_PROTOCOL_HANDLER)
106 virtual void registerProtocolHandler(const String& scheme, const String& baseURL, const String& url, const String& title);
108 virtual void invalidateRootView(const WebCore::IntRect&, bool);
109 virtual void invalidateContentsAndRootView(const WebCore::IntRect&, bool);
110 virtual void invalidateContentsForSlowScroll(const WebCore::IntRect&, bool);
111 #if ENABLE(REQUEST_ANIMATION_FRAME)
112 virtual void scheduleAnimation();
115 const WebCore::IntSize& scrollDelta, const WebCore::IntRect& rectToScroll,
116 const WebCore::IntRect& clipRect);
117 virtual WebCore::IntPoint screenToRootView(const WebCore::IntPoint&) const;
118 virtual WebCore::IntRect rootViewToScreen(const WebCore::IntRect&) const;
119 virtual PlatformPageClient platformPageClient() const { return 0; }
120 virtual void contentsSizeChanged(WebCore::Frame*, const WebCore::IntSize&) const;
121 virtual void layoutUpdated(WebCore::Frame*) const;
122 virtual void scrollRectIntoView(
123 const WebCore::IntRect&) const { }
124 virtual void scrollbarsModeDidChange() const;
125 virtual void mouseDidMoveOverElement(
126 const WebCore::HitTestResult& result, unsigned modifierFlags);
127 virtual void setToolTip(const WTF::String& tooltipText, WebCore::TextDirection);
128 virtual void print(WebCore::Frame*);
129 virtual void exceededDatabaseQuota(
130 WebCore::Frame*, const WTF::String& databaseName);
131 virtual void reachedMaxAppCacheSize(int64_t spaceNeeded);
132 virtual void reachedApplicationCacheOriginQuota(WebCore::SecurityOrigin*, int64_t totalSpaceNeeded);
133 virtual bool paintCustomOverhangArea(WebCore::GraphicsContext*, const WebCore::IntRect&, const WebCore::IntRect&, const WebCore::IntRect&);
134 virtual void requestGeolocationPermissionForFrame(WebCore::Frame*, WebCore::Geolocation*);
135 virtual void cancelGeolocationPermissionRequestForFrame(WebCore::Frame*, WebCore::Geolocation*);
136 virtual void runOpenPanel(WebCore::Frame*, PassRefPtr<WebCore::FileChooser>);
137 virtual void loadIconForFiles(const Vector<WTF::String>&, WebCore::FileIconLoader*);
138 #if ENABLE(DIRECTORY_UPLOAD)
139 virtual void enumerateChosenDirectory(WebCore::FileChooser*);
141 virtual void setCursor(const WebCore::Cursor&);
142 virtual void setCursorHiddenUntilMouseMoves(bool);
143 virtual void formStateDidChange(const WebCore::Node*);
144 #if ENABLE(TOUCH_EVENTS)
145 // FIXME: All touch events are forwarded regardless of whether or not they are needed.
146 virtual void needTouchEvents(bool needTouchEvents) { }
149 #if USE(ACCELERATED_COMPOSITING)
150 // Pass 0 as the GraphicsLayer to detatch the root layer.
151 virtual void attachRootGraphicsLayer(WebCore::Frame*, WebCore::GraphicsLayer*);
153 // Sets a flag to specify that the next time content is drawn to the window,
154 // the changes appear on the screen in synchrony with updates to GraphicsLayers.
155 virtual void setNeedsOneShotDrawingSynchronization() { }
157 // Sets a flag to specify that the view needs to be updated, so we need
158 // to do an eager layout before the drawing.
159 virtual void scheduleCompositingLayerSync();
161 virtual CompositingTriggerFlags allowedCompositingTriggers() const;
164 virtual bool supportsFullscreenForNode(const WebCore::Node*);
165 virtual void enterFullscreenForNode(WebCore::Node*);
166 virtual void exitFullscreenForNode(WebCore::Node*);
168 #if ENABLE(FULLSCREEN_API)
169 virtual bool supportsFullScreenForElement(const WebCore::Element*, bool withKeyboard);
170 virtual void enterFullScreenForElement(WebCore::Element*);
171 virtual void exitFullScreenForElement(WebCore::Element*);
172 virtual void fullScreenRendererChanged(WebCore::RenderBox*);
175 // ChromeClientChromium methods:
176 virtual void popupOpened(WebCore::PopupContainer* popupContainer,
177 const WebCore::IntRect& bounds,
178 bool handleExternally);
179 virtual void popupClosed(WebCore::PopupContainer* popupContainer);
180 virtual void postAccessibilityNotification(WebCore::AccessibilityObject*, WebCore::AXObjectCache::AXNotification);
183 void setCursorForPlugin(const WebCursorInfo&);
185 virtual bool selectItemWritingDirectionIsNatural();
186 virtual bool selectItemAlignmentFollowsMenuWritingDirection();
187 virtual PassRefPtr<WebCore::PopupMenu> createPopupMenu(WebCore::PopupMenuClient*) const;
188 virtual PassRefPtr<WebCore::SearchPopupMenu> createSearchPopupMenu(WebCore::PopupMenuClient*) const;
190 #if ENABLE(CONTEXT_MENUS)
191 virtual void showContextMenu() { }
194 virtual bool shouldRunModalDialogDuringPageDismissal(const DialogType&, const String& dialogMessage, WebCore::FrameLoader::PageDismissalType) const;
196 virtual bool shouldRubberBandInDirection(WebCore::ScrollDirection) const;
197 virtual void numWheelEventHandlersChanged(unsigned);
200 void getPopupMenuInfo(WebCore::PopupContainer*, WebPopupMenuInfo*);
201 void setCursor(const WebCursorInfo&);
203 WebViewImpl* m_webView; // weak pointer
204 bool m_toolbarsVisible;
205 bool m_statusbarVisible;
206 bool m_scrollbarsVisible;
207 bool m_menubarVisible;
211 } // namespace WebKit