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>
41 #if PLATFORM(EFL) && ENABLE(TIZEN_EVAS_OBJECT_PLUGIN)
42 #include "PluginView.h"
52 class AccessibilityObject;
62 class NavigationAction;
65 class PopupMenuClient;
67 class GraphicsContext3D;
70 struct FrameLoadRequest;
71 struct ViewportArguments;
72 struct WindowFeatures;
74 #if USE(ACCELERATED_COMPOSITING)
78 #if ENABLE(INPUT_COLOR)
84 virtual void chromeDestroyed() = 0;
86 virtual void setWindowRect(const FloatRect&) = 0;
87 virtual FloatRect windowRect() = 0;
89 virtual FloatRect pageRect() = 0;
91 #if ENABLE(TIZEN_INNER_SCREEN_RECT)
92 virtual FloatRect innerScreenRect() = 0;
95 #if ENABLE(TIZEN_MEDIA_QUERY)
96 virtual int getDPI() = 0;
97 virtual double getDPCM() = 0;
100 virtual void focus() = 0;
101 virtual void unfocus() = 0;
103 virtual bool canTakeFocus(FocusDirection) = 0;
104 virtual void takeFocus(FocusDirection) = 0;
106 virtual void focusedNodeChanged(Node*) = 0;
107 virtual void focusedFrameChanged(Frame*) = 0;
109 // The Frame pointer provides the ChromeClient with context about which
110 // Frame wants to create the new Page. Also, the newly created window
111 // should not be shown to the user until the ChromeClient of the newly
112 // created Page has its show method called.
113 // The FrameLoadRequest parameter is only for ChromeClient to check if the
114 // request could be fulfilled. The ChromeClient should not load the request.
115 virtual Page* createWindow(Frame*, const FrameLoadRequest&, const WindowFeatures&, const NavigationAction&) = 0;
116 virtual void show() = 0;
118 virtual bool canRunModal() = 0;
119 virtual void runModal() = 0;
121 virtual void setToolbarsVisible(bool) = 0;
122 virtual bool toolbarsVisible() = 0;
124 virtual void setStatusbarVisible(bool) = 0;
125 virtual bool statusbarVisible() = 0;
127 virtual void setScrollbarsVisible(bool) = 0;
128 virtual bool scrollbarsVisible() = 0;
130 virtual void setMenubarVisible(bool) = 0;
131 virtual bool menubarVisible() = 0;
133 virtual void setResizable(bool) = 0;
135 virtual void addMessageToConsole(MessageSource, MessageType, MessageLevel, const String& message, unsigned int lineNumber, const String& sourceID) = 0;
137 virtual bool canRunBeforeUnloadConfirmPanel() = 0;
138 virtual bool runBeforeUnloadConfirmPanel(const String& message, Frame* frame) = 0;
140 virtual void closeWindowSoon() = 0;
142 virtual void runJavaScriptAlert(Frame*, const String&) = 0;
143 virtual bool runJavaScriptConfirm(Frame*, const String&) = 0;
144 virtual bool runJavaScriptPrompt(Frame*, const String& message, const String& defaultValue, String& result) = 0;
145 virtual void setStatusbarText(const String&) = 0;
146 virtual bool shouldInterruptJavaScript() = 0;
147 virtual KeyboardUIMode keyboardUIMode() = 0;
149 virtual void* webView() const = 0;
151 #if ENABLE(REGISTER_PROTOCOL_HANDLER)
152 virtual void registerProtocolHandler(const String& scheme, const String& baseURL, const String& url, const String& title) = 0;
155 virtual IntRect windowResizerRect() const = 0;
157 // Methods used by HostWindow.
158 virtual void invalidateRootView(const IntRect&, bool) = 0;
159 virtual void invalidateContentsAndRootView(const IntRect&, bool) = 0;
160 virtual void invalidateContentsForSlowScroll(const IntRect&, bool) = 0;
161 virtual void scroll(const IntSize&, const IntRect&, const IntRect&) = 0;
162 #if USE(TILED_BACKING_STORE)
163 virtual void delegatedScrollRequested(const IntPoint&) = 0;
165 virtual IntPoint screenToRootView(const IntPoint&) const = 0;
166 virtual IntRect rootViewToScreen(const IntRect&) const = 0;
167 virtual PlatformPageClient platformPageClient() const = 0;
168 virtual void scrollbarsModeDidChange() const = 0;
169 virtual void setCursor(const Cursor&) = 0;
170 virtual void setCursorHiddenUntilMouseMoves(bool) = 0;
171 #if ENABLE(REQUEST_ANIMATION_FRAME) && !USE(REQUEST_ANIMATION_FRAME_TIMER)
172 virtual void scheduleAnimation() = 0;
174 // End methods used by HostWindow.
176 virtual void dispatchViewportPropertiesDidChange(const ViewportArguments&) const { }
178 #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
179 virtual void setMobileWebAppCapableState(const String&) { }
180 virtual void setMobileWebAppStatusBarStyle(const String&) { }
182 #if ENABLE(TIZEN_SUPPORT_VIEWPORT)
183 virtual bool canContentsSizeChange(Frame*, const IntSize&) const = 0;
185 virtual void contentsSizeChanged(Frame*, const IntSize&) const = 0;
186 virtual void layoutUpdated(Frame*) const { }
187 virtual void scrollRectIntoView(const IntRect&) const { }; // Currently only Mac has a non empty implementation.
189 virtual bool shouldMissingPluginMessageBeButton() const { return false; }
190 virtual void missingPluginButtonClicked(Element*) const { }
191 virtual void mouseDidMoveOverElement(const HitTestResult&, unsigned modifierFlags) = 0;
193 virtual void setToolTip(const String&, TextDirection) = 0;
195 virtual void print(Frame*) = 0;
196 virtual bool shouldRubberBandInDirection(ScrollDirection) const = 0;
198 #if ENABLE(SQL_DATABASE)
199 virtual void exceededDatabaseQuota(Frame*, const String& databaseName) = 0;
202 // Callback invoked when the application cache fails to save a cache object
203 // because storing it would grow the database file past its defined maximum
204 // size or past the amount of free space on the device.
205 // The chrome client would need to take some action such as evicting some
207 virtual void reachedMaxAppCacheSize(int64_t spaceNeeded) = 0;
209 // Callback invoked when the application cache origin quota is reached. This
210 // means that the resources attempting to be cached via the manifest are
211 // more than allowed on this origin. This callback allows the chrome client
212 // to take action, such as prompting the user to ask to increase the quota
213 // for this origin. The totalSpaceNeeded parameter is the total amount of
214 // storage, in bytes, needed to store the new cache along with all of the
215 // other existing caches for the origin that would not be replaced by
217 virtual void reachedApplicationCacheOriginQuota(SecurityOrigin*, int64_t totalSpaceNeeded) = 0;
219 #if ENABLE(DASHBOARD_SUPPORT)
220 virtual void dashboardRegionsChanged();
223 virtual void populateVisitedLinks();
225 virtual FloatRect customHighlightRect(Node*, const AtomicString& type, const FloatRect& lineRect);
226 virtual void paintCustomHighlight(Node*, const AtomicString& type, const FloatRect& boxRect, const FloatRect& lineRect,
227 bool behindText, bool entireLine);
229 virtual bool shouldReplaceWithGeneratedFileForUpload(const String& path, String& generatedFilename);
230 virtual String generateReplacementFile(const String& path);
232 virtual bool paintCustomOverhangArea(GraphicsContext*, const IntRect&, const IntRect&, const IntRect&);
234 // FIXME: Remove once all ports are using client-based geolocation. https://bugs.webkit.org/show_bug.cgi?id=40373
235 // For client-based geolocation, these two methods have moved to GeolocationClient. https://bugs.webkit.org/show_bug.cgi?id=50061
236 // This can be either a synchronous or asynchronous call. The ChromeClient can display UI asking the user for permission
237 // to use Geolocation.
238 virtual void requestGeolocationPermissionForFrame(Frame*, Geolocation*) = 0;
239 virtual void cancelGeolocationPermissionRequestForFrame(Frame*, Geolocation*) = 0;
241 #if ENABLE(INPUT_COLOR)
242 virtual void openColorChooser(ColorChooser*, const Color&) = 0;
243 virtual void cleanupColorChooser(ColorChooser*) = 0;
244 virtual void setSelectedColorInColorChooser(ColorChooser*, const Color&) = 0;
247 virtual void runOpenPanel(Frame*, PassRefPtr<FileChooser>) = 0;
248 // Asynchronous request to load an icon for specified filenames.
249 virtual void loadIconForFiles(const Vector<String>&, FileIconLoader*) = 0;
251 #if ENABLE(DIRECTORY_UPLOAD)
252 // Asychronous request to enumerate all files in a directory chosen by the user.
253 virtual void enumerateChosenDirectory(FileChooser*) = 0;
256 // Notification that the given form element has changed. This function
257 // will be called frequently, so handling should be very fast.
258 virtual void formStateDidChange(const Node*) = 0;
260 virtual void elementDidFocus(const Node*) { };
261 virtual void elementDidBlur(const Node*) { };
263 #if USE(ACCELERATED_COMPOSITING)
264 // Pass 0 as the GraphicsLayer to detatch the root layer.
265 virtual void attachRootGraphicsLayer(Frame*, GraphicsLayer*) = 0;
266 // Sets a flag to specify that the next time content is drawn to the window,
267 // the changes appear on the screen in synchrony with updates to GraphicsLayers.
268 virtual void setNeedsOneShotDrawingSynchronization() = 0;
269 // Sets a flag to specify that the view needs to be updated, so we need
270 // to do an eager layout before the drawing.
271 virtual void scheduleCompositingLayerSync() = 0;
272 // Returns whether or not the client can render the composited layer,
273 // regardless of the settings.
274 virtual bool allowsAcceleratedCompositing() const { return true; }
276 #if ENABLE(CANVAS_CAIRO_GLES_RENDERING)
277 virtual void* sharedCairoDevice() { return 0; }
279 #if ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_ACCELERATION)
280 virtual void addOrUpdateScrollingLayer(Node*, PlatformLayer* scrollingLayer, PlatformLayer* contentsLayer, const IntSize& scrollSize) = 0;
281 virtual void removeScrollingLayer(Node*, PlatformLayer* scrollingLayer, PlatformLayer* contentsLayer) = 0;
284 enum CompositingTrigger {
285 ThreeDTransformTrigger = 1 << 0,
286 VideoTrigger = 1 << 1,
287 PluginTrigger = 1 << 2,
288 CanvasTrigger = 1 << 3,
289 AnimationTrigger = 1 << 4,
290 AllTriggers = 0xFFFFFFFF
292 typedef unsigned CompositingTriggerFlags;
294 // Returns a bitfield indicating conditions that can trigger the compositor.
295 virtual CompositingTriggerFlags allowedCompositingTriggers() const { return static_cast<CompositingTriggerFlags>(AllTriggers); }
298 virtual bool supportsFullscreenForNode(const Node*) { return false; }
299 virtual void enterFullscreenForNode(Node*) { }
300 virtual void exitFullscreenForNode(Node*) { }
301 virtual bool requiresFullscreenForVideoPlayback() { return false; }
303 #if ENABLE(FULLSCREEN_API)
304 virtual bool supportsFullScreenForElement(const Element*, bool) { return false; }
305 virtual void enterFullScreenForElement(Element*) { }
306 virtual void exitFullScreenForElement(Element*) { }
307 virtual void fullScreenRendererChanged(RenderBox*) { }
308 virtual void setRootFullScreenLayer(GraphicsLayer*) { }
311 #if USE(TILED_BACKING_STORE)
312 virtual IntRect visibleRectForTiledBackingStore() const { return IntRect(); }
316 virtual NSResponder *firstResponder() { return 0; }
317 virtual void makeFirstResponder(NSResponder *) { }
318 // Focuses on the containing view associated with this page.
319 virtual void makeFirstResponder() { }
320 virtual void willPopUpMenu(NSMenu *) { }
324 virtual void setLastSetCursorToCurrentCursor() = 0;
327 #if ENABLE(TOUCH_EVENTS)
328 virtual void needTouchEvents(bool) = 0;
331 virtual bool selectItemWritingDirectionIsNatural() = 0;
332 virtual bool selectItemAlignmentFollowsMenuWritingDirection() = 0;
333 virtual PassRefPtr<PopupMenu> createPopupMenu(PopupMenuClient*) const = 0;
334 virtual PassRefPtr<SearchPopupMenu> createSearchPopupMenu(PopupMenuClient*) const = 0;
336 #if ENABLE(CONTEXT_MENUS)
337 virtual void showContextMenu() = 0;
340 virtual void postAccessibilityNotification(AccessibilityObject*, AXObjectCache::AXNotification) { }
342 #if PLATFORM(EFL) && ENABLE(TIZEN_EVAS_OBJECT_PLUGIN)
343 virtual void getPluginStorage(PluginStorage*) = 0;
344 #if ENABLE(TIZEN_SUPPORT_PLUGINS) && ENABLE(TIZEN_DONT_PAN_OVER_SOME_PLUGINS)
345 virtual void repeatEventsToPlugin(bool) = 0;
346 virtual void eventsHandledByPluginChanged(bool newState) = 0;
350 #if PLATFORM(EFL) && ENABLE(TIZEN_SHOULD_ALLOW_OPEN_URL)
351 virtual bool shouldAllowOpenUrl(const char* url) { return true; };
353 virtual void didStartRubberBandForFrame(Frame*, const IntSize&) const { }
354 virtual void didCompleteRubberBandForFrame(Frame*, const IntSize&) const { }
355 virtual void didStartAnimatedScroll() const { }
356 virtual void didCompleteAnimatedScroll() const { }
358 virtual void notifyScrollerThumbIsVisibleInRect(const IntRect&) { }
359 virtual void recommendedScrollbarStyleDidChange(int /*newStyle*/) { }
367 virtual bool shouldRunModalDialogDuringPageDismissal(const DialogType&, const String& dialogMessage, FrameLoader::PageDismissalType) const { UNUSED_PARAM(dialogMessage); return true; }
369 virtual void numWheelEventHandlersChanged(unsigned) = 0;
371 virtual bool isSVGImageChromeClient() const { return false; }
374 virtual ~ChromeClient() { }
379 #endif // ChromeClient_h