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