Merge "WebProcess crash is occured during changing default directory path for file...
[framework/web/webkit-efl.git] / Source / WebCore / page / ChromeClient.h
1 /*
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.
5  *
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.
10  *
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.
15  *
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.
20  */
21
22 #ifndef ChromeClient_h
23 #define ChromeClient_h
24
25 #include "AXObjectCache.h"
26 #include "ConsoleTypes.h"
27 #include "Cursor.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>
42
43 #ifndef __OBJC__
44 class NSMenu;
45 class NSResponder;
46 #endif
47
48 namespace WebCore {
49
50     class AccessibilityObject;
51     class Element;
52     class FileChooser;
53     class FileIconLoader;
54     class FloatRect;
55     class Frame;
56     class Geolocation;
57     class GraphicsLayer;
58     class HTMLInputElement;
59     class HitTestResult;
60     class IntRect;
61     class NavigationAction;
62     class Node;
63     class Page;
64     class PagePopup;
65     class PagePopupClient;
66     class PagePopupDriver;
67     class PopupMenuClient;
68     class SecurityOrigin;
69     class GraphicsContext3D;
70     class Widget;
71
72     struct FrameLoadRequest;
73     struct ViewportArguments;
74     struct WindowFeatures;
75
76 #if USE(ACCELERATED_COMPOSITING)
77     class GraphicsLayer;
78 #endif
79
80 #if ENABLE(INPUT_TYPE_COLOR)
81     class ColorChooser;
82     class ColorChooserClient;
83 #endif
84
85 #if PLATFORM(WIN) && USE(AVFOUNDATION)
86     struct GraphicsDeviceAdapter;
87 #endif
88
89     class ChromeClient {
90     public:
91         virtual void chromeDestroyed() = 0;
92         
93         virtual void setWindowRect(const FloatRect&) = 0;
94         virtual FloatRect windowRect() = 0;
95         
96         virtual FloatRect pageRect() = 0;
97
98         virtual void focus() = 0;
99         virtual void unfocus() = 0;
100
101         virtual bool canTakeFocus(FocusDirection) = 0;
102         virtual void takeFocus(FocusDirection) = 0;
103
104         virtual void focusedNodeChanged(Node*) = 0;
105         virtual void focusedFrameChanged(Frame*) = 0;
106
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;
115
116         virtual bool canRunModal() = 0;
117         virtual void runModal() = 0;
118
119         virtual void setToolbarsVisible(bool) = 0;
120         virtual bool toolbarsVisible() = 0;
121         
122         virtual void setStatusbarVisible(bool) = 0;
123         virtual bool statusbarVisible() = 0;
124         
125         virtual void setScrollbarsVisible(bool) = 0;
126         virtual bool scrollbarsVisible() = 0;
127         
128         virtual void setMenubarVisible(bool) = 0;
129         virtual bool menubarVisible() = 0;
130
131         virtual void setResizable(bool) = 0;
132         
133         virtual void addMessageToConsole(MessageSource, MessageType, MessageLevel, const String& message, unsigned int lineNumber, const String& sourceID) = 0;
134
135         virtual bool canRunBeforeUnloadConfirmPanel() = 0;
136         virtual bool runBeforeUnloadConfirmPanel(const String& message, Frame* frame) = 0;
137
138         virtual void closeWindowSoon() = 0;
139         
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;
146
147         virtual void* webView() const = 0;
148
149 #if ENABLE(CUSTOM_SCHEME_HANDLER) || !ENABLE(TIZEN_REGISTER_SCHEME_HANDLER)
150         enum CustomHandlersState {
151             CustomHandlersNew,
152             CustomHandlersRegistered,
153             CustomHandlersDeclined
154         };
155 #endif
156
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;
160 #endif
161
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;
165 #endif
166
167
168         virtual IntRect windowResizerRect() const = 0;
169
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;
177 #endif
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;
186 #endif
187         // End methods used by HostWindow.
188
189         virtual void dispatchViewportPropertiesDidChange(const ViewportArguments&) const { }
190
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.
194        
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;
198
199         virtual void setToolTip(const String&, TextDirection) = 0;
200
201         virtual void print(Frame*) = 0;
202         virtual bool shouldRubberBandInDirection(ScrollDirection) const = 0;
203
204 #if ENABLE(SQL_DATABASE)
205         virtual void exceededDatabaseQuota(Frame*, const String& databaseName) = 0;
206 #endif
207
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
212         // old caches.
213         virtual void reachedMaxAppCacheSize(int64_t spaceNeeded) = 0;
214
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
222         // the new cache.
223         virtual void reachedApplicationCacheOriginQuota(SecurityOrigin*, int64_t totalSpaceNeeded) = 0;
224
225 #if ENABLE(DASHBOARD_SUPPORT)
226         virtual void dashboardRegionsChanged();
227 #endif
228
229         virtual void populateVisitedLinks();
230
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);
234             
235         virtual bool shouldReplaceWithGeneratedFileForUpload(const String& path, String& generatedFilename);
236         virtual String generateReplacementFile(const String& path);
237
238         virtual bool paintCustomOverhangArea(GraphicsContext*, const IntRect&, const IntRect&, const IntRect&);
239
240 #if ENABLE(INPUT_TYPE_COLOR)
241         virtual PassOwnPtr<ColorChooser> createColorChooser(ColorChooserClient*, const Color&) = 0;
242 #endif
243
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;
247
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;
251 #endif
252
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;
256         
257         virtual void elementDidFocus(const Node*) { };
258         virtual void elementDidBlur(const Node*) { };
259
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; }
272
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;
276 #endif
277
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
286         };
287         typedef unsigned CompositingTriggerFlags;
288
289         // Returns a bitfield indicating conditions that can trigger the compositor.
290         virtual CompositingTriggerFlags allowedCompositingTriggers() const { return static_cast<CompositingTriggerFlags>(AllTriggers); }
291 #endif
292
293 #if PLATFORM(WIN) && USE(AVFOUNDATION)
294         virtual GraphicsDeviceAdapter* graphicsDeviceAdapter() const { return 0; }
295 #endif
296
297         virtual bool supportsFullscreenForNode(const Node*) { return false; }
298         virtual void enterFullscreenForNode(Node*) { }
299         virtual void exitFullscreenForNode(Node*) { }
300         virtual bool requiresFullscreenForVideoPlayback() { return false; } 
301
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*) { }
308 #endif
309         
310 #if USE(TILED_BACKING_STORE)
311         virtual IntRect visibleRectForTiledBackingStore() const { return IntRect(); }
312 #endif
313
314 #if PLATFORM(MAC)
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 *) { }
320 #endif
321
322 #if PLATFORM(WIN)
323         virtual void setLastSetCursorToCurrentCursor() = 0;
324 #endif
325
326 #if ENABLE(TOUCH_EVENTS)
327         virtual void needTouchEvents(bool) = 0;
328 #endif
329
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;
341         // For testing.
342         virtual void setPagePopupDriver(PagePopupDriver*) = 0;
343         virtual void resetPagePopupDriver() = 0;
344 #endif
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*) { }
352
353         virtual void postAccessibilityNotification(AccessibilityObject*, AXObjectCache::AXNotification) { }
354
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 { }
359         
360         virtual void notifyScrollerThumbIsVisibleInRect(const IntRect&) { }
361         virtual void recommendedScrollbarStyleDidChange(int /*newStyle*/) { }
362
363         enum DialogType {
364             AlertDialog = 0,
365             ConfirmDialog = 1,
366             PromptDialog = 2,
367             HTMLDialog = 3
368         };
369         virtual bool shouldRunModalDialogDuringPageDismissal(const DialogType&, const String& dialogMessage, FrameLoader::PageDismissalType) const { UNUSED_PARAM(dialogMessage); return true; }
370
371         virtual void numWheelEventHandlersChanged(unsigned) = 0;
372         
373         virtual bool isSVGImageChromeClient() const { return false; }
374
375 #if ENABLE(POINTER_LOCK)
376         virtual bool requestPointerLock() { return false; }
377         virtual void requestPointerUnlock() { }
378         virtual bool isPointerLocked() { return false; }
379 #endif
380
381 #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
382         virtual bool getStandaloneStatus() { return true; }
383 #endif
384
385 #if ENABLE(SCREEN_ORIENTATION_SUPPORT)
386         virtual bool lockOrientation(int willLockOrientation) { return false; }
387         virtual void unlockOrientation() { }
388 #endif
389
390         virtual void logDiagnosticMessage(const String& message, const String& description, const String& status) { UNUSED_PARAM(message); UNUSED_PARAM(description); UNUSED_PARAM(status); }
391
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;
395 #endif
396
397 #if ENABLE(TIZEN_SCREEN_READER)
398         virtual void rendererWillBeDestroyed(RenderObject*) { }
399 #endif
400
401     protected:
402         virtual ~ChromeClient() { }
403     };
404
405 }
406 #endif // ChromeClient_h