Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / Source / web / ChromeClientImpl.h
blob27b3ed9aa38776dc4f6c4b0cd645d90b4a6317aa
1 /*
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
7 * met:
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.
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 "core/page/WindowFeatures.h"
37 #include "public/web/WebNavigationPolicy.h"
38 #include "wtf/PassOwnPtr.h"
40 namespace blink {
42 class PagePopup;
43 class PagePopupClient;
44 class WebViewImpl;
45 struct WebCursorInfo;
47 // Handles window-level notifications from core on behalf of a WebView.
48 class ChromeClientImpl final : public ChromeClient {
49 public:
50 static PassOwnPtrWillBeRawPtr<ChromeClientImpl> create(WebViewImpl*);
51 ~ChromeClientImpl() override;
53 void* webView() const override;
55 // ChromeClient methods:
56 void chromeDestroyed() override;
57 void setWindowRect(const IntRect&) override;
58 IntRect windowRect() override;
59 IntRect pageRect() override;
60 void focus() override;
61 bool canTakeFocus(WebFocusType) override;
62 void takeFocus(WebFocusType) override;
63 void focusedNodeChanged(Node* fromNode, Node* toNode) override;
64 void focusedFrameChanged(LocalFrame*) override;
65 bool hadFormInteraction() const override;
66 Page* createWindow(
67 LocalFrame*, const FrameLoadRequest&, const WindowFeatures&, NavigationPolicy, ShouldSendReferrer) override;
68 void show(NavigationPolicy) override;
69 void didOverscroll(const FloatSize&, const FloatSize&, const FloatPoint&, const FloatSize&) override;
70 void setToolbarsVisible(bool) override;
71 bool toolbarsVisible() override;
72 void setStatusbarVisible(bool) override;
73 bool statusbarVisible() override;
74 void setScrollbarsVisible(bool) override;
75 bool scrollbarsVisible() override;
76 void setMenubarVisible(bool) override;
77 bool menubarVisible() override;
78 void setResizable(bool) override;
79 bool shouldReportDetailedMessageForSource(LocalFrame&, const String&) override;
80 void addMessageToConsole(
81 LocalFrame*, MessageSource, MessageLevel,
82 const String& message, unsigned lineNumber,
83 const String& sourceID, const String& stackTrace) override;
84 bool canOpenBeforeUnloadConfirmPanel() override;
85 bool openBeforeUnloadConfirmPanelDelegate(LocalFrame*, const String&) override;
86 void closeWindowSoon() override;
87 bool openJavaScriptAlertDelegate(LocalFrame*, const String&) override;
88 bool openJavaScriptConfirmDelegate(LocalFrame*, const String&) override;
89 bool openJavaScriptPromptDelegate(
90 LocalFrame*, const String& message,
91 const String& defaultValue, String& result) override;
92 void setStatusbarText(const String& message) override;
93 bool tabsToLinks() override;
94 IntRect windowResizerRect() const override;
95 void invalidateRect(const IntRect&) override;
96 void scheduleAnimation() override;
97 void scheduleAnimationForFrame(LocalFrame* localRoot) override;
98 IntRect viewportToScreen(const IntRect&) const override;
99 WebScreenInfo screenInfo() const override;
100 void contentsSizeChanged(LocalFrame*, const IntSize&) const override;
101 void pageScaleFactorChanged() const override;
102 float clampPageScaleFactorToLimits(float scale) const override;
103 void layoutUpdated(LocalFrame*) const override;
104 void showMouseOverURL(const HitTestResult&) override;
105 void setToolTip(const String& tooltipText, TextDirection) override;
106 void dispatchViewportPropertiesDidChange(const ViewportDescription&) const override;
107 void printDelegate(LocalFrame*) override;
108 void annotatedRegionsChanged() override;
109 PassOwnPtrWillBeRawPtr<ColorChooser> openColorChooser(LocalFrame*, ColorChooserClient*, const Color&) override;
110 PassRefPtr<DateTimeChooser> openDateTimeChooser(DateTimeChooserClient*, const DateTimeChooserParameters&) override;
111 void openFileChooser(LocalFrame*, PassRefPtr<FileChooser>) override;
112 void enumerateChosenDirectory(FileChooser*) override;
113 void setCursor(const Cursor&) override;
114 Cursor lastSetCursorForTesting() const override;
115 void needTouchEvents(bool needTouchEvents) override;
116 void setTouchAction(TouchAction) override;
118 GraphicsLayerFactory* graphicsLayerFactory() const override;
120 // Pass 0 as the GraphicsLayer to detatch the root layer.
121 void attachRootGraphicsLayer(GraphicsLayer*, LocalFrame* localRoot) override;
123 void setCompositedDisplayList(PassOwnPtr<CompositedDisplayList>) override;
124 CompositedDisplayList* compositedDisplayListForTesting() override;
126 void attachCompositorAnimationTimeline(WebCompositorAnimationTimeline*, LocalFrame* localRoot) override;
127 void detachCompositorAnimationTimeline(WebCompositorAnimationTimeline*, LocalFrame* localRoot) override;
129 void enterFullScreenForElement(Element*) override;
130 void exitFullScreenForElement(Element*) override;
132 void clearCompositedSelection() override;
133 void updateCompositedSelection(const CompositedSelection&) override;
135 // ChromeClient methods:
136 void postAccessibilityNotification(AXObject*, AXObjectCache::AXNotification) override;
137 String acceptLanguages() override;
139 // ChromeClientImpl:
140 void setCursorForPlugin(const WebCursorInfo&);
141 void setNewWindowNavigationPolicy(WebNavigationPolicy);
142 void setCursorOverridden(bool);
144 bool hasOpenedPopup() const override;
145 PassRefPtrWillBeRawPtr<PopupMenu> openPopupMenu(LocalFrame&, HTMLSelectElement&) override;
146 PagePopup* openPagePopup(PagePopupClient*);
147 void closePagePopup(PagePopup*);
148 DOMWindow* pagePopupWindowForTesting() const override;
150 bool shouldOpenModalDialogDuringPageDismissal(const DialogType&, const String& dialogMessage, Document::PageDismissalType) const override;
152 bool requestPointerLock() override;
153 void requestPointerUnlock() override;
155 // AutofillClient pass throughs:
156 void didAssociateFormControls(const WillBeHeapVector<RefPtrWillBeMember<Element>>&, LocalFrame*) override;
157 void handleKeyboardEventOnTextField(HTMLInputElement&, KeyboardEvent&) override;
158 void didChangeValueInTextField(HTMLFormControlElement&) override;
159 void didEndEditingOnTextField(HTMLInputElement&) override;
160 void openTextDataListChooser(HTMLInputElement&) override;
161 void textFieldDataListChanged(HTMLInputElement&) override;
162 void ajaxSucceeded(LocalFrame*) override;
164 void didCancelCompositionOnSelectionChange() override;
165 void willSetInputMethodState() override;
166 void didUpdateTextOfFocusedElementByNonUserInput() override;
167 void showImeIfNeeded() override;
169 void registerViewportLayers() const override;
171 void showUnhandledTapUIIfNeeded(IntPoint, Node*, bool) override;
172 void onMouseDown(Node*) override;
173 void didUpdateTopControls() const override;
175 FloatSize elasticOverscroll() const override;
177 private:
178 explicit ChromeClientImpl(WebViewImpl*);
180 bool isChromeClientImpl() const override { return true; }
181 void registerPopupOpeningObserver(PopupOpeningObserver*) override;
182 void unregisterPopupOpeningObserver(PopupOpeningObserver*) override;
184 void notifyPopupOpeningObservers() const;
185 void setCursor(const WebCursorInfo&);
187 WebViewImpl* m_webView; // Weak pointer.
188 WindowFeatures m_windowFeatures;
189 Vector<PopupOpeningObserver*> m_popupOpeningObservers;
190 Cursor m_lastSetMouseCursorForTesting;
191 bool m_cursorOverridden;
194 DEFINE_TYPE_CASTS(ChromeClientImpl, ChromeClient, client, client->isChromeClientImpl(), client.isChromeClientImpl());
196 } // namespace blink
198 #endif