tizen beta release
[profile/ivi/webkit-efl.git] / Source / WebCore / page / ChromeClient.h
1 /*
2  * Copyright (C) 2006, 2007, 2008, 2009 Apple, Inc. All rights reserved.
3  * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
4  *
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.
9  *
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.
14  *
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.
19  */
20
21 #ifndef ChromeClient_h
22 #define ChromeClient_h
23
24 #include "AXObjectCache.h"
25 #include "ConsoleTypes.h"
26 #include "Cursor.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>
40
41 #if PLATFORM(EFL) && ENABLE(TIZEN_EVAS_OBJECT_PLUGIN)
42 #include "PluginView.h"
43 #endif
44
45 #ifndef __OBJC__
46 class NSMenu;
47 class NSResponder;
48 #endif
49
50 namespace WebCore {
51
52     class AccessibilityObject;
53     class Element;
54     class FileChooser;
55     class FileIconLoader;
56     class FloatRect;
57     class Frame;
58     class Geolocation;
59     class GraphicsLayer;
60     class HitTestResult;
61     class IntRect;
62     class NavigationAction;
63     class Node;
64     class Page;
65     class PopupMenuClient;
66     class SecurityOrigin;
67     class GraphicsContext3D;
68     class Widget;
69
70     struct FrameLoadRequest;
71     struct ViewportArguments;
72     struct WindowFeatures;
73
74 #if USE(ACCELERATED_COMPOSITING)
75     class GraphicsLayer;
76 #endif
77
78 #if ENABLE(INPUT_COLOR)
79     class ColorChooser;
80 #endif
81
82     class ChromeClient {
83     public:
84         virtual void chromeDestroyed() = 0;
85         
86         virtual void setWindowRect(const FloatRect&) = 0;
87         virtual FloatRect windowRect() = 0;
88         
89         virtual FloatRect pageRect() = 0;
90
91 #if ENABLE(TIZEN_INNER_SCREEN_RECT)
92         virtual FloatRect innerScreenRect() = 0;
93 #endif
94
95 #if ENABLE(TIZEN_MEDIA_QUERY) 
96         virtual int getDPI() = 0;
97         virtual double getDPCM() = 0;
98 #endif
99
100         virtual void focus() = 0;
101         virtual void unfocus() = 0;
102
103         virtual bool canTakeFocus(FocusDirection) = 0;
104         virtual void takeFocus(FocusDirection) = 0;
105
106         virtual void focusedNodeChanged(Node*) = 0;
107         virtual void focusedFrameChanged(Frame*) = 0;
108
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;
117
118         virtual bool canRunModal() = 0;
119         virtual void runModal() = 0;
120
121         virtual void setToolbarsVisible(bool) = 0;
122         virtual bool toolbarsVisible() = 0;
123         
124         virtual void setStatusbarVisible(bool) = 0;
125         virtual bool statusbarVisible() = 0;
126         
127         virtual void setScrollbarsVisible(bool) = 0;
128         virtual bool scrollbarsVisible() = 0;
129         
130         virtual void setMenubarVisible(bool) = 0;
131         virtual bool menubarVisible() = 0;
132
133         virtual void setResizable(bool) = 0;
134         
135         virtual void addMessageToConsole(MessageSource, MessageType, MessageLevel, const String& message, unsigned int lineNumber, const String& sourceID) = 0;
136
137         virtual bool canRunBeforeUnloadConfirmPanel() = 0;
138         virtual bool runBeforeUnloadConfirmPanel(const String& message, Frame* frame) = 0;
139
140         virtual void closeWindowSoon() = 0;
141         
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;
148
149         virtual void* webView() const = 0;
150
151 #if ENABLE(REGISTER_PROTOCOL_HANDLER)
152         virtual void registerProtocolHandler(const String& scheme, const String& baseURL, const String& url, const String& title) = 0;
153 #endif
154
155         virtual IntRect windowResizerRect() const = 0;
156
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;
164 #endif
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;
173 #endif
174         // End methods used by HostWindow.
175
176         virtual void dispatchViewportPropertiesDidChange(const ViewportArguments&) const { }
177
178 #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
179         virtual void setMobileWebAppCapableState(const String&) { }
180         virtual void setMobileWebAppStatusBarStyle(const String&) { }
181 #endif
182 #if ENABLE(TIZEN_SUPPORT_VIEWPORT)
183         virtual bool canContentsSizeChange(Frame*, const IntSize&) const = 0;
184 #endif
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.
188        
189         virtual bool shouldMissingPluginMessageBeButton() const { return false; }
190         virtual void missingPluginButtonClicked(Element*) const { }
191         virtual void mouseDidMoveOverElement(const HitTestResult&, unsigned modifierFlags) = 0;
192
193         virtual void setToolTip(const String&, TextDirection) = 0;
194
195         virtual void print(Frame*) = 0;
196         virtual bool shouldRubberBandInDirection(ScrollDirection) const = 0;
197
198 #if ENABLE(SQL_DATABASE)
199         virtual void exceededDatabaseQuota(Frame*, const String& databaseName) = 0;
200 #endif
201
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
206         // old caches.
207         virtual void reachedMaxAppCacheSize(int64_t spaceNeeded) = 0;
208
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
216         // the new cache.
217         virtual void reachedApplicationCacheOriginQuota(SecurityOrigin*, int64_t totalSpaceNeeded) = 0;
218
219 #if ENABLE(DASHBOARD_SUPPORT)
220         virtual void dashboardRegionsChanged();
221 #endif
222
223         virtual void populateVisitedLinks();
224
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);
228             
229         virtual bool shouldReplaceWithGeneratedFileForUpload(const String& path, String& generatedFilename);
230         virtual String generateReplacementFile(const String& path);
231
232         virtual bool paintCustomOverhangArea(GraphicsContext*, const IntRect&, const IntRect&, const IntRect&);
233
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;
240
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;
245 #endif
246
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;
250
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;
254 #endif
255
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;
259         
260         virtual void elementDidFocus(const Node*) { };
261         virtual void elementDidBlur(const Node*) { };
262
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; }
275
276 #if ENABLE(CANVAS_CAIRO_GLES_RENDERING)
277         virtual void* sharedCairoDevice() { return 0; }
278 #endif
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;
282 #endif
283
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
291         };
292         typedef unsigned CompositingTriggerFlags;
293
294         // Returns a bitfield indicating conditions that can trigger the compositor.
295         virtual CompositingTriggerFlags allowedCompositingTriggers() const { return static_cast<CompositingTriggerFlags>(AllTriggers); }
296 #endif
297
298         virtual bool supportsFullscreenForNode(const Node*) { return false; }
299         virtual void enterFullscreenForNode(Node*) { }
300         virtual void exitFullscreenForNode(Node*) { }
301         virtual bool requiresFullscreenForVideoPlayback() { return false; } 
302
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*) { }
309 #endif
310         
311 #if USE(TILED_BACKING_STORE)
312         virtual IntRect visibleRectForTiledBackingStore() const { return IntRect(); }
313 #endif
314
315 #if PLATFORM(MAC)
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 *) { }
321 #endif
322
323 #if PLATFORM(WIN)
324         virtual void setLastSetCursorToCurrentCursor() = 0;
325 #endif
326
327 #if ENABLE(TOUCH_EVENTS)
328         virtual void needTouchEvents(bool) = 0;
329 #endif
330
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;
335
336 #if ENABLE(CONTEXT_MENUS)
337         virtual void showContextMenu() = 0;
338 #endif
339
340         virtual void postAccessibilityNotification(AccessibilityObject*, AXObjectCache::AXNotification) { }
341
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;
347 #endif
348 #endif
349
350 #if PLATFORM(EFL) && ENABLE(TIZEN_SHOULD_ALLOW_OPEN_URL)
351         virtual bool shouldAllowOpenUrl(const char* url) { return true; };
352 #endif
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 { }
357         
358         virtual void notifyScrollerThumbIsVisibleInRect(const IntRect&) { }
359         virtual void recommendedScrollbarStyleDidChange(int /*newStyle*/) { }
360
361         enum DialogType {
362             AlertDialog = 0,
363             ConfirmDialog = 1,
364             PromptDialog = 2,
365             HTMLDialog = 3
366         };
367         virtual bool shouldRunModalDialogDuringPageDismissal(const DialogType&, const String& dialogMessage, FrameLoader::PageDismissalType) const { UNUSED_PARAM(dialogMessage); return true; }
368
369         virtual void numWheelEventHandlersChanged(unsigned) = 0;
370         
371         virtual bool isSVGImageChromeClient() const { return false; }
372
373     protected:
374         virtual ~ChromeClient() { }
375     };
376
377 }
378
379 #endif // ChromeClient_h