Add keypad layout that has number variation
[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(TIZEN_APPLICATION_CACHE)
226         virtual bool requestApplicationCachePermission(Frame*) = 0;
227 #endif
228
229 #if ENABLE(DASHBOARD_SUPPORT)
230         virtual void dashboardRegionsChanged();
231 #endif
232
233         virtual void populateVisitedLinks();
234
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);
238             
239         virtual bool shouldReplaceWithGeneratedFileForUpload(const String& path, String& generatedFilename);
240         virtual String generateReplacementFile(const String& path);
241
242         virtual bool paintCustomOverhangArea(GraphicsContext*, const IntRect&, const IntRect&, const IntRect&);
243
244 #if ENABLE(INPUT_TYPE_COLOR)
245         virtual PassOwnPtr<ColorChooser> createColorChooser(ColorChooserClient*, const Color&) = 0;
246 #endif
247
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;
251
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;
255 #endif
256
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;
260         
261         virtual void elementDidFocus(const Node*) { };
262         virtual void elementDidBlur(const Node*) { };
263
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; }
276
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;
280 #endif
281
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
290         };
291         typedef unsigned CompositingTriggerFlags;
292
293         // Returns a bitfield indicating conditions that can trigger the compositor.
294         virtual CompositingTriggerFlags allowedCompositingTriggers() const { return static_cast<CompositingTriggerFlags>(AllTriggers); }
295 #endif
296
297 #if PLATFORM(WIN) && USE(AVFOUNDATION)
298         virtual GraphicsDeviceAdapter* graphicsDeviceAdapter() const { return 0; }
299 #endif
300
301         virtual bool supportsFullscreenForNode(const Node*) { return false; }
302         virtual void enterFullscreenForNode(Node*) { }
303         virtual void exitFullscreenForNode(Node*) { }
304         virtual bool requiresFullscreenForVideoPlayback() { return false; } 
305
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*) { }
312 #endif
313         
314 #if USE(TILED_BACKING_STORE)
315         virtual IntRect visibleRectForTiledBackingStore() const { return IntRect(); }
316 #endif
317
318 #if PLATFORM(MAC)
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 *) { }
324 #endif
325
326 #if PLATFORM(WIN)
327         virtual void setLastSetCursorToCurrentCursor() = 0;
328 #endif
329
330 #if ENABLE(TOUCH_EVENTS)
331         virtual void needTouchEvents(bool) = 0;
332 #endif
333
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;
345         // For testing.
346         virtual void setPagePopupDriver(PagePopupDriver*) = 0;
347         virtual void resetPagePopupDriver() = 0;
348 #endif
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*) { }
356
357         virtual void postAccessibilityNotification(AccessibilityObject*, AXObjectCache::AXNotification) { }
358
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 { }
363         
364         virtual void notifyScrollerThumbIsVisibleInRect(const IntRect&) { }
365         virtual void recommendedScrollbarStyleDidChange(int /*newStyle*/) { }
366
367         enum DialogType {
368             AlertDialog = 0,
369             ConfirmDialog = 1,
370             PromptDialog = 2,
371             HTMLDialog = 3
372         };
373         virtual bool shouldRunModalDialogDuringPageDismissal(const DialogType&, const String& dialogMessage, FrameLoader::PageDismissalType) const { UNUSED_PARAM(dialogMessage); return true; }
374
375         virtual void numWheelEventHandlersChanged(unsigned) = 0;
376         
377         virtual bool isSVGImageChromeClient() const { return false; }
378
379 #if ENABLE(POINTER_LOCK)
380         virtual bool requestPointerLock() { return false; }
381         virtual void requestPointerUnlock() { }
382         virtual bool isPointerLocked() { return false; }
383 #endif
384
385 #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
386         virtual bool getStandaloneStatus() { return true; }
387 #endif
388
389 #if ENABLE(SCREEN_ORIENTATION_SUPPORT)
390         virtual bool lockOrientation(int willLockOrientation) { return false; }
391         virtual void unlockOrientation() { }
392 #endif
393
394         virtual void logDiagnosticMessage(const String& message, const String& description, const String& status) { UNUSED_PARAM(message); UNUSED_PARAM(description); UNUSED_PARAM(status); }
395
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;
399 #endif
400
401 #if OS(TIZEN)
402         virtual void rendererWillBeDestroyed(RenderObject*) { }
403 #endif
404
405 #if ENABLE(TIZEN_INDEXED_DATABASE)
406         virtual bool exceededIndexedDatabaseQuota(Frame*, int64_t) = 0;
407 #endif
408
409 #if ENABLE(TIZEN_FILE_SYSTEM)
410         virtual bool exceededLocalFileSystemQuota(Frame*, int64_t currentUsage) = 0;
411 #endif
412
413     protected:
414         virtual ~ChromeClient() { }
415     };
416
417 }
418 #endif // ChromeClient_h