• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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/heap/Handle.h"
37 #include "platform/scroll/ScrollTypes.h"
38 #include "wtf/Forward.h"
39 #include "wtf/PassOwnPtr.h"
40 #include "wtf/Vector.h"
41 
42 namespace blink {
43 
44 class AXObject;
45 class ColorChooser;
46 class ColorChooserClient;
47 class DateTimeChooser;
48 class DateTimeChooserClient;
49 class Element;
50 class FileChooser;
51 class FloatRect;
52 class Frame;
53 class GraphicsContext;
54 class GraphicsLayer;
55 class GraphicsLayerFactory;
56 class HitTestResult;
57 class HTMLFormControlElement;
58 class HTMLInputElement;
59 class IntRect;
60 class LocalFrame;
61 class Node;
62 class Page;
63 class PagePopup;
64 class PagePopupClient;
65 class PagePopupDriver;
66 class PopupMenuClient;
67 
68 struct CompositedSelectionBound;
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 IntRect rootViewToScreen(const IntRect&) const = 0;
141     virtual blink::WebScreenInfo screenInfo() const = 0;
142     virtual void setCursor(const Cursor&) = 0;
143     virtual void scheduleAnimation() = 0;
144     // End methods used by HostWindow.
145 
dispatchViewportPropertiesDidChange(const ViewportDescription &)146     virtual void dispatchViewportPropertiesDidChange(const ViewportDescription&) const { }
147 
148     virtual void contentsSizeChanged(LocalFrame*, const IntSize&) const = 0;
deviceOrPageScaleFactorChanged()149     virtual void deviceOrPageScaleFactorChanged() const { }
layoutUpdated(LocalFrame *)150     virtual void layoutUpdated(LocalFrame*) const { }
151 
152     virtual void mouseDidMoveOverElement(const HitTestResult&, unsigned modifierFlags) = 0;
153 
154     virtual void setToolTip(const String&, TextDirection) = 0;
155 
156     virtual void print(LocalFrame*) = 0;
157 
158     virtual void annotatedRegionsChanged() = 0;
159 
160     virtual bool paintCustomOverhangArea(GraphicsContext*, const IntRect&, const IntRect&, const IntRect&) = 0;
161 
162     virtual PassOwnPtr<ColorChooser> createColorChooser(LocalFrame*, ColorChooserClient*, const Color&) = 0;
163 
164     // This function is used for:
165     //  - Mandatory date/time choosers if !ENABLE(INPUT_MULTIPLE_FIELDS_UI)
166     //  - Date/time choosers for types for which RenderTheme::supportsCalendarPicker
167     //    returns true, if ENABLE(INPUT_MULTIPLE_FIELDS_UI)
168     //  - <datalist> UI for date/time input types regardless of
169     //    ENABLE(INPUT_MULTIPLE_FIELDS_UI)
170     virtual PassRefPtr<DateTimeChooser> openDateTimeChooser(DateTimeChooserClient*, const DateTimeChooserParameters&) = 0;
171 
172     virtual void openTextDataListChooser(HTMLInputElement&) = 0;
173 
174     virtual void runOpenPanel(LocalFrame*, PassRefPtr<FileChooser>) = 0;
175 
176     // Asychronous request to enumerate all files in a directory chosen by the user.
177     virtual void enumerateChosenDirectory(FileChooser*) = 0;
178 
179     // Allows ports to customize the type of graphics layers created by this page.
graphicsLayerFactory()180     virtual GraphicsLayerFactory* graphicsLayerFactory() const { return 0; }
181 
182     // Pass 0 as the GraphicsLayer to detatch the root layer.
183     virtual void attachRootGraphicsLayer(GraphicsLayer*) = 0;
184 
enterFullScreenForElement(Element *)185     virtual void enterFullScreenForElement(Element*) { }
exitFullScreenForElement(Element *)186     virtual void exitFullScreenForElement(Element*) { }
187 
clearCompositedSelectionBounds()188     virtual void clearCompositedSelectionBounds() { }
updateCompositedSelectionBounds(const CompositedSelectionBound & anchor,const CompositedSelectionBound & focus)189     virtual void updateCompositedSelectionBounds(const CompositedSelectionBound& anchor, const CompositedSelectionBound& focus) { }
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 PassRefPtrWillBeRawPtr<PopupMenu> createPopupMenu(LocalFrame&, PopupMenuClient*) const = 0;
198     // For testing.
199     virtual void setPagePopupDriver(PagePopupDriver*) = 0;
200     virtual void resetPagePopupDriver() = 0;
201 
postAccessibilityNotification(AXObject *,AXObjectCache::AXNotification)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     };
shouldRunModalDialogDuringPageDismissal(const DialogType &,const String &,Document::PageDismissalType)211     virtual bool shouldRunModalDialogDuringPageDismissal(const DialogType&, const String&, Document::PageDismissalType) const { return true; }
212 
isSVGImageChromeClient()213     virtual bool isSVGImageChromeClient() const { return false; }
214 
requestPointerLock()215     virtual bool requestPointerLock() { return false; }
requestPointerUnlock()216     virtual void requestPointerUnlock() { }
217 
minimumWindowSize()218     virtual FloatSize minimumWindowSize() const { return FloatSize(100, 100); };
219 
isChromeClientImpl()220     virtual bool isChromeClientImpl() const { return false; }
221 
didAssociateFormControls(const WillBeHeapVector<RefPtrWillBeMember<Element>> &)222     virtual void didAssociateFormControls(const WillBeHeapVector<RefPtrWillBeMember<Element> >&) { };
didChangeValueInTextField(HTMLFormControlElement &)223     virtual void didChangeValueInTextField(HTMLFormControlElement&) { }
didEndEditingOnTextField(HTMLInputElement &)224     virtual void didEndEditingOnTextField(HTMLInputElement&) { }
handleKeyboardEventOnTextField(HTMLInputElement &,KeyboardEvent &)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.
forwardInputEvent(blink::Frame *,blink::Event *)229     virtual void forwardInputEvent(blink::Frame*, blink::Event*) { }
230 
231     // Input mehtod editor related functions.
didCancelCompositionOnSelectionChange()232     virtual void didCancelCompositionOnSelectionChange() { }
willSetInputMethodState()233     virtual void willSetInputMethodState() { }
didUpdateTextOfFocusedElementByNonUserInput()234     virtual void didUpdateTextOfFocusedElementByNonUserInput() { }
showImeIfNeeded()235     virtual void showImeIfNeeded() { }
236 
237 protected:
~ChromeClient()238     virtual ~ChromeClient() { }
239 };
240 
241 }
242 #endif // ChromeClient_h
243