2 * Copyright (C) 2006, 2007, 2008, 2009 Apple, Inc. All rights reserved.
3 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
15 * You should have received a copy of the GNU Library General Public License
16 * along with this library; see the file COPYING.LIB. If not, write to
17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
21 #ifndef ChromeClient_h
22 #define ChromeClient_h
24 #include "AXObjectCache.h"
25 #include "ConsoleTypes.h"
27 #include "FocusDirection.h"
28 #include "FrameLoader.h"
29 #include "GraphicsContext.h"
30 #include "HostWindow.h"
31 #include "PopupMenu.h"
32 #include "PopupMenuClient.h"
33 #include "ScrollTypes.h"
34 #include "SearchPopupMenu.h"
35 #include "WebCoreKeyboardUIMode.h"
36 #include <wtf/Forward.h>
37 #include <wtf/PassOwnPtr.h>
38 #include <wtf/UnusedParam.h>
39 #include <wtf/Vector.h>
48 class AccessibilityObject;
58 class NavigationAction;
61 class PopupMenuClient;
63 class GraphicsContext3D;
66 struct FrameLoadRequest;
67 struct ViewportArguments;
68 struct WindowFeatures;
70 #if USE(ACCELERATED_COMPOSITING)
74 #if ENABLE(INPUT_COLOR)
78 #if ENABLE(NOTIFICATIONS)
79 class NotificationPresenter;
84 virtual void chromeDestroyed() = 0;
86 virtual void setWindowRect(const FloatRect&) = 0;
87 virtual FloatRect windowRect() = 0;
89 virtual FloatRect pageRect() = 0;
91 virtual void focus() = 0;
92 virtual void unfocus() = 0;
94 virtual bool canTakeFocus(FocusDirection) = 0;
95 virtual void takeFocus(FocusDirection) = 0;
97 virtual void focusedNodeChanged(Node*) = 0;
98 virtual void focusedFrameChanged(Frame*) = 0;
100 // The Frame pointer provides the ChromeClient with context about which
101 // Frame wants to create the new Page. Also, the newly created window
102 // should not be shown to the user until the ChromeClient of the newly
103 // created Page has its show method called.
104 // The FrameLoadRequest parameter is only for ChromeClient to check if the
105 // request could be fulfilled. The ChromeClient should not load the request.
106 virtual Page* createWindow(Frame*, const FrameLoadRequest&, const WindowFeatures&, const NavigationAction&) = 0;
107 virtual void show() = 0;
109 virtual bool canRunModal() = 0;
110 virtual void runModal() = 0;
112 virtual void setToolbarsVisible(bool) = 0;
113 virtual bool toolbarsVisible() = 0;
115 virtual void setStatusbarVisible(bool) = 0;
116 virtual bool statusbarVisible() = 0;
118 virtual void setScrollbarsVisible(bool) = 0;
119 virtual bool scrollbarsVisible() = 0;
121 virtual void setMenubarVisible(bool) = 0;
122 virtual bool menubarVisible() = 0;
124 virtual void setResizable(bool) = 0;
126 virtual void addMessageToConsole(MessageSource, MessageType, MessageLevel, const String& message, unsigned int lineNumber, const String& sourceID) = 0;
128 virtual bool canRunBeforeUnloadConfirmPanel() = 0;
129 virtual bool runBeforeUnloadConfirmPanel(const String& message, Frame* frame) = 0;
131 virtual void closeWindowSoon() = 0;
133 virtual void runJavaScriptAlert(Frame*, const String&) = 0;
134 virtual bool runJavaScriptConfirm(Frame*, const String&) = 0;
135 virtual bool runJavaScriptPrompt(Frame*, const String& message, const String& defaultValue, String& result) = 0;
136 virtual void setStatusbarText(const String&) = 0;
137 virtual bool shouldInterruptJavaScript() = 0;
138 virtual KeyboardUIMode keyboardUIMode() = 0;
140 virtual void* webView() const = 0;
142 #if ENABLE(REGISTER_PROTOCOL_HANDLER)
143 virtual void registerProtocolHandler(const String& scheme, const String& baseURL, const String& url, const String& title) = 0;
146 virtual IntRect windowResizerRect() const = 0;
148 // Methods used by HostWindow.
149 virtual void invalidateWindow(const IntRect&, bool) = 0;
150 virtual void invalidateContentsAndWindow(const IntRect&, bool) = 0;
151 virtual void invalidateContentsForSlowScroll(const IntRect&, bool) = 0;
152 virtual void scroll(const IntSize&, const IntRect&, const IntRect&) = 0;
153 #if ENABLE(TILED_BACKING_STORE)
154 virtual void delegatedScrollRequested(const IntPoint&) = 0;
156 virtual IntPoint screenToWindow(const IntPoint&) const = 0;
157 virtual IntRect windowToScreen(const IntRect&) const = 0;
158 virtual PlatformPageClient platformPageClient() const = 0;
159 virtual void scrollbarsModeDidChange() const = 0;
160 virtual void setCursor(const Cursor&) = 0;
161 virtual void setCursorHiddenUntilMouseMoves(bool) = 0;
162 #if ENABLE(REQUEST_ANIMATION_FRAME) && !USE(REQUEST_ANIMATION_FRAME_TIMER)
163 virtual void scheduleAnimation() = 0;
165 // End methods used by HostWindow.
167 virtual void dispatchViewportDataDidChange(const ViewportArguments&) const { }
169 virtual void contentsSizeChanged(Frame*, const IntSize&) const = 0;
170 virtual void layoutUpdated(Frame*) const { }
171 virtual void scrollRectIntoView(const IntRect&) const { }; // Currently only Mac has a non empty implementation.
173 virtual bool shouldMissingPluginMessageBeButton() const { return false; }
174 virtual void missingPluginButtonClicked(Element*) const { }
175 virtual void mouseDidMoveOverElement(const HitTestResult&, unsigned modifierFlags) = 0;
177 virtual void setToolTip(const String&, TextDirection) = 0;
179 virtual void print(Frame*) = 0;
180 virtual bool shouldRubberBandInDirection(ScrollDirection) const = 0;
183 virtual void exceededDatabaseQuota(Frame*, const String& databaseName) = 0;
186 #if ENABLE(OFFLINE_WEB_APPLICATIONS)
187 // Callback invoked when the application cache fails to save a cache object
188 // because storing it would grow the database file past its defined maximum
189 // size or past the amount of free space on the device.
190 // The chrome client would need to take some action such as evicting some
192 virtual void reachedMaxAppCacheSize(int64_t spaceNeeded) = 0;
194 // Callback invoked when the application cache origin quota is reached. This
195 // means that the resources attempting to be cached via the manifest are
196 // more than allowed on this origin. This callback allows the chrome client
197 // to take action, such as prompting the user to ask to increase the quota
198 // for this origin. The totalSpaceNeeded parameter is the total amount of
199 // storage, in bytes, needed to store the new cache along with all of the
200 // other existing caches for the origin that would not be replaced by
202 virtual void reachedApplicationCacheOriginQuota(SecurityOrigin*, int64_t totalSpaceNeeded) = 0;
205 #if ENABLE(DASHBOARD_SUPPORT)
206 virtual void dashboardRegionsChanged();
209 #if ENABLE(NOTIFICATIONS)
210 virtual NotificationPresenter* notificationPresenter() const = 0;
213 virtual void populateVisitedLinks();
215 virtual FloatRect customHighlightRect(Node*, const AtomicString& type, const FloatRect& lineRect);
216 virtual void paintCustomHighlight(Node*, const AtomicString& type, const FloatRect& boxRect, const FloatRect& lineRect,
217 bool behindText, bool entireLine);
219 virtual bool shouldReplaceWithGeneratedFileForUpload(const String& path, String& generatedFilename);
220 virtual String generateReplacementFile(const String& path);
222 virtual bool paintCustomScrollbar(GraphicsContext*, const FloatRect&, ScrollbarControlSize,
223 ScrollbarControlState, ScrollbarPart pressedPart, bool vertical,
224 float value, float proportion, ScrollbarControlPartMask);
225 virtual bool paintCustomScrollCorner(GraphicsContext*, const FloatRect&);
227 virtual bool paintCustomOverhangArea(GraphicsContext*, const IntRect&, const IntRect&, const IntRect&);
229 // FIXME: Remove once all ports are using client-based geolocation. https://bugs.webkit.org/show_bug.cgi?id=40373
230 // For client-based geolocation, these two methods have moved to GeolocationClient. https://bugs.webkit.org/show_bug.cgi?id=50061
231 // This can be either a synchronous or asynchronous call. The ChromeClient can display UI asking the user for permission
232 // to use Geolocation.
233 virtual void requestGeolocationPermissionForFrame(Frame*, Geolocation*) = 0;
234 virtual void cancelGeolocationPermissionRequestForFrame(Frame*, Geolocation*) = 0;
236 #if ENABLE(INPUT_COLOR)
237 virtual void openColorChooser(ColorChooser*, const Color&) = 0;
238 virtual void cleanupColorChooser() = 0;
239 virtual void setSelectedColorInColorChooser(const Color&) = 0;
242 virtual void runOpenPanel(Frame*, PassRefPtr<FileChooser>) = 0;
243 // Asynchronous request to load an icon for specified filenames.
244 virtual void loadIconForFiles(const Vector<String>&, FileIconLoader*) = 0;
246 #if ENABLE(DIRECTORY_UPLOAD)
247 // Asychronous request to enumerate all files in a directory chosen by the user.
248 virtual void enumerateChosenDirectory(FileChooser*) = 0;
251 // Notification that the given form element has changed. This function
252 // will be called frequently, so handling should be very fast.
253 virtual void formStateDidChange(const Node*) = 0;
255 virtual void elementDidFocus(const Node*) { };
256 virtual void elementDidBlur(const Node*) { };
258 #if USE(ACCELERATED_COMPOSITING)
259 // Pass 0 as the GraphicsLayer to detatch the root layer.
260 virtual void attachRootGraphicsLayer(Frame*, GraphicsLayer*) = 0;
261 // Sets a flag to specify that the next time content is drawn to the window,
262 // the changes appear on the screen in synchrony with updates to GraphicsLayers.
263 virtual void setNeedsOneShotDrawingSynchronization() = 0;
264 // Sets a flag to specify that the view needs to be updated, so we need
265 // to do an eager layout before the drawing.
266 virtual void scheduleCompositingLayerSync() = 0;
267 // Returns whether or not the client can render the composited layer,
268 // regardless of the settings.
269 virtual bool allowsAcceleratedCompositing() const { return true; }
271 enum CompositingTrigger {
272 ThreeDTransformTrigger = 1 << 0,
273 VideoTrigger = 1 << 1,
274 PluginTrigger = 1 << 2,
275 CanvasTrigger = 1 << 3,
276 AnimationTrigger = 1 << 4,
277 AllTriggers = 0xFFFFFFFF
279 typedef unsigned CompositingTriggerFlags;
281 // Returns a bitfield indicating conditions that can trigger the compositor.
282 virtual CompositingTriggerFlags allowedCompositingTriggers() const { return static_cast<CompositingTriggerFlags>(AllTriggers); }
285 virtual bool supportsFullscreenForNode(const Node*) { return false; }
286 virtual void enterFullscreenForNode(Node*) { }
287 virtual void exitFullscreenForNode(Node*) { }
288 virtual bool requiresFullscreenForVideoPlayback() { return false; }
290 #if ENABLE(FULLSCREEN_API)
291 virtual bool supportsFullScreenForElement(const Element*, bool) { return false; }
292 virtual void enterFullScreenForElement(Element*) { }
293 virtual void exitFullScreenForElement(Element*) { }
294 virtual void fullScreenRendererChanged(RenderBox*) { }
295 virtual void setRootFullScreenLayer(GraphicsLayer*) { }
298 #if ENABLE(TILED_BACKING_STORE)
299 virtual IntRect visibleRectForTiledBackingStore() const { return IntRect(); }
303 virtual NSResponder *firstResponder() { return 0; }
304 virtual void makeFirstResponder(NSResponder *) { }
305 // Focuses on the containing view associated with this page.
306 virtual void makeFirstResponder() { }
307 virtual void willPopUpMenu(NSMenu *) { }
311 virtual void setLastSetCursorToCurrentCursor() = 0;
314 #if ENABLE(TOUCH_EVENTS)
315 virtual void needTouchEvents(bool) = 0;
318 virtual bool selectItemWritingDirectionIsNatural() = 0;
319 virtual bool selectItemAlignmentFollowsMenuWritingDirection() = 0;
320 virtual PassRefPtr<PopupMenu> createPopupMenu(PopupMenuClient*) const = 0;
321 virtual PassRefPtr<SearchPopupMenu> createSearchPopupMenu(PopupMenuClient*) const = 0;
323 #if ENABLE(CONTEXT_MENUS)
324 virtual void showContextMenu() = 0;
327 virtual void postAccessibilityNotification(AccessibilityObject*, AXObjectCache::AXNotification) { }
329 virtual void didStartRubberBandForFrame(Frame*, const IntSize&) const { }
330 virtual void didCompleteRubberBandForFrame(Frame*, const IntSize&) const { }
331 virtual void didStartAnimatedScroll() const { }
332 virtual void didCompleteAnimatedScroll() const { }
334 virtual void notifyScrollerThumbIsVisibleInRect(const IntRect&) { }
342 virtual bool shouldRunModalDialogDuringPageDismissal(const DialogType&, const String& dialogMessage, FrameLoader::PageDismissalType) const { UNUSED_PARAM(dialogMessage); return true; }
344 virtual void numWheelEventHandlersChanged(unsigned) = 0;
347 virtual ~ChromeClient() { }
352 #endif // ChromeClient_h