Upstream version 6.35.121.0
[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 "modules/navigatorcontentutils/NavigatorContentUtilsClient.h"
38 #include "platform/PopupMenu.h"
39 #include "platform/weborigin/KURL.h"
40 #include "public/platform/WebColor.h"
41 #include "wtf/PassOwnPtr.h"
42
43 namespace WebCore {
44 class AXObject;
45 class ColorChooser;
46 class ColorChooserClient;
47 class Element;
48 class Event;
49 class FileChooser;
50 class GraphicsLayerFactory;
51 class HTMLFormControlElement;
52 class HTMLInputElement;
53 class KeyboardEvent;
54 class PopupMenuClient;
55 class RenderBox;
56 class SecurityOrigin;
57 class DateTimeChooser;
58 class DateTimeChooserClient;
59 struct WindowFeatures;
60 }
61
62 namespace blink {
63 class WebColorChooser;
64 class WebColorChooserClient;
65 class WebViewImpl;
66 struct WebCursorInfo;
67 struct WebPopupMenuInfo;
68
69 // Handles window-level notifications from WebCore on behalf of a WebView.
70 class ChromeClientImpl FINAL : public WebCore::ChromeClient {
71 public:
72     explicit ChromeClientImpl(WebViewImpl* webView);
73     virtual ~ChromeClientImpl();
74
75     virtual void* webView() const OVERRIDE;
76
77     // ChromeClient methods:
78     virtual void chromeDestroyed() OVERRIDE;
79     virtual void setWindowRect(const WebCore::FloatRect&) OVERRIDE;
80     virtual WebCore::FloatRect windowRect() OVERRIDE;
81     virtual WebCore::FloatRect pageRect() OVERRIDE;
82     virtual void focus() OVERRIDE;
83     virtual bool canTakeFocus(WebCore::FocusType) OVERRIDE;
84     virtual void takeFocus(WebCore::FocusType) OVERRIDE;
85     virtual void focusedNodeChanged(WebCore::Node*) OVERRIDE;
86     virtual void focusedFrameChanged(WebCore::LocalFrame*) OVERRIDE;
87     virtual WebCore::Page* createWindow(
88         WebCore::LocalFrame*, const WebCore::FrameLoadRequest&, const WebCore::WindowFeatures&, WebCore::NavigationPolicy, WebCore::ShouldSendReferrer) OVERRIDE;
89     virtual void show(WebCore::NavigationPolicy) OVERRIDE;
90     virtual bool canRunModal() OVERRIDE;
91     virtual void runModal() OVERRIDE;
92     virtual void setToolbarsVisible(bool) OVERRIDE;
93     virtual bool toolbarsVisible() OVERRIDE;
94     virtual void setStatusbarVisible(bool) OVERRIDE;
95     virtual bool statusbarVisible() OVERRIDE;
96     virtual void setScrollbarsVisible(bool) OVERRIDE;
97     virtual bool scrollbarsVisible() OVERRIDE;
98     virtual void setMenubarVisible(bool) OVERRIDE;
99     virtual bool menubarVisible() OVERRIDE;
100     virtual void setResizable(bool) OVERRIDE;
101     virtual bool shouldReportDetailedMessageForSource(const WTF::String&) OVERRIDE;
102     virtual void addMessageToConsole(
103         WebCore::MessageSource, WebCore::MessageLevel,
104         const WTF::String& message, unsigned lineNumber,
105         const WTF::String& sourceID, const WTF::String& stackTrace) OVERRIDE;
106     virtual bool canRunBeforeUnloadConfirmPanel() OVERRIDE;
107     virtual bool runBeforeUnloadConfirmPanel(
108         const WTF::String& message, WebCore::LocalFrame*) OVERRIDE;
109     virtual void closeWindowSoon() OVERRIDE;
110     virtual void runJavaScriptAlert(WebCore::LocalFrame*, const WTF::String&) OVERRIDE;
111     virtual bool runJavaScriptConfirm(WebCore::LocalFrame*, const WTF::String&) OVERRIDE;
112     virtual bool runJavaScriptPrompt(
113         WebCore::LocalFrame*, const WTF::String& message,
114         const WTF::String& defaultValue, WTF::String& result) OVERRIDE;
115     virtual void setStatusbarText(const WTF::String& message) OVERRIDE;
116     virtual bool tabsToLinks() OVERRIDE;
117     virtual WebCore::IntRect windowResizerRect() const OVERRIDE;
118     virtual void invalidateContentsAndRootView(const WebCore::IntRect&) OVERRIDE;
119     virtual void invalidateContentsForSlowScroll(const WebCore::IntRect&) OVERRIDE;
120     virtual void scheduleAnimation() OVERRIDE;
121     virtual bool isCompositorFramePending() const OVERRIDE;
122     virtual void scroll(
123         const WebCore::IntSize& scrollDelta, const WebCore::IntRect& rectToScroll,
124         const WebCore::IntRect& clipRect) OVERRIDE;
125     virtual WebCore::IntRect rootViewToScreen(const WebCore::IntRect&) const OVERRIDE;
126     virtual WebScreenInfo screenInfo() const OVERRIDE;
127     virtual void contentsSizeChanged(WebCore::LocalFrame*, const WebCore::IntSize&) const OVERRIDE;
128     virtual void deviceOrPageScaleFactorChanged() const OVERRIDE;
129     virtual void layoutUpdated(WebCore::LocalFrame*) const OVERRIDE;
130     virtual void mouseDidMoveOverElement(
131         const WebCore::HitTestResult&, unsigned modifierFlags) OVERRIDE;
132     virtual void setToolTip(const WTF::String& tooltipText, WebCore::TextDirection) OVERRIDE;
133     virtual void dispatchViewportPropertiesDidChange(const WebCore::ViewportDescription&) const OVERRIDE;
134     virtual void print(WebCore::LocalFrame*) OVERRIDE;
135     virtual void annotatedRegionsChanged() OVERRIDE;
136     virtual bool paintCustomOverhangArea(WebCore::GraphicsContext*, const WebCore::IntRect&, const WebCore::IntRect&, const WebCore::IntRect&) OVERRIDE;
137     virtual PassOwnPtr<WebCore::ColorChooser> createColorChooser(WebCore::ColorChooserClient*, const WebCore::Color&) OVERRIDE;
138     virtual PassRefPtr<WebCore::DateTimeChooser> openDateTimeChooser(WebCore::DateTimeChooserClient*, const WebCore::DateTimeChooserParameters&) OVERRIDE;
139     virtual void openTextDataListChooser(WebCore::HTMLInputElement&) OVERRIDE;
140     virtual void runOpenPanel(WebCore::LocalFrame*, PassRefPtr<WebCore::FileChooser>) OVERRIDE;
141     virtual void enumerateChosenDirectory(WebCore::FileChooser*) OVERRIDE;
142     virtual void setCursor(const WebCore::Cursor&) OVERRIDE;
143     virtual void needTouchEvents(bool needTouchEvents) OVERRIDE;
144     virtual void setTouchAction(WebCore::TouchAction) OVERRIDE;
145
146     virtual WebCore::GraphicsLayerFactory* graphicsLayerFactory() const OVERRIDE;
147
148     // Pass 0 as the GraphicsLayer to detatch the root layer.
149     virtual void attachRootGraphicsLayer(WebCore::GraphicsLayer*) OVERRIDE;
150
151     virtual WebCore::CompositingTriggerFlags allowedCompositingTriggers() const OVERRIDE;
152
153     virtual void enterFullScreenForElement(WebCore::Element*) OVERRIDE;
154     virtual void exitFullScreenForElement(WebCore::Element*) OVERRIDE;
155
156     // ChromeClient methods:
157     virtual void postAccessibilityNotification(WebCore::AXObject*, WebCore::AXObjectCache::AXNotification) OVERRIDE;
158     virtual String acceptLanguages() OVERRIDE;
159
160     // ChromeClientImpl:
161     void setCursorForPlugin(const WebCursorInfo&);
162     void setNewWindowNavigationPolicy(WebNavigationPolicy);
163
164     virtual bool hasOpenedPopup() const OVERRIDE;
165     virtual PassRefPtr<WebCore::PopupMenu> createPopupMenu(WebCore::LocalFrame&, WebCore::PopupMenuClient*) const OVERRIDE;
166     WebCore::PagePopup* openPagePopup(WebCore::PagePopupClient*, const WebCore::IntRect&);
167     void closePagePopup(WebCore::PagePopup*);
168     virtual void setPagePopupDriver(WebCore::PagePopupDriver*) OVERRIDE;
169     virtual void resetPagePopupDriver() OVERRIDE;
170
171     virtual bool isPasswordGenerationEnabled() const OVERRIDE;
172     virtual void openPasswordGenerator(WebCore::HTMLInputElement*) OVERRIDE;
173
174     virtual bool shouldRunModalDialogDuringPageDismissal(const DialogType&, const String& dialogMessage, WebCore::Document::PageDismissalType) const OVERRIDE;
175
176     virtual bool shouldRubberBandInDirection(WebCore::ScrollDirection) const OVERRIDE;
177     virtual void numWheelEventHandlersChanged(unsigned) OVERRIDE;
178
179     virtual bool requestPointerLock() OVERRIDE;
180     virtual void requestPointerUnlock() OVERRIDE;
181
182     virtual void didAssociateFormControls(const Vector<RefPtr<WebCore::Element> >&) OVERRIDE;
183     virtual void didChangeValueInTextField(WebCore::HTMLFormControlElement&) OVERRIDE;
184     virtual void didEndEditingOnTextField(WebCore::HTMLInputElement&) OVERRIDE;
185     virtual void handleKeyboardEventOnTextField(WebCore::HTMLInputElement&, WebCore::KeyboardEvent&) OVERRIDE;
186
187     // FIXME: Remove this method once we have input routing in the browser
188     // process. See http://crbug.com/339659.
189     virtual void forwardInputEvent(WebCore::Document*, WebCore::Event*) OVERRIDE;
190
191     virtual void didCancelCompositionOnSelectionChange() OVERRIDE;
192     virtual void willSetInputMethodState() OVERRIDE;
193
194 private:
195     virtual bool isChromeClientImpl() const OVERRIDE { return true; }
196
197     WebNavigationPolicy getNavigationPolicy();
198     void setCursor(const WebCursorInfo&);
199
200     WebViewImpl* m_webView;  // weak pointer
201     bool m_toolbarsVisible;
202     bool m_statusbarVisible;
203     bool m_scrollbarsVisible;
204     bool m_menubarVisible;
205     bool m_resizable;
206
207     WebCore::PagePopupDriver* m_pagePopupDriver;
208 };
209
210 class NavigatorContentUtilsClientImpl FINAL : public WebCore::NavigatorContentUtilsClient {
211 public:
212     static PassOwnPtr<NavigatorContentUtilsClientImpl> create(WebViewImpl*);
213     virtual ~NavigatorContentUtilsClientImpl() { }
214
215     virtual void registerProtocolHandler(const String& scheme, const WebCore::KURL& baseURL, const WebCore::KURL&, const String& title) OVERRIDE;
216     virtual CustomHandlersState isProtocolHandlerRegistered(const String& scheme, const WebCore::KURL& baseURL, const WebCore::KURL&) OVERRIDE;
217     virtual void unregisterProtocolHandler(const String& scheme, const WebCore::KURL& baseURL, const WebCore::KURL&) OVERRIDE;
218
219 private:
220     explicit NavigatorContentUtilsClientImpl(WebViewImpl*);
221
222     WebViewImpl* m_webView;
223 };
224
225 DEFINE_TYPE_CASTS(ChromeClientImpl, WebCore::ChromeClient, client, client->isChromeClientImpl(), client.isChromeClientImpl());
226
227 } // namespace blink
228
229 #endif