• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "core/page/ChromeClient.h"
36 #include "modules/navigatorcontentutils/NavigatorContentUtilsClient.h"
37 #include "platform/PopupMenu.h"
38 #include "platform/weborigin/KURL.h"
39 #include "public/platform/WebColor.h"
40 #include "public/web/WebNavigationPolicy.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::LocalFrame*, 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 void scroll(
122         const WebCore::IntSize& scrollDelta, const WebCore::IntRect& rectToScroll,
123         const WebCore::IntRect& clipRect) OVERRIDE;
124     virtual WebCore::IntRect rootViewToScreen(const WebCore::IntRect&) const OVERRIDE;
125     virtual WebScreenInfo screenInfo() const OVERRIDE;
126     virtual void contentsSizeChanged(WebCore::LocalFrame*, const WebCore::IntSize&) const OVERRIDE;
127     virtual void deviceOrPageScaleFactorChanged() const OVERRIDE;
128     virtual void layoutUpdated(WebCore::LocalFrame*) const OVERRIDE;
129     virtual void mouseDidMoveOverElement(
130         const WebCore::HitTestResult&, unsigned modifierFlags) OVERRIDE;
131     virtual void setToolTip(const WTF::String& tooltipText, WebCore::TextDirection) OVERRIDE;
132     virtual void dispatchViewportPropertiesDidChange(const WebCore::ViewportDescription&) const OVERRIDE;
133     virtual void print(WebCore::LocalFrame*) OVERRIDE;
134     virtual void annotatedRegionsChanged() OVERRIDE;
135     virtual bool paintCustomOverhangArea(WebCore::GraphicsContext*, const WebCore::IntRect&, const WebCore::IntRect&, const WebCore::IntRect&) OVERRIDE;
136     virtual PassOwnPtr<WebCore::ColorChooser> createColorChooser(WebCore::LocalFrame*, WebCore::ColorChooserClient*, const WebCore::Color&) OVERRIDE;
137     virtual PassRefPtrWillBeRawPtr<WebCore::DateTimeChooser> openDateTimeChooser(WebCore::DateTimeChooserClient*, const WebCore::DateTimeChooserParameters&) OVERRIDE;
138     virtual void openTextDataListChooser(WebCore::HTMLInputElement&) OVERRIDE;
139     virtual void runOpenPanel(WebCore::LocalFrame*, PassRefPtr<WebCore::FileChooser>) OVERRIDE;
140     virtual void enumerateChosenDirectory(WebCore::FileChooser*) OVERRIDE;
141     virtual void setCursor(const WebCore::Cursor&) OVERRIDE;
142     virtual void needTouchEvents(bool needTouchEvents) OVERRIDE;
143     virtual void setTouchAction(WebCore::TouchAction) OVERRIDE;
144 
145     virtual WebCore::GraphicsLayerFactory* graphicsLayerFactory() const OVERRIDE;
146 
147     // Pass 0 as the GraphicsLayer to detatch the root layer.
148     virtual void attachRootGraphicsLayer(WebCore::GraphicsLayer*) OVERRIDE;
149 
150     virtual void enterFullScreenForElement(WebCore::Element*) OVERRIDE;
151     virtual void exitFullScreenForElement(WebCore::Element*) OVERRIDE;
152 
153     // ChromeClient methods:
154     virtual void postAccessibilityNotification(WebCore::AXObject*, WebCore::AXObjectCache::AXNotification) OVERRIDE;
155     virtual String acceptLanguages() OVERRIDE;
156 
157     // ChromeClientImpl:
158     void setCursorForPlugin(const WebCursorInfo&);
159     void setNewWindowNavigationPolicy(WebNavigationPolicy);
160 
161     virtual bool hasOpenedPopup() const OVERRIDE;
162     virtual PassRefPtr<WebCore::PopupMenu> createPopupMenu(WebCore::LocalFrame&, WebCore::PopupMenuClient*) const OVERRIDE;
163     WebCore::PagePopup* openPagePopup(WebCore::PagePopupClient*, const WebCore::IntRect&);
164     void closePagePopup(WebCore::PagePopup*);
165     virtual void setPagePopupDriver(WebCore::PagePopupDriver*) OVERRIDE;
166     virtual void resetPagePopupDriver() OVERRIDE;
167 
168     virtual bool shouldRunModalDialogDuringPageDismissal(const DialogType&, const String& dialogMessage, WebCore::Document::PageDismissalType) const OVERRIDE;
169 
170     virtual bool requestPointerLock() OVERRIDE;
171     virtual void requestPointerUnlock() OVERRIDE;
172 
173     virtual void didAssociateFormControls(const WillBeHeapVector<RefPtrWillBeMember<WebCore::Element> >&) OVERRIDE;
174     virtual void didChangeValueInTextField(WebCore::HTMLFormControlElement&) OVERRIDE;
175     virtual void didEndEditingOnTextField(WebCore::HTMLInputElement&) OVERRIDE;
176     virtual void handleKeyboardEventOnTextField(WebCore::HTMLInputElement&, WebCore::KeyboardEvent&) OVERRIDE;
177 
178     // FIXME: Remove this method once we have input routing in the browser
179     // process. See http://crbug.com/339659.
180     virtual void forwardInputEvent(WebCore::Frame*, WebCore::Event*) OVERRIDE;
181 
182     virtual void didCancelCompositionOnSelectionChange() OVERRIDE;
183     virtual void willSetInputMethodState() OVERRIDE;
184     virtual void didUpdateTextOfFocusedElementByNonUserInput() OVERRIDE;
185 
186 private:
isChromeClientImpl()187     virtual bool isChromeClientImpl() const OVERRIDE { return true; }
188 
189     WebNavigationPolicy getNavigationPolicy();
190     void setCursor(const WebCursorInfo&);
191 
192     WebViewImpl* m_webView;  // weak pointer
193     bool m_toolbarsVisible;
194     bool m_statusbarVisible;
195     bool m_scrollbarsVisible;
196     bool m_menubarVisible;
197     bool m_resizable;
198 
199     WebCore::PagePopupDriver* m_pagePopupDriver;
200 };
201 
202 DEFINE_TYPE_CASTS(ChromeClientImpl, WebCore::ChromeClient, client, client->isChromeClientImpl(), client.isChromeClientImpl());
203 
204 } // namespace blink
205 
206 #endif
207