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