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(DASHBOARD_SUPPORT)
226 virtual void dashboardRegionsChanged();
229 virtual void populateVisitedLinks();
231 virtual FloatRect customHighlightRect(Node*, const AtomicString& type, const FloatRect& lineRect);
232 virtual void paintCustomHighlight(Node*, const AtomicString& type, const FloatRect& boxRect, const FloatRect& lineRect,
233 bool behindText, bool entireLine);
235 virtual bool shouldReplaceWithGeneratedFileForUpload(const String& path, String& generatedFilename);
236 virtual String generateReplacementFile(const String& path);
238 virtual bool paintCustomOverhangArea(GraphicsContext*, const IntRect&, const IntRect&, const IntRect&);
240 #if ENABLE(INPUT_TYPE_COLOR)
241 virtual PassOwnPtr<ColorChooser> createColorChooser(ColorChooserClient*, const Color&) = 0;
244 virtual void runOpenPanel(Frame*, PassRefPtr<FileChooser>) = 0;
245 // Asynchronous request to load an icon for specified filenames.
246 virtual void loadIconForFiles(const Vector<String>&, FileIconLoader*) = 0;
248 #if ENABLE(DIRECTORY_UPLOAD)
249 // Asychronous request to enumerate all files in a directory chosen by the user.
250 virtual void enumerateChosenDirectory(FileChooser*) = 0;
253 // Notification that the given form element has changed. This function
254 // will be called frequently, so handling should be very fast.
255 virtual void formStateDidChange(const Node*) = 0;
257 virtual void elementDidFocus(const Node*) { };
258 virtual void elementDidBlur(const Node*) { };
260 #if USE(ACCELERATED_COMPOSITING)
261 // Pass 0 as the GraphicsLayer to detatch the root layer.
262 virtual void attachRootGraphicsLayer(Frame*, GraphicsLayer*) = 0;
263 // Sets a flag to specify that the next time content is drawn to the window,
264 // the changes appear on the screen in synchrony with updates to GraphicsLayers.
265 virtual void setNeedsOneShotDrawingSynchronization() = 0;
266 // Sets a flag to specify that the view needs to be updated, so we need
267 // to do an eager layout before the drawing.
268 virtual void scheduleCompositingLayerSync() = 0;
269 // Returns whether or not the client can render the composited layer,
270 // regardless of the settings.
271 virtual bool allowsAcceleratedCompositing() const { return true; }
273 #if ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_ACCELERATION)
274 virtual void addOrUpdateScrollingLayer(Node*, GraphicsLayer* scrollingLayer, GraphicsLayer* contentsLayer, const IntSize& scrollSize) = 0;
275 virtual void removeScrollingLayer(Node*, GraphicsLayer* scrollingLayer, GraphicsLayer* contentsLayer) = 0;
278 enum CompositingTrigger {
279 ThreeDTransformTrigger = 1 << 0,
280 VideoTrigger = 1 << 1,
281 PluginTrigger = 1 << 2,
282 CanvasTrigger = 1 << 3,
283 AnimationTrigger = 1 << 4,
284 FilterTrigger = 1 << 5,
285 AllTriggers = 0xFFFFFFFF
287 typedef unsigned CompositingTriggerFlags;
289 // Returns a bitfield indicating conditions that can trigger the compositor.
290 virtual CompositingTriggerFlags allowedCompositingTriggers() const { return static_cast<CompositingTriggerFlags>(AllTriggers); }
293 #if PLATFORM(WIN) && USE(AVFOUNDATION)
294 virtual GraphicsDeviceAdapter* graphicsDeviceAdapter() const { return 0; }
297 virtual bool supportsFullscreenForNode(const Node*) { return false; }
298 virtual void enterFullscreenForNode(Node*) { }
299 virtual void exitFullscreenForNode(Node*) { }
300 virtual bool requiresFullscreenForVideoPlayback() { return false; }
302 #if ENABLE(FULLSCREEN_API)
303 virtual bool supportsFullScreenForElement(const Element*, bool) { return false; }
304 virtual void enterFullScreenForElement(Element*) { }
305 virtual void exitFullScreenForElement(Element*) { }
306 virtual void fullScreenRendererChanged(RenderBox*) { }
307 virtual void setRootFullScreenLayer(GraphicsLayer*) { }
310 #if USE(TILED_BACKING_STORE)
311 virtual IntRect visibleRectForTiledBackingStore() const { return IntRect(); }
315 virtual NSResponder *firstResponder() { return 0; }
316 virtual void makeFirstResponder(NSResponder *) { }
317 // Focuses on the containing view associated with this page.
318 virtual void makeFirstResponder() { }
319 virtual void willPopUpMenu(NSMenu *) { }
323 virtual void setLastSetCursorToCurrentCursor() = 0;
326 #if ENABLE(TOUCH_EVENTS)
327 virtual void needTouchEvents(bool) = 0;
330 virtual bool selectItemWritingDirectionIsNatural() = 0;
331 virtual bool selectItemAlignmentFollowsMenuWritingDirection() = 0;
332 // Checks if there is an opened popup, called by RenderMenuList::showPopup().
333 virtual bool hasOpenedPopup() const = 0;
334 virtual PassRefPtr<PopupMenu> createPopupMenu(PopupMenuClient*) const = 0;
335 virtual PassRefPtr<SearchPopupMenu> createSearchPopupMenu(PopupMenuClient*) const = 0;
336 #if ENABLE(PAGE_POPUP)
337 // Creates a PagePopup object, and shows it beside originBoundsInRootView.
338 // The return value can be 0.
339 virtual PagePopup* openPagePopup(PagePopupClient*, const IntRect& originBoundsInRootView) = 0;
340 virtual void closePagePopup(PagePopup*) = 0;
342 virtual void setPagePopupDriver(PagePopupDriver*) = 0;
343 virtual void resetPagePopupDriver() = 0;
345 // This function is called whenever a text field <input> is
346 // created. The implementation should return true if it wants
347 // to do something in addTextFieldDecorationsTo().
348 // The argument is always non-0.
349 virtual bool willAddTextFieldDecorationsTo(HTMLInputElement*) { return false; }
350 // The argument is always non-0.
351 virtual void addTextFieldDecorationsTo(HTMLInputElement*) { }
353 virtual void postAccessibilityNotification(AccessibilityObject*, AXObjectCache::AXNotification) { }
355 virtual void didStartRubberBandForFrame(Frame*, const IntSize&) const { }
356 virtual void didCompleteRubberBandForFrame(Frame*, const IntSize&) const { }
357 virtual void didStartAnimatedScroll() const { }
358 virtual void didCompleteAnimatedScroll() const { }
360 virtual void notifyScrollerThumbIsVisibleInRect(const IntRect&) { }
361 virtual void recommendedScrollbarStyleDidChange(int /*newStyle*/) { }
369 virtual bool shouldRunModalDialogDuringPageDismissal(const DialogType&, const String& dialogMessage, FrameLoader::PageDismissalType) const { UNUSED_PARAM(dialogMessage); return true; }
371 virtual void numWheelEventHandlersChanged(unsigned) = 0;
373 virtual bool isSVGImageChromeClient() const { return false; }
375 #if ENABLE(POINTER_LOCK)
376 virtual bool requestPointerLock() { return false; }
377 virtual void requestPointerUnlock() { }
378 virtual bool isPointerLocked() { return false; }
381 #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
382 virtual bool getStandaloneStatus() { return true; }
385 #if ENABLE(SCREEN_ORIENTATION_SUPPORT)
386 virtual bool lockOrientation(int willLockOrientation) { return false; }
387 virtual void unlockOrientation() { }
390 virtual void logDiagnosticMessage(const String& message, const String& description, const String& status) { UNUSED_PARAM(message); UNUSED_PARAM(description); UNUSED_PARAM(status); }
392 #if ENABLE(TIZEN_WEBKIT2_HISTORICAL_RESTORE_VISIBLE_CONTENT_RECT)
393 virtual void requestVisibleContentRectRestore(const IntPoint& scrollOffset, float scale) = 0;
394 virtual float contentsScaleFactor() const = 0;
397 #if ENABLE(TIZEN_SCREEN_READER)
398 virtual void rendererWillBeDestroyed(RenderObject*) { }
402 virtual ~ChromeClient() { }
406 #endif // ChromeClient_h