tizen beta release
[framework/web/webkit-efl.git] / Source / WebKit / chromium / src / 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 "ChromeClientChromium.h"
36 #include "PopupMenu.h"
37 #include "SearchPopupMenu.h"
38
39 namespace WebCore {
40 class AccessibilityObject;
41 class Element;
42 class FileChooser;
43 class PopupContainer;
44 class PopupMenuClient;
45 class RenderBox;
46 class SecurityOrigin;
47 struct WindowFeatures;
48 }
49
50 namespace WebKit {
51 class WebViewImpl;
52 struct WebCursorInfo;
53 struct WebPopupMenuInfo;
54
55 // Handles window-level notifications from WebCore on behalf of a WebView.
56 class ChromeClientImpl : public WebCore::ChromeClientChromium {
57 public:
58     explicit ChromeClientImpl(WebViewImpl* webView);
59     virtual ~ChromeClientImpl();
60
61     virtual void* webView() const;
62
63     // ChromeClient methods:
64     virtual void chromeDestroyed();
65     virtual void setWindowRect(const WebCore::FloatRect&);
66     virtual WebCore::FloatRect windowRect();
67     virtual WebCore::FloatRect pageRect();
68     virtual void focus();
69     virtual void unfocus();
70     virtual bool canTakeFocus(WebCore::FocusDirection);
71     virtual void takeFocus(WebCore::FocusDirection);
72     virtual void focusedNodeChanged(WebCore::Node*);
73     virtual void focusedFrameChanged(WebCore::Frame*);
74     virtual WebCore::Page* createWindow(
75         WebCore::Frame*, const WebCore::FrameLoadRequest&, const WebCore::WindowFeatures&, const WebCore::NavigationAction&);
76     virtual void show();
77     virtual bool canRunModal();
78     virtual void runModal();
79     virtual void setToolbarsVisible(bool);
80     virtual bool toolbarsVisible();
81     virtual void setStatusbarVisible(bool);
82     virtual bool statusbarVisible();
83     virtual void setScrollbarsVisible(bool);
84     virtual bool scrollbarsVisible();
85     virtual void setMenubarVisible(bool);
86     virtual bool menubarVisible();
87     virtual void setResizable(bool);
88     virtual void addMessageToConsole(
89         WebCore::MessageSource, WebCore::MessageType, WebCore::MessageLevel,
90         const WTF::String& message, unsigned lineNumber,
91         const WTF::String& sourceID);
92     virtual bool canRunBeforeUnloadConfirmPanel();
93     virtual bool runBeforeUnloadConfirmPanel(
94         const WTF::String& message, WebCore::Frame*);
95     virtual void closeWindowSoon();
96     virtual void runJavaScriptAlert(WebCore::Frame*, const WTF::String&);
97     virtual bool runJavaScriptConfirm(WebCore::Frame*, const WTF::String&);
98     virtual bool runJavaScriptPrompt(
99         WebCore::Frame*, const WTF::String& message,
100         const WTF::String& defaultValue, WTF::String& result);
101     virtual void setStatusbarText(const WTF::String& message);
102     virtual bool shouldInterruptJavaScript();
103     virtual WebCore::KeyboardUIMode keyboardUIMode();
104     virtual WebCore::IntRect windowResizerRect() const;
105 #if ENABLE(REGISTER_PROTOCOL_HANDLER)
106     virtual void registerProtocolHandler(const String& scheme, const String& baseURL, const String& url, const String& title);
107 #endif
108     virtual void invalidateRootView(const WebCore::IntRect&, bool);
109     virtual void invalidateContentsAndRootView(const WebCore::IntRect&, bool);
110     virtual void invalidateContentsForSlowScroll(const WebCore::IntRect&, bool);
111 #if ENABLE(REQUEST_ANIMATION_FRAME)
112     virtual void scheduleAnimation();
113 #endif
114     virtual void scroll(
115         const WebCore::IntSize& scrollDelta, const WebCore::IntRect& rectToScroll,
116         const WebCore::IntRect& clipRect);
117     virtual WebCore::IntPoint screenToRootView(const WebCore::IntPoint&) const;
118     virtual WebCore::IntRect rootViewToScreen(const WebCore::IntRect&) const;
119     virtual PlatformPageClient platformPageClient() const { return 0; }
120     virtual void contentsSizeChanged(WebCore::Frame*, const WebCore::IntSize&) const;
121     virtual void layoutUpdated(WebCore::Frame*) const;
122     virtual void scrollRectIntoView(
123         const WebCore::IntRect&) const { }
124     virtual void scrollbarsModeDidChange() const;
125     virtual void mouseDidMoveOverElement(
126         const WebCore::HitTestResult& result, unsigned modifierFlags);
127     virtual void setToolTip(const WTF::String& tooltipText, WebCore::TextDirection);
128     virtual void print(WebCore::Frame*);
129     virtual void exceededDatabaseQuota(
130         WebCore::Frame*, const WTF::String& databaseName);
131     virtual void reachedMaxAppCacheSize(int64_t spaceNeeded);
132     virtual void reachedApplicationCacheOriginQuota(WebCore::SecurityOrigin*, int64_t totalSpaceNeeded);
133     virtual bool paintCustomOverhangArea(WebCore::GraphicsContext*, const WebCore::IntRect&, const WebCore::IntRect&, const WebCore::IntRect&);
134     virtual void requestGeolocationPermissionForFrame(WebCore::Frame*, WebCore::Geolocation*);
135     virtual void cancelGeolocationPermissionRequestForFrame(WebCore::Frame*, WebCore::Geolocation*);
136     virtual void runOpenPanel(WebCore::Frame*, PassRefPtr<WebCore::FileChooser>);
137     virtual void loadIconForFiles(const Vector<WTF::String>&, WebCore::FileIconLoader*);
138 #if ENABLE(DIRECTORY_UPLOAD)
139     virtual void enumerateChosenDirectory(WebCore::FileChooser*);
140 #endif
141     virtual void setCursor(const WebCore::Cursor&);
142     virtual void setCursorHiddenUntilMouseMoves(bool);
143     virtual void formStateDidChange(const WebCore::Node*);
144 #if ENABLE(TOUCH_EVENTS)
145     // FIXME: All touch events are forwarded regardless of whether or not they are needed.
146     virtual void needTouchEvents(bool needTouchEvents) { }
147 #endif
148
149 #if USE(ACCELERATED_COMPOSITING)
150     // Pass 0 as the GraphicsLayer to detatch the root layer.
151     virtual void attachRootGraphicsLayer(WebCore::Frame*, WebCore::GraphicsLayer*);
152
153     // Sets a flag to specify that the next time content is drawn to the window,
154     // the changes appear on the screen in synchrony with updates to GraphicsLayers.
155     virtual void setNeedsOneShotDrawingSynchronization() { }
156
157     // Sets a flag to specify that the view needs to be updated, so we need
158     // to do an eager layout before the drawing.
159     virtual void scheduleCompositingLayerSync();
160
161     virtual CompositingTriggerFlags allowedCompositingTriggers() const;
162 #endif
163
164     virtual bool supportsFullscreenForNode(const WebCore::Node*);
165     virtual void enterFullscreenForNode(WebCore::Node*);
166     virtual void exitFullscreenForNode(WebCore::Node*);
167
168 #if ENABLE(FULLSCREEN_API)
169     virtual bool supportsFullScreenForElement(const WebCore::Element*, bool withKeyboard);
170     virtual void enterFullScreenForElement(WebCore::Element*);
171     virtual void exitFullScreenForElement(WebCore::Element*);
172     virtual void fullScreenRendererChanged(WebCore::RenderBox*);
173 #endif
174
175     // ChromeClientChromium methods:
176     virtual void popupOpened(WebCore::PopupContainer* popupContainer,
177                              const WebCore::IntRect& bounds,
178                              bool handleExternally);
179     virtual void popupClosed(WebCore::PopupContainer* popupContainer);
180     virtual void postAccessibilityNotification(WebCore::AccessibilityObject*, WebCore::AXObjectCache::AXNotification);
181
182     // ChromeClientImpl:
183     void setCursorForPlugin(const WebCursorInfo&);
184
185     virtual bool selectItemWritingDirectionIsNatural();
186     virtual bool selectItemAlignmentFollowsMenuWritingDirection();
187     virtual PassRefPtr<WebCore::PopupMenu> createPopupMenu(WebCore::PopupMenuClient*) const;
188     virtual PassRefPtr<WebCore::SearchPopupMenu> createSearchPopupMenu(WebCore::PopupMenuClient*) const;
189
190 #if ENABLE(CONTEXT_MENUS)
191     virtual void showContextMenu() { }
192 #endif
193
194     virtual bool shouldRunModalDialogDuringPageDismissal(const DialogType&, const String& dialogMessage, WebCore::FrameLoader::PageDismissalType) const;
195
196     virtual bool shouldRubberBandInDirection(WebCore::ScrollDirection) const;
197     virtual void numWheelEventHandlersChanged(unsigned);
198
199 private:
200     void getPopupMenuInfo(WebCore::PopupContainer*, WebPopupMenuInfo*);
201     void setCursor(const WebCursorInfo&);
202
203     WebViewImpl* m_webView;  // weak pointer
204     bool m_toolbarsVisible;
205     bool m_statusbarVisible;
206     bool m_scrollbarsVisible;
207     bool m_menubarVisible;
208     bool m_resizable;
209 };
210
211 } // namespace WebKit
212
213 #endif