2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple, Inc. All rights reserved.
3 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
4 * Copyright (C) 2012 Samsung Electronics. All rights reserved.
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
16 * You should have received a copy of the GNU Library General Public License
17 * along with this library; see the file COPYING.LIB. If not, write to
18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02110-1301, USA.
22 #ifndef ChromeClient_h
23 #define ChromeClient_h
25 #include "AXObjectCache.h"
26 #include "ConsoleTypes.h"
28 #include "FocusDirection.h"
29 #include "FrameLoader.h"
30 #include "GraphicsContext.h"
31 #include "HostWindow.h"
32 #include "PopupMenu.h"
33 #include "PopupMenuClient.h"
34 #include "RenderEmbeddedObject.h"
35 #include "ScrollTypes.h"
36 #include "SearchPopupMenu.h"
37 #include "WebCoreKeyboardUIMode.h"
38 #include <wtf/Forward.h>
39 #include <wtf/PassOwnPtr.h>
40 #include <wtf/UnusedParam.h>
41 #include <wtf/Vector.h>
50 class AccessibilityObject;
58 class HTMLInputElement;
61 class NavigationAction;
65 class PagePopupClient;
66 class PagePopupDriver;
67 class PopupMenuClient;
69 class GraphicsContext3D;
72 struct FrameLoadRequest;
73 struct ViewportArguments;
74 struct WindowFeatures;
76 #if USE(ACCELERATED_COMPOSITING)
80 #if ENABLE(INPUT_TYPE_COLOR)
82 class ColorChooserClient;
85 #if PLATFORM(WIN) && USE(AVFOUNDATION)
86 struct GraphicsDeviceAdapter;
91 virtual void chromeDestroyed() = 0;
93 virtual void setWindowRect(const FloatRect&) = 0;
94 virtual FloatRect windowRect() = 0;
96 virtual FloatRect pageRect() = 0;
98 virtual void focus() = 0;
99 virtual void unfocus() = 0;
101 virtual bool canTakeFocus(FocusDirection) = 0;
102 virtual void takeFocus(FocusDirection) = 0;
104 virtual void focusedNodeChanged(Node*) = 0;
105 virtual void focusedFrameChanged(Frame*) = 0;
107 // The Frame pointer provides the ChromeClient with context about which
108 // Frame wants to create the new Page. Also, the newly created window
109 // should not be shown to the user until the ChromeClient of the newly
110 // created Page has its show method called.
111 // The FrameLoadRequest parameter is only for ChromeClient to check if the
112 // request could be fulfilled. The ChromeClient should not load the request.
113 virtual Page* createWindow(Frame*, const FrameLoadRequest&, const WindowFeatures&, const NavigationAction&) = 0;
114 virtual void show() = 0;
116 virtual bool canRunModal() = 0;
117 virtual void runModal() = 0;
119 virtual void setToolbarsVisible(bool) = 0;
120 virtual bool toolbarsVisible() = 0;
122 virtual void setStatusbarVisible(bool) = 0;
123 virtual bool statusbarVisible() = 0;
125 virtual void setScrollbarsVisible(bool) = 0;
126 virtual bool scrollbarsVisible() = 0;
128 virtual void setMenubarVisible(bool) = 0;
129 virtual bool menubarVisible() = 0;
131 virtual void setResizable(bool) = 0;
133 virtual void addMessageToConsole(MessageSource, MessageType, MessageLevel, const String& message, unsigned int lineNumber, const String& sourceID) = 0;
135 virtual bool canRunBeforeUnloadConfirmPanel() = 0;
136 virtual bool runBeforeUnloadConfirmPanel(const String& message, Frame* frame) = 0;
138 virtual void closeWindowSoon() = 0;
140 virtual void runJavaScriptAlert(Frame*, const String&) = 0;
141 virtual bool runJavaScriptConfirm(Frame*, const String&) = 0;
142 virtual bool runJavaScriptPrompt(Frame*, const String& message, const String& defaultValue, String& result) = 0;
143 virtual void setStatusbarText(const String&) = 0;
144 virtual bool shouldInterruptJavaScript() = 0;
145 virtual KeyboardUIMode keyboardUIMode() = 0;
147 virtual void* webView() const = 0;
149 #if ENABLE(CUSTOM_SCHEME_HANDLER) || !ENABLE(TIZEN_REGISTER_SCHEME_HANDLER)
150 enum CustomHandlersState {
152 CustomHandlersRegistered,
153 CustomHandlersDeclined
157 #if ENABLE(CUSTOM_SCHEME_HANDLER) && !ENABLE(TIZEN_CUSTOM_SCHEME_HANDLER)
158 virtual CustomHandlersState isProtocolHandlerRegistered(const String& scheme, const String& baseURL, const String& url) = 0;
159 virtual void unregisterProtocolHandler(const String& scheme, const String& baseURL, const String& url) = 0;
162 #if ENABLE(TIZEN_SEARCH_PROVIDER)
163 virtual void addSearchProvider(const String& baseURL, const String& engineURL) = 0;
164 virtual unsigned long isSearchProviderInstalled(const String& baseURL, const String& engineURL) = 0;
168 virtual IntRect windowResizerRect() const = 0;
170 // Methods used by HostWindow.
171 virtual void invalidateRootView(const IntRect&, bool) = 0;
172 virtual void invalidateContentsAndRootView(const IntRect&, bool) = 0;
173 virtual void invalidateContentsForSlowScroll(const IntRect&, bool) = 0;
174 virtual void scroll(const IntSize&, const IntRect&, const IntRect&) = 0;
175 #if USE(TILED_BACKING_STORE)
176 virtual void delegatedScrollRequested(const IntPoint&) = 0;
178 virtual IntPoint screenToRootView(const IntPoint&) const = 0;
179 virtual IntRect rootViewToScreen(const IntRect&) const = 0;
180 virtual PlatformPageClient platformPageClient() const = 0;
181 virtual void scrollbarsModeDidChange() const = 0;
182 virtual void setCursor(const Cursor&) = 0;
183 virtual void setCursorHiddenUntilMouseMoves(bool) = 0;
184 #if ENABLE(REQUEST_ANIMATION_FRAME) && !USE(REQUEST_ANIMATION_FRAME_TIMER)
185 virtual void scheduleAnimation() = 0;
187 // End methods used by HostWindow.
189 virtual void dispatchViewportPropertiesDidChange(const ViewportArguments&) const { }
191 virtual void contentsSizeChanged(Frame*, const IntSize&) const = 0;
192 virtual void layoutUpdated(Frame*) const { }
193 virtual void scrollRectIntoView(const IntRect&) const { }; // Currently only Mac has a non empty implementation.
195 virtual bool shouldUnavailablePluginMessageBeButton(RenderEmbeddedObject::PluginUnavailabilityReason) const { return false; }
196 virtual void unavailablePluginButtonClicked(Element*, RenderEmbeddedObject::PluginUnavailabilityReason) const { }
197 virtual void mouseDidMoveOverElement(const HitTestResult&, unsigned modifierFlags) = 0;
199 virtual void setToolTip(const String&, TextDirection) = 0;
201 virtual void print(Frame*) = 0;
202 virtual bool shouldRubberBandInDirection(ScrollDirection) const = 0;
204 #if ENABLE(SQL_DATABASE)
205 virtual void exceededDatabaseQuota(Frame*, const String& databaseName) = 0;
208 // Callback invoked when the application cache fails to save a cache object
209 // because storing it would grow the database file past its defined maximum
210 // size or past the amount of free space on the device.
211 // The chrome client would need to take some action such as evicting some
213 virtual void reachedMaxAppCacheSize(int64_t spaceNeeded) = 0;
215 // Callback invoked when the application cache origin quota is reached. This
216 // means that the resources attempting to be cached via the manifest are
217 // more than allowed on this origin. This callback allows the chrome client
218 // to take action, such as prompting the user to ask to increase the quota
219 // for this origin. The totalSpaceNeeded parameter is the total amount of
220 // storage, in bytes, needed to store the new cache along with all of the
221 // other existing caches for the origin that would not be replaced by
223 virtual void reachedApplicationCacheOriginQuota(SecurityOrigin*, int64_t totalSpaceNeeded) = 0;
225 #if ENABLE(TIZEN_APPLICATION_CACHE)
226 virtual bool requestApplicationCachePermission(Frame*) = 0;
229 #if ENABLE(DASHBOARD_SUPPORT)
230 virtual void dashboardRegionsChanged();
233 virtual void populateVisitedLinks();
235 virtual FloatRect customHighlightRect(Node*, const AtomicString& type, const FloatRect& lineRect);
236 virtual void paintCustomHighlight(Node*, const AtomicString& type, const FloatRect& boxRect, const FloatRect& lineRect,
237 bool behindText, bool entireLine);
239 virtual bool shouldReplaceWithGeneratedFileForUpload(const String& path, String& generatedFilename);
240 virtual String generateReplacementFile(const String& path);
242 virtual bool paintCustomOverhangArea(GraphicsContext*, const IntRect&, const IntRect&, const IntRect&);
244 #if ENABLE(INPUT_TYPE_COLOR)
245 virtual PassOwnPtr<ColorChooser> createColorChooser(ColorChooserClient*, const Color&) = 0;
248 virtual void runOpenPanel(Frame*, PassRefPtr<FileChooser>) = 0;
249 // Asynchronous request to load an icon for specified filenames.
250 virtual void loadIconForFiles(const Vector<String>&, FileIconLoader*) = 0;
252 #if ENABLE(DIRECTORY_UPLOAD)
253 // Asychronous request to enumerate all files in a directory chosen by the user.
254 virtual void enumerateChosenDirectory(FileChooser*) = 0;
257 // Notification that the given form element has changed. This function
258 // will be called frequently, so handling should be very fast.
259 virtual void formStateDidChange(const Node*) = 0;
261 virtual void elementDidFocus(const Node*) { };
262 virtual void elementDidBlur(const Node*) { };
264 #if USE(ACCELERATED_COMPOSITING)
265 // Pass 0 as the GraphicsLayer to detatch the root layer.
266 virtual void attachRootGraphicsLayer(Frame*, GraphicsLayer*) = 0;
267 // Sets a flag to specify that the next time content is drawn to the window,
268 // the changes appear on the screen in synchrony with updates to GraphicsLayers.
269 virtual void setNeedsOneShotDrawingSynchronization() = 0;
270 // Sets a flag to specify that the view needs to be updated, so we need
271 // to do an eager layout before the drawing.
272 virtual void scheduleCompositingLayerSync() = 0;
273 // Returns whether or not the client can render the composited layer,
274 // regardless of the settings.
275 virtual bool allowsAcceleratedCompositing() const { return true; }
277 #if ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_ACCELERATION)
278 virtual void addOrUpdateScrollingLayer(Node*, GraphicsLayer* scrollingLayer, GraphicsLayer* contentsLayer, const IntSize& scrollSize) = 0;
279 virtual void removeScrollingLayer(Node*, GraphicsLayer* scrollingLayer, GraphicsLayer* contentsLayer) = 0;
282 enum CompositingTrigger {
283 ThreeDTransformTrigger = 1 << 0,
284 VideoTrigger = 1 << 1,
285 PluginTrigger = 1 << 2,
286 CanvasTrigger = 1 << 3,
287 AnimationTrigger = 1 << 4,
288 FilterTrigger = 1 << 5,
289 AllTriggers = 0xFFFFFFFF
291 typedef unsigned CompositingTriggerFlags;
293 // Returns a bitfield indicating conditions that can trigger the compositor.
294 virtual CompositingTriggerFlags allowedCompositingTriggers() const { return static_cast<CompositingTriggerFlags>(AllTriggers); }
297 #if PLATFORM(WIN) && USE(AVFOUNDATION)
298 virtual GraphicsDeviceAdapter* graphicsDeviceAdapter() const { return 0; }
301 virtual bool supportsFullscreenForNode(const Node*) { return false; }
302 virtual void enterFullscreenForNode(Node*) { }
303 virtual void exitFullscreenForNode(Node*) { }
304 virtual bool requiresFullscreenForVideoPlayback() { return false; }
306 #if ENABLE(FULLSCREEN_API)
307 virtual bool supportsFullScreenForElement(const Element*, bool) { return false; }
308 virtual void enterFullScreenForElement(Element*) { }
309 virtual void exitFullScreenForElement(Element*) { }
310 virtual void fullScreenRendererChanged(RenderBox*) { }
311 virtual void setRootFullScreenLayer(GraphicsLayer*) { }
314 #if USE(TILED_BACKING_STORE)
315 virtual IntRect visibleRectForTiledBackingStore() const { return IntRect(); }
319 virtual NSResponder *firstResponder() { return 0; }
320 virtual void makeFirstResponder(NSResponder *) { }
321 // Focuses on the containing view associated with this page.
322 virtual void makeFirstResponder() { }
323 virtual void willPopUpMenu(NSMenu *) { }
327 virtual void setLastSetCursorToCurrentCursor() = 0;
330 #if ENABLE(TOUCH_EVENTS)
331 virtual void needTouchEvents(bool) = 0;
334 virtual bool selectItemWritingDirectionIsNatural() = 0;
335 virtual bool selectItemAlignmentFollowsMenuWritingDirection() = 0;
336 // Checks if there is an opened popup, called by RenderMenuList::showPopup().
337 virtual bool hasOpenedPopup() const = 0;
338 virtual PassRefPtr<PopupMenu> createPopupMenu(PopupMenuClient*) const = 0;
339 virtual PassRefPtr<SearchPopupMenu> createSearchPopupMenu(PopupMenuClient*) const = 0;
340 #if ENABLE(PAGE_POPUP)
341 // Creates a PagePopup object, and shows it beside originBoundsInRootView.
342 // The return value can be 0.
343 virtual PagePopup* openPagePopup(PagePopupClient*, const IntRect& originBoundsInRootView) = 0;
344 virtual void closePagePopup(PagePopup*) = 0;
346 virtual void setPagePopupDriver(PagePopupDriver*) = 0;
347 virtual void resetPagePopupDriver() = 0;
349 // This function is called whenever a text field <input> is
350 // created. The implementation should return true if it wants
351 // to do something in addTextFieldDecorationsTo().
352 // The argument is always non-0.
353 virtual bool willAddTextFieldDecorationsTo(HTMLInputElement*) { return false; }
354 // The argument is always non-0.
355 virtual void addTextFieldDecorationsTo(HTMLInputElement*) { }
357 virtual void postAccessibilityNotification(AccessibilityObject*, AXObjectCache::AXNotification) { }
359 virtual void didStartRubberBandForFrame(Frame*, const IntSize&) const { }
360 virtual void didCompleteRubberBandForFrame(Frame*, const IntSize&) const { }
361 virtual void didStartAnimatedScroll() const { }
362 virtual void didCompleteAnimatedScroll() const { }
364 virtual void notifyScrollerThumbIsVisibleInRect(const IntRect&) { }
365 virtual void recommendedScrollbarStyleDidChange(int /*newStyle*/) { }
373 virtual bool shouldRunModalDialogDuringPageDismissal(const DialogType&, const String& dialogMessage, FrameLoader::PageDismissalType) const { UNUSED_PARAM(dialogMessage); return true; }
375 virtual void numWheelEventHandlersChanged(unsigned) = 0;
377 virtual bool isSVGImageChromeClient() const { return false; }
379 #if ENABLE(POINTER_LOCK)
380 virtual bool requestPointerLock() { return false; }
381 virtual void requestPointerUnlock() { }
382 virtual bool isPointerLocked() { return false; }
385 #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
386 virtual bool getStandaloneStatus() { return true; }
389 #if ENABLE(SCREEN_ORIENTATION_SUPPORT)
390 virtual bool lockOrientation(int willLockOrientation) { return false; }
391 virtual void unlockOrientation() { }
394 virtual void logDiagnosticMessage(const String& message, const String& description, const String& status) { UNUSED_PARAM(message); UNUSED_PARAM(description); UNUSED_PARAM(status); }
396 #if ENABLE(TIZEN_WEBKIT2_HISTORICAL_RESTORE_VISIBLE_CONTENT_RECT)
397 virtual void requestVisibleContentRectRestore(const IntPoint& scrollOffset, float scale) = 0;
398 virtual float contentsScaleFactor() const = 0;
402 virtual void rendererWillBeDestroyed(RenderObject*) { }
405 #if ENABLE(TIZEN_INDEXED_DATABASE)
406 virtual bool exceededIndexedDatabaseQuota(Frame*, int64_t) = 0;
409 #if ENABLE(TIZEN_FILE_SYSTEM)
410 virtual bool exceededLocalFileSystemQuota(Frame*, int64_t currentUsage) = 0;
414 virtual ~ChromeClient() { }
418 #endif // ChromeClient_h