Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / core / 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 "core/accessibility/AXObjectCache.h"
26 #include "core/inspector/ConsoleAPITypes.h"
27 #include "core/loader/FrameLoader.h"
28 #include "core/loader/NavigationPolicy.h"
29 #include "core/frame/ConsoleTypes.h"
30 #include "core/page/FocusType.h"
31 #include "core/rendering/RenderEmbeddedObject.h"
32 #include "core/rendering/style/RenderStyleConstants.h"
33 #include "platform/Cursor.h"
34 #include "platform/HostWindow.h"
35 #include "platform/PopupMenu.h"
36 #include "platform/PopupMenuClient.h"
37 #include "platform/graphics/GraphicsContext.h"
38 #include "platform/scroll/ScrollTypes.h"
39 #include "wtf/Forward.h"
40 #include "wtf/PassOwnPtr.h"
41 #include "wtf/Vector.h"
42
43
44 #ifndef __OBJC__
45 class NSMenu;
46 class NSResponder;
47 #endif
48
49 namespace WebCore {
50
51 class AXObject;
52 class ColorChooser;
53 class ColorChooserClient;
54 class DateTimeChooser;
55 class DateTimeChooserClient;
56 class Element;
57 class FileChooser;
58 class FloatRect;
59 class Frame;
60 class GraphicsLayer;
61 class GraphicsLayerFactory;
62 class HitTestResult;
63 class HTMLFormControlElement;
64 class HTMLInputElement;
65 class IntRect;
66 class LocalFrame;
67 class Node;
68 class Page;
69 class PagePopup;
70 class PagePopupClient;
71 class PagePopupDriver;
72 class PopupMenuClient;
73 class SecurityOrigin;
74 class Widget;
75
76 struct DateTimeChooserParameters;
77 struct FrameLoadRequest;
78 struct GraphicsDeviceAdapter;
79 struct ViewportDescription;
80 struct WindowFeatures;
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     virtual void focus() = 0;
92
93     virtual bool canTakeFocus(FocusType) = 0;
94     virtual void takeFocus(FocusType) = 0;
95
96     virtual void focusedNodeChanged(Node*) = 0;
97
98     virtual void focusedFrameChanged(LocalFrame*) = 0;
99
100     // The LocalFrame pointer provides the ChromeClient with context about which
101     // LocalFrame wants to create the new Page. Also, the newly created window
102     // should not be shown to the user until the ChromeClient of the newly
103     // created Page has its show method called.
104     // The FrameLoadRequest parameter is only for ChromeClient to check if the
105     // request could be fulfilled. The ChromeClient should not load the request.
106     virtual Page* createWindow(LocalFrame*, const FrameLoadRequest&, const WindowFeatures&, NavigationPolicy, ShouldSendReferrer) = 0;
107     virtual void show(NavigationPolicy) = 0;
108
109     virtual bool canRunModal() = 0;
110     virtual void runModal() = 0;
111
112     virtual void setToolbarsVisible(bool) = 0;
113     virtual bool toolbarsVisible() = 0;
114
115     virtual void setStatusbarVisible(bool) = 0;
116     virtual bool statusbarVisible() = 0;
117
118     virtual void setScrollbarsVisible(bool) = 0;
119     virtual bool scrollbarsVisible() = 0;
120
121     virtual void setMenubarVisible(bool) = 0;
122     virtual bool menubarVisible() = 0;
123
124     virtual void setResizable(bool) = 0;
125
126     virtual bool shouldReportDetailedMessageForSource(const String& source) = 0;
127     virtual void addMessageToConsole(LocalFrame*, MessageSource, MessageLevel, const String& message, unsigned lineNumber, const String& sourceID, const String& stackTrace) = 0;
128
129     virtual bool canRunBeforeUnloadConfirmPanel() = 0;
130     virtual bool runBeforeUnloadConfirmPanel(const String& message, LocalFrame*) = 0;
131
132     virtual void closeWindowSoon() = 0;
133
134     virtual void runJavaScriptAlert(LocalFrame*, const String&) = 0;
135     virtual bool runJavaScriptConfirm(LocalFrame*, const String&) = 0;
136     virtual bool runJavaScriptPrompt(LocalFrame*, const String& message, const String& defaultValue, String& result) = 0;
137     virtual void setStatusbarText(const String&) = 0;
138     virtual bool tabsToLinks() = 0;
139
140     virtual void* webView() const = 0;
141
142     virtual IntRect windowResizerRect() const = 0;
143
144     // Methods used by HostWindow.
145     virtual void invalidateContentsAndRootView(const IntRect&) = 0;
146     virtual void invalidateContentsForSlowScroll(const IntRect&) = 0;
147     virtual void scroll(const IntSize&, const IntRect&, const IntRect&) = 0;
148     virtual IntRect rootViewToScreen(const IntRect&) const = 0;
149     virtual blink::WebScreenInfo screenInfo() const = 0;
150     virtual void setCursor(const Cursor&) = 0;
151     virtual void scheduleAnimation() = 0;
152     // End methods used by HostWindow.
153
154     virtual bool isCompositorFramePending() const = 0;
155
156     virtual void dispatchViewportPropertiesDidChange(const ViewportDescription&) const { }
157
158     virtual void contentsSizeChanged(LocalFrame*, const IntSize&) const = 0;
159     virtual void deviceOrPageScaleFactorChanged() const { }
160     virtual void layoutUpdated(LocalFrame*) const { }
161
162     virtual void mouseDidMoveOverElement(const HitTestResult&, unsigned modifierFlags) = 0;
163
164     virtual void setToolTip(const String&, TextDirection) = 0;
165
166     virtual void print(LocalFrame*) = 0;
167     virtual bool shouldRubberBandInDirection(ScrollDirection) const = 0;
168
169     virtual void annotatedRegionsChanged() = 0;
170
171     virtual bool paintCustomOverhangArea(GraphicsContext*, const IntRect&, const IntRect&, const IntRect&) = 0;
172
173     virtual PassOwnPtr<ColorChooser> createColorChooser(LocalFrame*, ColorChooserClient*, const Color&) = 0;
174
175     // This function is used for:
176     //  - Mandatory date/time choosers if !ENABLE(INPUT_MULTIPLE_FIELDS_UI)
177     //  - Date/time choosers for types for which RenderTheme::supportsCalendarPicker
178     //    returns true, if ENABLE(INPUT_MULTIPLE_FIELDS_UI)
179     //  - <datalist> UI for date/time input types regardless of
180     //    ENABLE(INPUT_MULTIPLE_FIELDS_UI)
181     virtual PassRefPtr<DateTimeChooser> openDateTimeChooser(DateTimeChooserClient*, const DateTimeChooserParameters&) = 0;
182
183     virtual void openTextDataListChooser(HTMLInputElement&) = 0;
184
185     virtual void runOpenPanel(LocalFrame*, PassRefPtr<FileChooser>) = 0;
186
187     // Asychronous request to enumerate all files in a directory chosen by the user.
188     virtual void enumerateChosenDirectory(FileChooser*) = 0;
189
190     // Allows ports to customize the type of graphics layers created by this page.
191     virtual GraphicsLayerFactory* graphicsLayerFactory() const { return 0; }
192
193     // Pass 0 as the GraphicsLayer to detatch the root layer.
194     virtual void attachRootGraphicsLayer(GraphicsLayer*) = 0;
195
196     virtual void enterFullScreenForElement(Element*) { }
197     virtual void exitFullScreenForElement(Element*) { }
198
199     virtual void needTouchEvents(bool) = 0;
200
201     virtual void setTouchAction(TouchAction) = 0;
202
203     // Checks if there is an opened popup, called by RenderMenuList::showPopup().
204     virtual bool hasOpenedPopup() const = 0;
205     virtual PassRefPtr<PopupMenu> createPopupMenu(LocalFrame&, PopupMenuClient*) const = 0;
206     // For testing.
207     virtual void setPagePopupDriver(PagePopupDriver*) = 0;
208     virtual void resetPagePopupDriver() = 0;
209
210     // FIXME: Should these be on a different client interface?
211     virtual bool isPasswordGenerationEnabled() const { return false; }
212     virtual void openPasswordGenerator(HTMLInputElement*) { }
213
214     virtual void postAccessibilityNotification(AXObject*, AXObjectCache::AXNotification) { }
215     virtual String acceptLanguages() = 0;
216
217     enum DialogType {
218         AlertDialog = 0,
219         ConfirmDialog = 1,
220         PromptDialog = 2,
221         HTMLDialog = 3
222     };
223     virtual bool shouldRunModalDialogDuringPageDismissal(const DialogType&, const String&, Document::PageDismissalType) const { return true; }
224
225     virtual void numWheelEventHandlersChanged(unsigned) = 0;
226
227     virtual bool isSVGImageChromeClient() const { return false; }
228
229     virtual bool requestPointerLock() { return false; }
230     virtual void requestPointerUnlock() { }
231
232     virtual FloatSize minimumWindowSize() const { return FloatSize(100, 100); };
233
234     virtual bool isChromeClientImpl() const { return false; }
235
236     virtual void didAssociateFormControls(const Vector<RefPtr<Element> >&) { };
237     virtual void didChangeValueInTextField(HTMLFormControlElement&) { }
238     virtual void didEndEditingOnTextField(HTMLInputElement&) { }
239     virtual void handleKeyboardEventOnTextField(HTMLInputElement&, KeyboardEvent&) { }
240
241     // FIXME: Remove this method once we have input routing in the browser
242     // process. See http://crbug.com/339659.
243     virtual void forwardInputEvent(WebCore::Frame*, WebCore::Event*) { }
244
245     // Input mehtod editor related functions.
246     virtual void didCancelCompositionOnSelectionChange() { }
247     virtual void willSetInputMethodState() { }
248     virtual void didUpdateTextOfFocusedElementByNonUserInput() { }
249
250 protected:
251     virtual ~ChromeClient() { }
252 };
253
254 }
255 #endif // ChromeClient_h