Update To 11.40.268.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 "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 blink {
44 class AXObject;
45 class ColorChooser;
46 class ColorChooserClient;
47 class Element;
48 class FileChooser;
49 class GraphicsLayerFactory;
50 class HTMLFormControlElement;
51 class HTMLInputElement;
52 class KeyboardEvent;
53 class PagePopup;
54 class PagePopupClient;
55 class PopupMenuClient;
56 class DateTimeChooser;
57 class DateTimeChooserClient;
58 class WebViewImpl;
59 struct WebCursorInfo;
60 struct WindowFeatures;
61
62 // Handles window-level notifications from WebCore on behalf of a WebView.
63 class ChromeClientImpl final : public ChromeClient {
64 public:
65     explicit ChromeClientImpl(WebViewImpl* webView);
66     virtual ~ChromeClientImpl();
67
68     virtual void* webView() const override;
69
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;
134
135     virtual GraphicsLayerFactory* graphicsLayerFactory() const override;
136
137     // Pass 0 as the GraphicsLayer to detatch the root layer.
138     virtual void attachRootGraphicsLayer(GraphicsLayer*) override;
139
140     virtual void enterFullScreenForElement(Element*) override;
141     virtual void exitFullScreenForElement(Element*) override;
142
143     virtual void clearCompositedSelectionBounds() override;
144     virtual void updateCompositedSelectionBounds(const blink::CompositedSelectionBound& anchor, const blink::CompositedSelectionBound& focus) override;
145
146     // ChromeClient methods:
147     virtual void postAccessibilityNotification(AXObject*, AXObjectCache::AXNotification) override;
148     virtual String acceptLanguages() override;
149
150     // ChromeClientImpl:
151     void setCursorForPlugin(const WebCursorInfo&);
152     void setNewWindowNavigationPolicy(WebNavigationPolicy);
153
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; }
161
162     virtual bool shouldRunModalDialogDuringPageDismissal(const DialogType&, const String& dialogMessage, Document::PageDismissalType) const override;
163
164     virtual bool requestPointerLock() override;
165     virtual void requestPointerUnlock() override;
166
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;
171
172     virtual void didCancelCompositionOnSelectionChange() override;
173     virtual void willSetInputMethodState() override;
174     virtual void didUpdateTextOfFocusedElementByNonUserInput() override;
175     virtual void showImeIfNeeded() override;
176
177 private:
178     virtual bool isChromeClientImpl() const override { return true; }
179
180     WebNavigationPolicy getNavigationPolicy();
181     void setCursor(const WebCursorInfo&);
182
183     WebViewImpl* m_webView;  // weak pointer
184     bool m_toolbarsVisible;
185     bool m_statusbarVisible;
186     bool m_scrollbarsVisible;
187     bool m_menubarVisible;
188     bool m_resizable;
189
190     PagePopupDriver* m_pagePopupDriver;
191 };
192
193 DEFINE_TYPE_CASTS(ChromeClientImpl, ChromeClient, client, client->isChromeClientImpl(), client.isChromeClientImpl());
194
195 } // namespace blink
196
197 #endif