2 * Copyright (C) 2009 Google Inc. All rights reserved.
3 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
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
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.
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.
32 #ifndef ChromeClientImpl_h
33 #define ChromeClientImpl_h
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"
46 class ColorChooserClient;
49 class GraphicsLayerFactory;
50 class HTMLFormControlElement;
51 class HTMLInputElement;
54 class PagePopupClient;
55 class PopupMenuClient;
56 class DateTimeChooser;
57 class DateTimeChooserClient;
60 struct WindowFeatures;
62 // Handles window-level notifications from WebCore on behalf of a WebView.
63 class ChromeClientImpl final : public ChromeClient {
65 explicit ChromeClientImpl(WebViewImpl* webView);
66 virtual ~ChromeClientImpl();
68 virtual void* webView() const override;
70 // ChromeClient methods:
71 virtual void chromeDestroyed() override;
72 virtual void setWindowRect(const FloatRect&) override;
73 virtual FloatRect windowRect() override;
74 virtual FloatRect pageRect() override;
75 virtual void focus() override;
76 virtual bool canTakeFocus(FocusType) override;
77 virtual void takeFocus(FocusType) override;
78 virtual void focusedNodeChanged(Node*) override;
79 virtual void focusedFrameChanged(LocalFrame*) override;
80 virtual Page* createWindow(
81 LocalFrame*, const FrameLoadRequest&, const WindowFeatures&, NavigationPolicy, ShouldSendReferrer) override;
82 virtual void show(NavigationPolicy) override;
83 virtual bool canRunModal() override;
84 virtual void runModal() override;
85 virtual void setToolbarsVisible(bool) override;
86 virtual bool toolbarsVisible() override;
87 virtual void setStatusbarVisible(bool) override;
88 virtual bool statusbarVisible() override;
89 virtual void setScrollbarsVisible(bool) override;
90 virtual bool scrollbarsVisible() override;
91 virtual void setMenubarVisible(bool) override;
92 virtual bool menubarVisible() override;
93 virtual void setResizable(bool) override;
94 virtual bool shouldReportDetailedMessageForSource(const WTF::String&) override;
95 virtual void addMessageToConsole(
96 LocalFrame*, MessageSource, MessageLevel,
97 const WTF::String& message, unsigned lineNumber,
98 const WTF::String& sourceID, const WTF::String& stackTrace) override;
99 virtual bool canRunBeforeUnloadConfirmPanel() override;
100 virtual bool runBeforeUnloadConfirmPanel(
101 const WTF::String& message, LocalFrame*) override;
102 virtual void closeWindowSoon() override;
103 virtual void runJavaScriptAlert(LocalFrame*, const WTF::String&) override;
104 virtual bool runJavaScriptConfirm(LocalFrame*, const WTF::String&) override;
105 virtual bool runJavaScriptPrompt(
106 LocalFrame*, const WTF::String& message,
107 const WTF::String& defaultValue, WTF::String& result) override;
108 virtual void setStatusbarText(const WTF::String& message) override;
109 virtual bool tabsToLinks() override;
110 virtual IntRect windowResizerRect() const override;
111 virtual void invalidateContentsAndRootView(const IntRect&) override;
112 virtual void invalidateContentsForSlowScroll(const IntRect&) override;
113 virtual void scheduleAnimation() override;
114 virtual IntRect rootViewToScreen(const IntRect&) const override;
115 virtual WebScreenInfo screenInfo() const override;
116 virtual void contentsSizeChanged(LocalFrame*, const IntSize&) const override;
117 virtual void deviceOrPageScaleFactorChanged() const override;
118 virtual void layoutUpdated(LocalFrame*) const override;
119 virtual void mouseDidMoveOverElement(
120 const HitTestResult&, unsigned modifierFlags) override;
121 virtual void setToolTip(const WTF::String& tooltipText, TextDirection) override;
122 virtual void dispatchViewportPropertiesDidChange(const ViewportDescription&) const override;
123 virtual void print(LocalFrame*) override;
124 virtual void annotatedRegionsChanged() override;
125 virtual bool paintCustomOverhangArea(GraphicsContext*, const IntRect&, const IntRect&, const IntRect&) override;
126 virtual PassOwnPtrWillBeRawPtr<ColorChooser> createColorChooser(LocalFrame*, ColorChooserClient*, const Color&) override;
127 virtual PassRefPtr<DateTimeChooser> openDateTimeChooser(DateTimeChooserClient*, const DateTimeChooserParameters&) override;
128 virtual void openTextDataListChooser(HTMLInputElement&) override;
129 virtual void runOpenPanel(LocalFrame*, PassRefPtr<FileChooser>) override;
130 virtual void enumerateChosenDirectory(FileChooser*) override;
131 virtual void setCursor(const Cursor&) override;
132 virtual void needTouchEvents(bool needTouchEvents) override;
133 virtual void setTouchAction(TouchAction) override;
135 virtual GraphicsLayerFactory* graphicsLayerFactory() const override;
137 // Pass 0 as the GraphicsLayer to detatch the root layer.
138 virtual void attachRootGraphicsLayer(GraphicsLayer*) override;
140 virtual void enterFullScreenForElement(Element*) override;
141 virtual void exitFullScreenForElement(Element*) override;
143 virtual void clearCompositedSelectionBounds() override;
144 virtual void updateCompositedSelectionBounds(const blink::CompositedSelectionBound& anchor, const blink::CompositedSelectionBound& focus) override;
146 // ChromeClient methods:
147 virtual void postAccessibilityNotification(AXObject*, AXObjectCache::AXNotification) override;
148 virtual String acceptLanguages() override;
151 void setCursorForPlugin(const WebCursorInfo&);
152 void setNewWindowNavigationPolicy(WebNavigationPolicy);
154 virtual bool hasOpenedPopup() const override;
155 virtual PassRefPtrWillBeRawPtr<PopupMenu> createPopupMenu(LocalFrame&, PopupMenuClient*) const override;
156 PagePopup* openPagePopup(PagePopupClient*, const IntRect&);
157 void closePagePopup(PagePopup*);
158 virtual void setPagePopupDriver(PagePopupDriver*) override;
159 virtual void resetPagePopupDriver() override;
160 virtual PagePopupDriver* pagePopupDriver() const override { return m_pagePopupDriver; }
162 virtual bool shouldRunModalDialogDuringPageDismissal(const DialogType&, const String& dialogMessage, Document::PageDismissalType) const override;
164 virtual bool requestPointerLock() override;
165 virtual void requestPointerUnlock() override;
167 virtual void didAssociateFormControls(const WillBeHeapVector<RefPtrWillBeMember<Element> >&) override;
168 virtual void didChangeValueInTextField(HTMLFormControlElement&) override;
169 virtual void didEndEditingOnTextField(HTMLInputElement&) override;
170 virtual void handleKeyboardEventOnTextField(HTMLInputElement&, KeyboardEvent&) override;
172 virtual void didCancelCompositionOnSelectionChange() override;
173 virtual void willSetInputMethodState() override;
174 virtual void didUpdateTextOfFocusedElementByNonUserInput() override;
175 virtual void showImeIfNeeded() override;
178 virtual bool isChromeClientImpl() const override { return true; }
180 WebNavigationPolicy getNavigationPolicy();
181 void setCursor(const WebCursorInfo&);
183 WebViewImpl* m_webView; // weak pointer
184 bool m_toolbarsVisible;
185 bool m_statusbarVisible;
186 bool m_scrollbarsVisible;
187 bool m_menubarVisible;
190 PagePopupDriver* m_pagePopupDriver;
193 DEFINE_TYPE_CASTS(ChromeClientImpl, ChromeClient, client, client->isChromeClientImpl(), client.isChromeClientImpl());