• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2006, 2007, 2008, 2009 Apple 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
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  *
14  * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
15  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
18  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
21  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
22  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25  */
26 
27 #include <WebCore/ChromeClient.h>
28 #include <WebCore/COMPtr.h>
29 #include <WebCore/GraphicsContext.h>
30 #include <WebCore/FocusDirection.h>
31 #include <WebCore/ScrollTypes.h>
32 #include <wtf/Forward.h>
33 #include <wtf/PassRefPtr.h>
34 
35 class WebView;
36 class WebDesktopNotificationsDelegate;
37 
38 interface IWebUIDelegate;
39 
40 class WebChromeClient : public WebCore::ChromeClient {
41 public:
42     WebChromeClient(WebView*);
43 
44     virtual void chromeDestroyed();
45 
webView()46     virtual void* webView() const { return 0; }
47     virtual void setWindowRect(const WebCore::FloatRect&);
48     virtual WebCore::FloatRect windowRect();
49 
50     virtual WebCore::FloatRect pageRect();
51 
52     virtual float scaleFactor();
53 
54     virtual void focus();
55     virtual void unfocus();
56 
57     virtual bool canTakeFocus(WebCore::FocusDirection);
58     virtual void takeFocus(WebCore::FocusDirection);
59 
60     virtual void focusedNodeChanged(WebCore::Node*);
61     virtual void focusedFrameChanged(WebCore::Frame*);
62 
63     virtual WebCore::Page* createWindow(WebCore::Frame*, const WebCore::FrameLoadRequest&, const WebCore::WindowFeatures&, const WebCore::NavigationAction&);
64     virtual void show();
65 
66     virtual bool canRunModal();
67     virtual void runModal();
68 
69     virtual void setToolbarsVisible(bool);
70     virtual bool toolbarsVisible();
71 
72     virtual void setStatusbarVisible(bool);
73     virtual bool statusbarVisible();
74 
75     virtual void setScrollbarsVisible(bool);
76     virtual bool scrollbarsVisible();
77 
78     virtual void setMenubarVisible(bool);
79     virtual bool menubarVisible();
80 
81     virtual void setResizable(bool);
82 
83     virtual void addMessageToConsole(WebCore::MessageSource source, WebCore::MessageType type, WebCore::MessageLevel level, const WTF::String& message, unsigned line, const WTF::String& url);
84 
85     virtual bool canRunBeforeUnloadConfirmPanel();
86     virtual bool runBeforeUnloadConfirmPanel(const WTF::String& message, WebCore::Frame* frame);
87 
88     virtual void closeWindowSoon();
89 
90     virtual void runJavaScriptAlert(WebCore::Frame*, const WTF::String&);
91     virtual bool runJavaScriptConfirm(WebCore::Frame*, const WTF::String&);
92     virtual bool runJavaScriptPrompt(WebCore::Frame*, const WTF::String& message, const WTF::String& defaultValue, WTF::String& result);
93     virtual void setStatusbarText(const WTF::String&);
94     virtual bool shouldInterruptJavaScript();
95 
96     virtual WebCore::KeyboardUIMode keyboardUIMode();
97     virtual WebCore::IntRect windowResizerRect() const;
98 
99     virtual void invalidateWindow(const WebCore::IntRect&, bool);
100     virtual void invalidateContentsAndWindow(const WebCore::IntRect&, bool);
101     virtual void invalidateContentsForSlowScroll(const WebCore::IntRect&, bool);
102     virtual void scroll(const WebCore::IntSize& scrollDelta, const WebCore::IntRect& rectToScroll, const WebCore::IntRect& clipRect);
103 
104     virtual WebCore::IntPoint screenToWindow(const WebCore::IntPoint& p) const;
105     virtual WebCore::IntRect windowToScreen(const WebCore::IntRect& r) const;
106     virtual PlatformPageClient platformPageClient() const;
107     virtual void contentsSizeChanged(WebCore::Frame*, const WebCore::IntSize&) const;
108 
scrollbarsModeDidChange()109     virtual void scrollbarsModeDidChange() const { }
110     virtual void mouseDidMoveOverElement(const WebCore::HitTestResult&, unsigned modifierFlags);
111     virtual bool shouldMissingPluginMessageBeButton() const;
112     virtual void missingPluginButtonClicked(WebCore::Element*) const;
113 
114     virtual void setToolTip(const WTF::String&, WebCore::TextDirection);
115 
116     virtual void print(WebCore::Frame*);
117 
118 #if ENABLE(DATABASE)
119     virtual void exceededDatabaseQuota(WebCore::Frame*, const WTF::String&);
120 #endif
121 
122 #if ENABLE(OFFLINE_WEB_APPLICATIONS)
123     virtual void reachedMaxAppCacheSize(int64_t spaceNeeded);
124     virtual void reachedApplicationCacheOriginQuota(WebCore::SecurityOrigin*);
125 #endif
126 
127 #if ENABLE(CONTEXT_MENUS)
showContextMenu()128     virtual void showContextMenu() { }
129 #endif
130 
131     virtual void populateVisitedLinks();
132 
133     virtual bool paintCustomScrollbar(WebCore::GraphicsContext*, const WebCore::FloatRect&, WebCore::ScrollbarControlSize,
134                                         WebCore::ScrollbarControlState, WebCore::ScrollbarPart pressedPart, bool vertical,
135                                         float value, float proportion, WebCore::ScrollbarControlPartMask);
136     virtual bool paintCustomScrollCorner(WebCore::GraphicsContext*, const WebCore::FloatRect&);
137 
138     virtual void runOpenPanel(WebCore::Frame*, PassRefPtr<WebCore::FileChooser>);
139     virtual void chooseIconForFiles(const Vector<WTF::String>&, WebCore::FileChooser*);
140 
141     virtual void setCursor(const WebCore::Cursor&);
142     virtual void setLastSetCursorToCurrentCursor();
143 
webView()144     WebView* webView() const { return m_webView; }
145 
formStateDidChange(const WebCore::Node *)146     virtual void formStateDidChange(const WebCore::Node*) { }
147 
148 #if USE(ACCELERATED_COMPOSITING)
149         // Pass 0 as the GraphicsLayer to detatch the root layer.
150         virtual void attachRootGraphicsLayer(WebCore::Frame*, WebCore::GraphicsLayer*);
151         // Sets a flag to specify that the next time content is drawn to the window,
152         // the changes appear on the screen in synchrony with updates to GraphicsLayers.
setNeedsOneShotDrawingSynchronization()153         virtual void setNeedsOneShotDrawingSynchronization() { }
154         // Sets a flag to specify that the view needs to be updated, so we need
155         // to do an eager layout before the drawing.
156         virtual void scheduleCompositingLayerSync();
157 #endif
158 
scrollRectIntoView(const WebCore::IntRect &,const WebCore::ScrollView *)159     virtual void scrollRectIntoView(const WebCore::IntRect&, const WebCore::ScrollView*) const {}
160 
161     // FIXME: Remove once all ports are using client-based geolocation. https://bugs.webkit.org/show_bug.cgi?id=40373
162     // For client-based geolocation, these two methods have been moved to WebGeolocationClient. https://bugs.webkit.org/show_bug.cgi?id=50061
requestGeolocationPermissionForFrame(WebCore::Frame *,WebCore::Geolocation *)163     virtual void requestGeolocationPermissionForFrame(WebCore::Frame*, WebCore::Geolocation*) { }
cancelGeolocationPermissionRequestForFrame(WebCore::Frame *,WebCore::Geolocation *)164     virtual void cancelGeolocationPermissionRequestForFrame(WebCore::Frame*, WebCore::Geolocation*) { }
165 
166 #if ENABLE(VIDEO)
167     virtual bool supportsFullscreenForNode(const WebCore::Node*);
168     virtual void enterFullscreenForNode(WebCore::Node*);
169     virtual void exitFullscreenForNode(WebCore::Node*);
170 #endif
171 
172 #if ENABLE(NOTIFICATIONS)
notificationPresenter()173     virtual WebCore::NotificationPresenter* notificationPresenter() const { return reinterpret_cast<WebCore::NotificationPresenter*>(m_notificationsDelegate.get()); }
174 #endif
175 
176     virtual bool selectItemWritingDirectionIsNatural();
177     virtual bool selectItemAlignmentFollowsMenuWritingDirection();
178     virtual PassRefPtr<WebCore::PopupMenu> createPopupMenu(WebCore::PopupMenuClient*) const;
179     virtual PassRefPtr<WebCore::SearchPopupMenu> createSearchPopupMenu(WebCore::PopupMenuClient*) const;
180 
181 private:
182     COMPtr<IWebUIDelegate> uiDelegate();
183 
184     WebView* m_webView;
185 
186 #if ENABLE(NOTIFICATIONS)
187     OwnPtr<WebDesktopNotificationsDelegate> m_notificationsDelegate;
188 #endif
189 };
190