- add third_party src.
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / web / ChromeClientImpl.h
1 /*
2  * Copyright (C) 2009 Google Inc. All rights reserved.
3  * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are
7  * met:
8  *
9  *     * Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  *     * Redistributions in binary form must reproduce the above
12  * copyright notice, this list of conditions and the following disclaimer
13  * in the documentation and/or other materials provided with the
14  * distribution.
15  *     * Neither the name of Google Inc. nor the names of its
16  * contributors may be used to endorse or promote products derived from
17  * this software without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30  */
31
32 #ifndef ChromeClientImpl_h
33 #define ChromeClientImpl_h
34
35 #include "WebNavigationPolicy.h"
36 #include "core/page/ChromeClient.h"
37 #include "core/platform/PopupMenu.h"
38 #include "modules/navigatorcontentutils/NavigatorContentUtilsClient.h"
39 #include "public/platform/WebColor.h"
40 #include "wtf/PassOwnPtr.h"
41
42 namespace WebCore {
43 class AXObject;
44 class ColorChooser;
45 class ColorChooserClient;
46 class Element;
47 class FileChooser;
48 class GraphicsLayerFactory;
49 class PopupContainer;
50 class PopupMenuClient;
51 class RenderBox;
52 class SecurityOrigin;
53 class DateTimeChooser;
54 class DateTimeChooserClient;
55 struct WindowFeatures;
56 }
57
58 namespace WebKit {
59 class WebColorChooser;
60 class WebColorChooserClient;
61 class WebViewImpl;
62 struct WebCursorInfo;
63 struct WebPopupMenuInfo;
64
65 // Handles window-level notifications from WebCore on behalf of a WebView.
66 class ChromeClientImpl : public WebCore::ChromeClient {
67 public:
68     explicit ChromeClientImpl(WebViewImpl* webView);
69     virtual ~ChromeClientImpl();
70
71     virtual void* webView() const;
72
73     // ChromeClient methods:
74     virtual void chromeDestroyed();
75     virtual void setWindowRect(const WebCore::FloatRect&);
76     virtual WebCore::FloatRect windowRect();
77     virtual WebCore::FloatRect pageRect();
78     virtual void focus();
79     virtual void unfocus();
80     virtual bool canTakeFocus(WebCore::FocusDirection);
81     virtual void takeFocus(WebCore::FocusDirection);
82     virtual void focusedNodeChanged(WebCore::Node*);
83     virtual WebCore::Page* createWindow(
84         WebCore::Frame*, const WebCore::FrameLoadRequest&, const WebCore::WindowFeatures&, WebCore::NavigationPolicy);
85     virtual void show(WebCore::NavigationPolicy);
86     virtual bool canRunModal();
87     virtual void runModal();
88     virtual void setToolbarsVisible(bool);
89     virtual bool toolbarsVisible();
90     virtual void setStatusbarVisible(bool);
91     virtual bool statusbarVisible();
92     virtual void setScrollbarsVisible(bool);
93     virtual bool scrollbarsVisible();
94     virtual void setMenubarVisible(bool);
95     virtual bool menubarVisible();
96     virtual void setResizable(bool);
97     virtual bool shouldReportDetailedMessageForSource(const WTF::String&);
98     virtual void addMessageToConsole(
99         WebCore::MessageSource, WebCore::MessageLevel,
100         const WTF::String& message, unsigned lineNumber,
101         const WTF::String& sourceID, const WTF::String& stackTrace);
102     virtual bool canRunBeforeUnloadConfirmPanel();
103     virtual bool runBeforeUnloadConfirmPanel(
104         const WTF::String& message, WebCore::Frame*);
105     virtual void closeWindowSoon();
106     virtual void runJavaScriptAlert(WebCore::Frame*, const WTF::String&);
107     virtual bool runJavaScriptConfirm(WebCore::Frame*, const WTF::String&);
108     virtual bool runJavaScriptPrompt(
109         WebCore::Frame*, const WTF::String& message,
110         const WTF::String& defaultValue, WTF::String& result);
111     virtual void setStatusbarText(const WTF::String& message);
112     virtual bool tabsToLinks();
113     virtual WebCore::IntRect windowResizerRect() const;
114     virtual void invalidateContentsAndRootView(const WebCore::IntRect&);
115     virtual void invalidateContentsForSlowScroll(const WebCore::IntRect&);
116     virtual void scheduleAnimation();
117     virtual void scroll(
118         const WebCore::IntSize& scrollDelta, const WebCore::IntRect& rectToScroll,
119         const WebCore::IntRect& clipRect);
120     virtual WebCore::IntPoint screenToRootView(const WebCore::IntPoint&) const;
121     virtual WebCore::IntRect rootViewToScreen(const WebCore::IntRect&) const;
122     virtual WebScreenInfo screenInfo() const;
123     virtual void contentsSizeChanged(WebCore::Frame*, const WebCore::IntSize&) const;
124     virtual void deviceOrPageScaleFactorChanged() const;
125     virtual void layoutUpdated(WebCore::Frame*) const;
126     virtual void mouseDidMoveOverElement(
127         const WebCore::HitTestResult& result, unsigned modifierFlags);
128     virtual void setToolTip(const WTF::String& tooltipText, WebCore::TextDirection);
129     virtual void dispatchViewportPropertiesDidChange(const WebCore::ViewportDescription&) const;
130     virtual void print(WebCore::Frame*);
131     virtual void annotatedRegionsChanged();
132     virtual bool paintCustomOverhangArea(WebCore::GraphicsContext*, const WebCore::IntRect&, const WebCore::IntRect&, const WebCore::IntRect&);
133     virtual PassOwnPtr<WebCore::ColorChooser> createColorChooser(WebCore::ColorChooserClient*, const WebCore::Color&) OVERRIDE;
134     PassOwnPtr<WebColorChooser> createWebColorChooser(WebColorChooserClient*, const WebColor&);
135     virtual PassRefPtr<WebCore::DateTimeChooser> openDateTimeChooser(WebCore::DateTimeChooserClient*, const WebCore::DateTimeChooserParameters&) OVERRIDE;
136     virtual void runOpenPanel(WebCore::Frame*, PassRefPtr<WebCore::FileChooser>);
137     virtual void enumerateChosenDirectory(WebCore::FileChooser*);
138     virtual void setCursor(const WebCore::Cursor&);
139     virtual void formStateDidChange(const WebCore::Node*);
140     virtual void needTouchEvents(bool needTouchEvents) OVERRIDE;
141
142     virtual WebCore::GraphicsLayerFactory* graphicsLayerFactory() const OVERRIDE;
143
144     // Pass 0 as the GraphicsLayer to detatch the root layer.
145     virtual void attachRootGraphicsLayer(WebCore::Frame*, WebCore::GraphicsLayer*);
146
147     // Sets a flag to specify that the view needs to be updated, so we need
148     // to do an eager layout before the drawing.
149     virtual void scheduleCompositingLayerFlush();
150
151     virtual CompositingTriggerFlags allowedCompositingTriggers() const;
152
153     virtual void enterFullScreenForElement(WebCore::Element*);
154     virtual void exitFullScreenForElement(WebCore::Element*);
155
156     // ChromeClient methods:
157     virtual void popupOpened(WebCore::PopupContainer* popupContainer,
158                              const WebCore::IntRect& bounds,
159                              bool handleExternally);
160     virtual void popupClosed(WebCore::PopupContainer* popupContainer);
161     virtual void postAccessibilityNotification(WebCore::AXObject*, WebCore::AXObjectCache::AXNotification);
162     virtual String acceptLanguages() OVERRIDE;
163
164     // ChromeClientImpl:
165     void setCursorForPlugin(const WebCursorInfo&);
166     void setNewWindowNavigationPolicy(WebNavigationPolicy);
167
168     virtual bool hasOpenedPopup() const OVERRIDE;
169     virtual PassRefPtr<WebCore::PopupMenu> createPopupMenu(WebCore::Frame&, WebCore::PopupMenuClient*) const;
170     virtual WebCore::PagePopup* openPagePopup(WebCore::PagePopupClient*, const WebCore::IntRect&) OVERRIDE;
171     virtual void closePagePopup(WebCore::PagePopup*) OVERRIDE;
172     virtual void setPagePopupDriver(WebCore::PagePopupDriver*) OVERRIDE;
173     virtual void resetPagePopupDriver() OVERRIDE;
174
175     virtual bool isPasswordGenerationEnabled() const OVERRIDE;
176     virtual void openPasswordGenerator(WebCore::HTMLInputElement*) OVERRIDE;
177
178     virtual bool shouldRunModalDialogDuringPageDismissal(const DialogType&, const String& dialogMessage, WebCore::Document::PageDismissalType) const;
179
180     virtual bool shouldRubberBandInDirection(WebCore::ScrollDirection) const;
181     virtual void numWheelEventHandlersChanged(unsigned);
182
183     virtual bool requestPointerLock();
184     virtual void requestPointerUnlock();
185     virtual bool isPointerLocked();
186
187     virtual void didAssociateFormControls(const Vector<RefPtr<WebCore::Element> >&) OVERRIDE;
188
189 private:
190     virtual bool isChromeClientImpl() const OVERRIDE { return true; }
191
192     WebNavigationPolicy getNavigationPolicy();
193     void getPopupMenuInfo(WebCore::PopupContainer*, WebPopupMenuInfo*);
194     void setCursor(const WebCursorInfo&);
195
196     WebViewImpl* m_webView;  // weak pointer
197     bool m_toolbarsVisible;
198     bool m_statusbarVisible;
199     bool m_scrollbarsVisible;
200     bool m_menubarVisible;
201     bool m_resizable;
202
203     WebCore::PagePopupDriver* m_pagePopupDriver;
204 };
205
206 #if ENABLE(NAVIGATOR_CONTENT_UTILS)
207 class NavigatorContentUtilsClientImpl : public WebCore::NavigatorContentUtilsClient {
208 public:
209     static PassOwnPtr<NavigatorContentUtilsClientImpl> create(WebViewImpl*);
210     ~NavigatorContentUtilsClientImpl() { }
211
212     virtual void registerProtocolHandler(const String& scheme, const String& baseURL, const String& url, const String& title) OVERRIDE;
213
214 private:
215     explicit NavigatorContentUtilsClientImpl(WebViewImpl*);
216
217     WebViewImpl* m_webView;
218 };
219 #endif
220
221 inline ChromeClientImpl* toChromeClientImpl(WebCore::ChromeClient& client)
222 {
223     ASSERT_WITH_SECURITY_IMPLICATION(client.isChromeClientImpl());
224     return static_cast<ChromeClientImpl*>(&client);
225 }
226
227 } // namespace WebKit
228
229 #endif