OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 /* |
2 // Use of this source code is governed by a BSD-style license that can be | 2 * Copyright (C) 2009 Google Inc. All rights reserved. |
3 // found in the LICENSE file. | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are |
| 6 * met: |
| 7 * |
| 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above |
| 11 * copyright notice, this list of conditions and the following disclaimer |
| 12 * in the documentation and/or other materials provided with the |
| 13 * distribution. |
| 14 * * Neither the name of Google Inc. nor the names of its |
| 15 * contributors may be used to endorse or promote products derived from |
| 16 * this software without specific prior written permission. |
| 17 * |
| 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ |
4 | 30 |
5 #ifndef WEBKIT_GLUE_CHROME_CLIENT_IMPL_H_ | 31 #ifndef ChromeClientImpl_h |
6 #define WEBKIT_GLUE_CHROME_CLIENT_IMPL_H_ | 32 #define ChromeClientImpl_h |
7 | 33 |
8 #include "ChromeClientChromium.h" | 34 #include "ChromeClientChromium.h" |
9 | 35 |
10 class WebViewImpl; | 36 class WebViewImpl; |
11 | 37 |
12 namespace WebCore { | 38 namespace WebCore { |
13 class HTMLParserQuirks; | 39 class HTMLParserQuirks; |
14 class PopupContainer; | 40 class PopupContainer; |
15 class SecurityOrigin; | 41 class SecurityOrigin; |
16 struct WindowFeatures; | 42 struct WindowFeatures; |
17 } | 43 } |
18 | 44 |
19 namespace WebKit { | 45 namespace WebKit { |
20 struct WebCursorInfo; | 46 struct WebCursorInfo; |
21 struct WebPopupMenuInfo; | 47 struct WebPopupMenuInfo; |
22 } | |
23 | 48 |
24 // Handles window-level notifications from WebCore on behalf of a WebView. | 49 // Handles window-level notifications from WebCore on behalf of a WebView. |
25 class ChromeClientImpl : public WebCore::ChromeClientChromium { | 50 class ChromeClientImpl : public WebCore::ChromeClientChromium { |
26 public: | 51 public: |
27 explicit ChromeClientImpl(WebViewImpl* webview); | 52 explicit ChromeClientImpl(WebViewImpl* webView); |
28 virtual ~ChromeClientImpl(); | 53 virtual ~ChromeClientImpl(); |
29 | 54 |
30 WebViewImpl* webview() const { return webview_; } | 55 WebViewImpl* webview() const { return m_webView; } |
31 | 56 |
32 virtual void chromeDestroyed(); | 57 // ChromeClient methods: |
| 58 virtual void chromeDestroyed(); |
| 59 virtual void setWindowRect(const WebCore::FloatRect&); |
| 60 virtual WebCore::FloatRect windowRect(); |
| 61 virtual WebCore::FloatRect pageRect(); |
| 62 virtual float scaleFactor(); |
| 63 virtual void focus(); |
| 64 virtual void unfocus(); |
| 65 virtual bool canTakeFocus(WebCore::FocusDirection); |
| 66 virtual void takeFocus(WebCore::FocusDirection); |
| 67 virtual WebCore::Page* createWindow( |
| 68 WebCore::Frame*, const WebCore::FrameLoadRequest&, const WebCore::WindowFeatures&); |
| 69 virtual void show(); |
| 70 virtual bool canRunModal(); |
| 71 virtual void runModal(); |
| 72 virtual void setToolbarsVisible(bool); |
| 73 virtual bool toolbarsVisible(); |
| 74 virtual void setStatusbarVisible(bool); |
| 75 virtual bool statusbarVisible(); |
| 76 virtual void setScrollbarsVisible(bool); |
| 77 virtual bool scrollbarsVisible(); |
| 78 virtual void setMenubarVisible(bool); |
| 79 virtual bool menubarVisible(); |
| 80 virtual void setResizable(bool); |
| 81 virtual void addMessageToConsole( |
| 82 WebCore::MessageSource, WebCore::MessageType, WebCore::MessageLevel, |
| 83 const WebCore::String& message, unsigned lineNumber, |
| 84 const WebCore::String& sourceID); |
| 85 virtual bool canRunBeforeUnloadConfirmPanel(); |
| 86 virtual bool runBeforeUnloadConfirmPanel( |
| 87 const WebCore::String& message, WebCore::Frame*); |
| 88 virtual void closeWindowSoon(); |
| 89 virtual void runJavaScriptAlert(WebCore::Frame*, const WebCore::String&); |
| 90 virtual bool runJavaScriptConfirm(WebCore::Frame*, const WebCore::String&); |
| 91 virtual bool runJavaScriptPrompt( |
| 92 WebCore::Frame*, const WebCore::String& message, |
| 93 const WebCore::String& defaultValue, WebCore::String& result); |
| 94 virtual void setStatusbarText(const WebCore::String& message); |
| 95 virtual bool shouldInterruptJavaScript(); |
| 96 virtual bool tabsToLinks() const; |
| 97 virtual WebCore::IntRect windowResizerRect() const; |
| 98 virtual void repaint( |
| 99 const WebCore::IntRect&, bool contentChanged, bool immediate = false, |
| 100 bool repaintContentOnly = false); |
| 101 virtual void scroll( |
| 102 const WebCore::IntSize& scrollDelta, const WebCore::IntRect& rectToScroll, |
| 103 const WebCore::IntRect& clipRect); |
| 104 virtual WebCore::IntPoint screenToWindow(const WebCore::IntPoint&) const; |
| 105 virtual WebCore::IntRect windowToScreen(const WebCore::IntRect&) const; |
| 106 virtual PlatformPageClient platformPageClient() const { return 0; } |
| 107 virtual void contentsSizeChanged(WebCore::Frame*, const WebCore::IntSize&) const; |
| 108 virtual void scrollRectIntoView( |
| 109 const WebCore::IntRect&, const WebCore::ScrollView*) const { } |
| 110 virtual void scrollbarsModeDidChange() const; |
| 111 virtual void mouseDidMoveOverElement( |
| 112 const WebCore::HitTestResult& result, unsigned modifierFlags); |
| 113 virtual void setToolTip(const WebCore::String& tooltipText, WebCore::TextDirection); |
| 114 virtual void print(WebCore::Frame*); |
| 115 virtual void exceededDatabaseQuota( |
| 116 WebCore::Frame*, const WebCore::String& databaseName); |
| 117 #if ENABLE(OFFLINE_WEB_APPLICATIONS) |
| 118 virtual void reachedMaxAppCacheSize(int64_t spaceNeeded); |
| 119 #endif |
| 120 #if ENABLE(NOTIFICATIONS) |
| 121 virtual WebCore::NotificationPresenter* notificationPresenter() const; |
| 122 #endif |
| 123 virtual void requestGeolocationPermissionForFrame( |
| 124 WebCore::Frame*, WebCore::Geolocation*) { } |
| 125 virtual void runOpenPanel(WebCore::Frame*, PassRefPtr<WebCore::FileChooser>); |
| 126 virtual bool setCursor(WebCore::PlatformCursorHandle) { return false; } |
| 127 virtual void formStateDidChange(const WebCore::Node*); |
| 128 virtual PassOwnPtr<WebCore::HTMLParserQuirks> createHTMLParserQuirks() { return 0; } |
33 | 129 |
34 virtual void setWindowRect(const WebCore::FloatRect&); | 130 // ChromeClientChromium methods: |
35 virtual WebCore::FloatRect windowRect(); | 131 virtual void popupOpened(WebCore::PopupContainer* popupContainer, |
| 132 const WebCore::IntRect& bounds, |
| 133 bool activatable, |
| 134 bool handleExternally); |
36 | 135 |
37 virtual WebCore::FloatRect pageRect(); | 136 // ChromeClientImpl: |
| 137 void setCursor(const WebCursorInfo& cursor); |
| 138 void setCursorForPlugin(const WebCursorInfo& cursor); |
38 | 139 |
39 virtual float scaleFactor(); | 140 private: |
| 141 void getPopupMenuInfo(WebCore::PopupContainer*, WebPopupMenuInfo*); |
40 | 142 |
41 virtual void focus(); | 143 WebViewImpl* m_webView; // weak pointer |
42 virtual void unfocus(); | 144 bool m_toolbarsVisible; |
43 | 145 bool m_statusbarVisible; |
44 virtual bool canTakeFocus(WebCore::FocusDirection); | 146 bool m_scrollbarsVisible; |
45 virtual void takeFocus(WebCore::FocusDirection); | 147 bool m_menubarVisible; |
46 | 148 bool m_resizable; |
47 virtual WebCore::Page* createWindow(WebCore::Frame*, | 149 // Set to true if the next SetCursor is to be ignored. |
48 const WebCore::FrameLoadRequest&, | 150 bool m_ignoreNextSetCursor; |
49 const WebCore::WindowFeatures&); | |
50 virtual void show(); | |
51 | |
52 virtual bool canRunModal(); | |
53 virtual void runModal(); | |
54 | |
55 virtual void setToolbarsVisible(bool); | |
56 virtual bool toolbarsVisible(); | |
57 | |
58 virtual void setStatusbarVisible(bool); | |
59 virtual bool statusbarVisible(); | |
60 | |
61 virtual void setScrollbarsVisible(bool); | |
62 virtual bool scrollbarsVisible(); | |
63 | |
64 virtual void setMenubarVisible(bool); | |
65 virtual bool menubarVisible(); | |
66 | |
67 virtual void setResizable(bool); | |
68 | |
69 virtual void addMessageToConsole(WebCore::MessageSource source, | |
70 WebCore::MessageType type, | |
71 WebCore::MessageLevel level, | |
72 const WebCore::String& message, | |
73 unsigned int lineNumber, | |
74 const WebCore::String& sourceID); | |
75 | |
76 virtual bool canRunBeforeUnloadConfirmPanel(); | |
77 virtual bool runBeforeUnloadConfirmPanel(const WebCore::String& message, | |
78 WebCore::Frame* frame); | |
79 | |
80 virtual void closeWindowSoon(); | |
81 | |
82 virtual void runJavaScriptAlert(WebCore::Frame*, const WebCore::String&); | |
83 virtual bool runJavaScriptConfirm(WebCore::Frame*, const WebCore::String&); | |
84 virtual bool runJavaScriptPrompt(WebCore::Frame*, | |
85 const WebCore::String& message, | |
86 const WebCore::String& defaultValue, | |
87 WebCore::String& result); | |
88 | |
89 virtual void setStatusbarText(const WebCore::String& message); | |
90 virtual bool shouldInterruptJavaScript(); | |
91 | |
92 // Returns true if anchors should accept keyboard focus with the tab key. | |
93 // This method is used in a convoluted fashion by EventHandler::tabsToLinks. | |
94 // It's a twisted path (self-evident, but more complicated than seems | |
95 // necessary), but the net result is that returning true from here, on a | |
96 // platform other than MAC or QT, lets anchors get keyboard focus. | |
97 virtual bool tabsToLinks() const; | |
98 | |
99 virtual WebCore::IntRect windowResizerRect() const; | |
100 | |
101 virtual void repaint(const WebCore::IntRect&, bool contentChanged, | |
102 bool immediate = false, bool repaintContentOnly = false); | |
103 virtual void scroll(const WebCore::IntSize& scrollDelta, | |
104 const WebCore::IntRect& rectToScroll, | |
105 const WebCore::IntRect& clipRect); | |
106 virtual WebCore::IntPoint screenToWindow(const WebCore::IntPoint&) const; | |
107 virtual WebCore::IntRect windowToScreen(const WebCore::IntRect&) const; | |
108 virtual PlatformPageClient platformPageClient() const { return NULL; } | |
109 virtual void contentsSizeChanged(WebCore::Frame*, | |
110 const WebCore::IntSize&) const; | |
111 virtual void scrollRectIntoView(const WebCore::IntRect&, const WebCore::ScrollView*) const { } | |
112 | |
113 virtual void scrollbarsModeDidChange() const; | |
114 virtual void mouseDidMoveOverElement(const WebCore::HitTestResult& result, | |
115 unsigned modifierFlags); | |
116 | |
117 virtual void setToolTip(const WebCore::String& tooltip_text, | |
118 WebCore::TextDirection dir); | |
119 | |
120 virtual void print(WebCore::Frame*); | |
121 | |
122 virtual void exceededDatabaseQuota(WebCore::Frame*, | |
123 const WebCore::String& databaseName); | |
124 | |
125 #if ENABLE(OFFLINE_WEB_APPLICATIONS) | |
126 virtual void reachedMaxAppCacheSize(int64_t space_needed); | |
127 #endif | |
128 | |
129 virtual void requestGeolocationPermissionForFrame(WebCore::Frame*, WebCore::Geolocation*) { } | |
130 | |
131 virtual void runOpenPanel(WebCore::Frame*, | |
132 PassRefPtr<WebCore::FileChooser>); | |
133 virtual bool setCursor(WebCore::PlatformCursorHandle) { return false; } | |
134 virtual void popupOpened(WebCore::PopupContainer* popup_container, | |
135 const WebCore::IntRect& bounds, | |
136 bool activatable, | |
137 bool handle_externally); | |
138 | |
139 void SetCursor(const WebKit::WebCursorInfo& cursor); | |
140 void SetCursorForPlugin(const WebKit::WebCursorInfo& cursor); | |
141 | |
142 virtual void formStateDidChange(const WebCore::Node*); | |
143 | |
144 virtual PassOwnPtr<WebCore::HTMLParserQuirks> createHTMLParserQuirks() { return 0; } | |
145 | |
146 #if ENABLE(NOTIFICATIONS) | |
147 virtual WebCore::NotificationPresenter* notificationPresenter() const; | |
148 #endif | |
149 | |
150 private: | |
151 void GetPopupMenuInfo(WebCore::PopupContainer* popup_container, | |
152 WebKit::WebPopupMenuInfo* info); | |
153 | |
154 WebViewImpl* webview_; // weak pointer | |
155 bool toolbars_visible_; | |
156 bool statusbar_visible_; | |
157 bool scrollbars_visible_; | |
158 bool menubar_visible_; | |
159 bool resizable_; | |
160 // Set to true if the next SetCursor is to be ignored. | |
161 bool ignore_next_set_cursor_; | |
162 }; | 151 }; |
163 | 152 |
164 #endif // WEBKIT_GLUE_CHROME_CLIENT_IMPL_H_ | 153 } // namespace WebKit |
| 154 |
| 155 #endif |
OLD | NEW |