| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // WebCore provides hooks for several kinds of functionality, allowing separate | 5 // WebCore provides hooks for several kinds of functionality, allowing separate |
| 6 // classes termed "delegates" to receive notifications (in the form of direct | 6 // classes termed "delegates" to receive notifications (in the form of direct |
| 7 // function calls) when certain events are about to occur or have just occurred. | 7 // function calls) when certain events are about to occur or have just occurred. |
| 8 // In some cases, the delegate implements the needed functionality; in others, | 8 // In some cases, the delegate implements the needed functionality; in others, |
| 9 // the delegate has some control over the behavior but doesn't actually | 9 // the delegate has some control over the behavior but doesn't actually |
| 10 // implement it. For example, the UI delegate is responsible for showing a | 10 // implement it. For example, the UI delegate is responsible for showing a |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 // PolicyDelegate, FrameLoadDelegate, and EditorDelegate; additional portions | 22 // PolicyDelegate, FrameLoadDelegate, and EditorDelegate; additional portions |
| 23 // of ChromeClient and FrameLoaderClient not delegated in the WebKit | 23 // of ChromeClient and FrameLoaderClient not delegated in the WebKit |
| 24 // implementation; and some WebView additions. | 24 // implementation; and some WebView additions. |
| 25 | 25 |
| 26 #ifndef WEBKIT_GLUE_WEBVIEW_DELEGATE_H_ | 26 #ifndef WEBKIT_GLUE_WEBVIEW_DELEGATE_H_ |
| 27 #define WEBKIT_GLUE_WEBVIEW_DELEGATE_H_ | 27 #define WEBKIT_GLUE_WEBVIEW_DELEGATE_H_ |
| 28 | 28 |
| 29 #include <vector> | 29 #include <vector> |
| 30 | 30 |
| 31 #include "base/gfx/native_widget_types.h" | 31 #include "base/gfx/native_widget_types.h" |
| 32 #include "webkit/api/public/WebNavigationPolicy.h" |
| 32 #include "webkit/api/public/WebNavigationType.h" | 33 #include "webkit/api/public/WebNavigationType.h" |
| 34 #include "webkit/api/public/WebWidgetClient.h" |
| 33 #include "webkit/glue/context_menu.h" | 35 #include "webkit/glue/context_menu.h" |
| 34 #include "webkit/glue/webwidget_delegate.h" | |
| 35 | 36 |
| 36 namespace webkit_glue { | 37 namespace webkit_glue { |
| 37 class WebMediaPlayerDelegate; | 38 class WebMediaPlayerDelegate; |
| 38 } | 39 } |
| 39 | 40 |
| 40 namespace WebCore { | 41 namespace WebCore { |
| 41 class AccessibilityObject; | 42 class AccessibilityObject; |
| 42 } | 43 } |
| 43 | 44 |
| 44 namespace WebKit { | 45 namespace WebKit { |
| 45 class WebDataSource; | 46 class WebDataSource; |
| 46 class WebDragData; | 47 class WebDragData; |
| 47 class WebForm; | 48 class WebForm; |
| 48 class WebWorker; | 49 class WebWorker; |
| 49 class WebWorkerClient; | 50 class WebWorkerClient; |
| 50 class WebMediaPlayer; | 51 class WebMediaPlayer; |
| 51 class WebMediaPlayerClient; | 52 class WebMediaPlayerClient; |
| 52 class WebURLRequest; | 53 class WebURLRequest; |
| 53 class WebURLResponse; | 54 class WebURLResponse; |
| 55 class WebWidget; |
| 54 struct WebPoint; | 56 struct WebPoint; |
| 55 struct WebPopupMenuInfo; | 57 struct WebPopupMenuInfo; |
| 56 struct WebRect; | 58 struct WebRect; |
| 57 struct WebURLError; | 59 struct WebURLError; |
| 58 } | 60 } |
| 59 | 61 |
| 60 struct WebPreferences; | |
| 61 class FilePath; | 62 class FilePath; |
| 62 class SkBitmap; | 63 class SkBitmap; |
| 63 class WebDevToolsAgentDelegate; | 64 class WebDevToolsAgentDelegate; |
| 64 class WebFrame; | 65 class WebFrame; |
| 65 class WebMediaPlayerDelegate; | 66 class WebMediaPlayerDelegate; |
| 66 class WebPluginDelegate; | 67 class WebPluginDelegate; |
| 67 class WebView; | 68 class WebView; |
| 68 class WebWidget; | 69 struct WebPluginGeometry; |
| 70 struct WebPreferences; |
| 69 | 71 |
| 70 enum NavigationGesture { | 72 enum NavigationGesture { |
| 71 NavigationGestureUser, // User initiated navigation/load. This is not | 73 NavigationGestureUser, // User initiated navigation/load. This is not |
| 72 // currently used due to the untrustworthy nature | 74 // currently used due to the untrustworthy nature |
| 73 // of userGestureHint (wasRunByUserGesture). See | 75 // of userGestureHint (wasRunByUserGesture). See |
| 74 // bug 1051891. | 76 // bug 1051891. |
| 75 NavigationGestureAuto, // Non-user initiated navigation / load. For example | 77 NavigationGestureAuto, // Non-user initiated navigation / load. For example |
| 76 // onload or setTimeout triggered document.location | 78 // onload or setTimeout triggered document.location |
| 77 // changes, and form.submits. See bug 1046841 for | 79 // changes, and form.submits. See bug 1046841 for |
| 78 // some cases that should be treated this way but | 80 // some cases that should be treated this way but |
| (...skipping 10 matching lines...) Expand all Loading... |
| 89 WebFileChooserCallback() {} | 91 WebFileChooserCallback() {} |
| 90 virtual ~WebFileChooserCallback() {} | 92 virtual ~WebFileChooserCallback() {} |
| 91 virtual void OnFileChoose(const std::vector<FilePath>& file_names) { } | 93 virtual void OnFileChoose(const std::vector<FilePath>& file_names) { } |
| 92 | 94 |
| 93 private: | 95 private: |
| 94 DISALLOW_COPY_AND_ASSIGN(WebFileChooserCallback); | 96 DISALLOW_COPY_AND_ASSIGN(WebFileChooserCallback); |
| 95 }; | 97 }; |
| 96 | 98 |
| 97 | 99 |
| 98 // Inheritance here is somewhat weird, but since a WebView is a WebWidget, | 100 // Inheritance here is somewhat weird, but since a WebView is a WebWidget, |
| 99 // it makes sense that a WebViewDelegate is a WebWidgetDelegate. | 101 // it makes sense that a WebViewDelegate is a WebWidgetClient. |
| 100 class WebViewDelegate : virtual public WebWidgetDelegate { | 102 class WebViewDelegate : virtual public WebKit::WebWidgetClient { |
| 101 public: | 103 public: |
| 102 // WebView additions ------------------------------------------------------- | 104 // WebView additions ------------------------------------------------------- |
| 103 | 105 |
| 104 // This method is called to create a new WebView. The WebView should not be | 106 // This method is called to create a new WebView. The WebView should not be |
| 105 // made visible until the new WebView's Delegate has its Show method called. | 107 // made visible until the new WebView's Delegate has its Show method called. |
| 106 // The returned WebView pointer is assumed to be owned by the host window, | 108 // The returned WebView pointer is assumed to be owned by the host window, |
| 107 // and the caller of CreateWebView should not release the given WebView. | 109 // and the caller of CreateWebView should not release the given WebView. |
| 108 // |user_gesture| is true if a user action initiated this call. | 110 // |user_gesture| is true if a user action initiated this call. |
| 109 // |creator_url|, if nonempty, holds the security origin of the page creating | 111 // |creator_url|, if nonempty, holds the security origin of the page creating |
| 110 // this WebView. | 112 // this WebView. |
| 111 virtual WebView* CreateWebView(WebView* webview, | 113 virtual WebView* CreateWebView(WebView* webview, |
| 112 bool user_gesture, | 114 bool user_gesture, |
| 113 const GURL& creator_url) { | 115 const GURL& creator_url) { |
| 114 return NULL; | 116 return NULL; |
| 115 } | 117 } |
| 116 | 118 |
| 117 // This method is called to create a new WebWidget to act as a popup | 119 // This method is called to create a new WebWidget to act as a popup |
| 118 // (like a drop-down menu). | 120 // (like a drop-down menu). |
| 119 virtual WebWidget* CreatePopupWidget(WebView* webview, bool activatable) { | 121 virtual WebKit::WebWidget* CreatePopupWidget( |
| 122 WebView* webview, |
| 123 bool activatable) { |
| 120 return NULL; | 124 return NULL; |
| 121 } | 125 } |
| 122 | 126 |
| 123 // Like CreatePopupWidget, except the actual widget is rendered by the | 127 // Like CreatePopupWidget, except the actual widget is rendered by the |
| 124 // embedder using the supplied info. | 128 // embedder using the supplied info. |
| 125 virtual WebWidget* CreatePopupWidgetWithInfo( | 129 virtual WebKit::WebWidget* CreatePopupWidgetWithInfo( |
| 126 WebView* webview, | 130 WebView* webview, |
| 127 const WebKit::WebPopupMenuInfo& info) { | 131 const WebKit::WebPopupMenuInfo& info) { |
| 128 return NULL; | 132 return NULL; |
| 129 } | 133 } |
| 130 | 134 |
| 131 // This method is called to create a WebPluginDelegate implementation when a | 135 // This method is called to create a WebPluginDelegate implementation when a |
| 132 // new plugin is instanced. See webkit_glue::CreateWebPluginDelegateHelper | 136 // new plugin is instanced. See webkit_glue::CreateWebPluginDelegateHelper |
| 133 // for a default WebPluginDelegate implementation. | 137 // for a default WebPluginDelegate implementation. |
| 134 // TODO(port): clsid is very Win- and ActiveX-specific; refactor to be more | 138 // TODO(port): clsid is very Win- and ActiveX-specific; refactor to be more |
| 135 // platform-neutral | 139 // platform-neutral |
| (...skipping 21 matching lines...) Expand all Loading... |
| 157 | 161 |
| 158 // Called when a WebMediaPlayer is needed. | 162 // Called when a WebMediaPlayer is needed. |
| 159 virtual WebKit::WebMediaPlayer* CreateWebMediaPlayer( | 163 virtual WebKit::WebMediaPlayer* CreateWebMediaPlayer( |
| 160 WebKit::WebMediaPlayerClient* client) { | 164 WebKit::WebMediaPlayerClient* client) { |
| 161 return NULL; | 165 return NULL; |
| 162 } | 166 } |
| 163 | 167 |
| 164 // This method is called to open a URL in the specified manner. | 168 // This method is called to open a URL in the specified manner. |
| 165 virtual void OpenURL(WebView* webview, const GURL& url, | 169 virtual void OpenURL(WebView* webview, const GURL& url, |
| 166 const GURL& referrer, | 170 const GURL& referrer, |
| 167 WindowOpenDisposition disposition) { | 171 WebKit::WebNavigationPolicy policy) { |
| 168 } | 172 } |
| 169 | 173 |
| 170 // Notifies how many matches have been found so far, for a given request_id. | 174 // Notifies how many matches have been found so far, for a given request_id. |
| 171 // |final_update| specifies whether this is the last update (all frames have | 175 // |final_update| specifies whether this is the last update (all frames have |
| 172 // completed scoping). | 176 // completed scoping). |
| 173 virtual void ReportFindInPageMatchCount(int count, int request_id, | 177 virtual void ReportFindInPageMatchCount(int count, int request_id, |
| 174 bool final_update) { | 178 bool final_update) { |
| 175 } | 179 } |
| 176 | 180 |
| 177 // Notifies the browser what tick-mark rect is currently selected. Parameter | 181 // Notifies the browser what tick-mark rect is currently selected. Parameter |
| (...skipping 12 matching lines...) Expand all Loading... |
| 190 return true; | 194 return true; |
| 191 } | 195 } |
| 192 | 196 |
| 193 // Called by ChromeClientImpl::focus() if accessibility on the renderer side | 197 // Called by ChromeClientImpl::focus() if accessibility on the renderer side |
| 194 // is enabled, and a focus change has occurred. Will retrieve the id of the | 198 // is enabled, and a focus change has occurred. Will retrieve the id of the |
| 195 // input AccessibilityObject and send it through IPC for handling on the | 199 // input AccessibilityObject and send it through IPC for handling on the |
| 196 // browser side. | 200 // browser side. |
| 197 virtual void FocusAccessibilityObject(WebCore::AccessibilityObject* acc_obj) { | 201 virtual void FocusAccessibilityObject(WebCore::AccessibilityObject* acc_obj) { |
| 198 } | 202 } |
| 199 | 203 |
| 204 // Keeps track of the necessary window move for a plugin window that resulted |
| 205 // from a scroll operation. That way, all plugin windows can be moved at the |
| 206 // same time as each other and the page. |
| 207 virtual void DidMovePlugin(const WebPluginGeometry& move) { |
| 208 } |
| 209 |
| 200 // FrameLoaderClient ------------------------------------------------------- | 210 // FrameLoaderClient ------------------------------------------------------- |
| 201 | 211 |
| 202 virtual bool CanAcceptLoadDrops() const { | 212 virtual bool CanAcceptLoadDrops() const { |
| 203 // Always return true here so layout tests (which use the default WebView | 213 // Always return true here so layout tests (which use the default WebView |
| 204 // delegate) continue to pass. | 214 // delegate) continue to pass. |
| 205 return true; | 215 return true; |
| 206 } | 216 } |
| 207 | 217 |
| 208 // Notifies the delegate that a load has begun. | 218 // Notifies the delegate that a load has begun. |
| 209 virtual void DidStartLoading(WebView* webview) { | 219 virtual void DidStartLoading(WebView* webview) { |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 // Notifies that a garbage-collected context was created - content scripts. | 251 // Notifies that a garbage-collected context was created - content scripts. |
| 242 virtual void DidCreateIsolatedScriptContext(WebFrame* webframe) { | 252 virtual void DidCreateIsolatedScriptContext(WebFrame* webframe) { |
| 243 } | 253 } |
| 244 | 254 |
| 245 // PolicyDelegate ---------------------------------------------------------- | 255 // PolicyDelegate ---------------------------------------------------------- |
| 246 | 256 |
| 247 // This method is called to notify the delegate, and let it modify a | 257 // This method is called to notify the delegate, and let it modify a |
| 248 // proposed navigation. It will be called before loading starts, and | 258 // proposed navigation. It will be called before loading starts, and |
| 249 // on every redirect. | 259 // on every redirect. |
| 250 // | 260 // |
| 251 // disposition specifies what should normally happen for this | 261 // default_policy specifies what should normally happen for this |
| 252 // navigation (open in current tab, start a new tab, start a new | 262 // navigation (open in current tab, start a new tab, start a new |
| 253 // window, etc). This method can return an altered disposition, and | 263 // window, etc). This method can return an altered policy, and |
| 254 // take any additional separate action it wants to. | 264 // take any additional separate action it wants to. |
| 255 // | 265 // |
| 256 // is_redirect is true if this is a redirect rather than user action. | 266 // is_redirect is true if this is a redirect rather than user action. |
| 257 virtual WindowOpenDisposition DispositionForNavigationAction( | 267 virtual WebKit::WebNavigationPolicy PolicyForNavigationAction( |
| 258 WebView* webview, | 268 WebView* webview, |
| 259 WebFrame* frame, | 269 WebFrame* frame, |
| 260 const WebKit::WebURLRequest& request, | 270 const WebKit::WebURLRequest& request, |
| 261 WebKit::WebNavigationType type, | 271 WebKit::WebNavigationType type, |
| 262 WindowOpenDisposition disposition, | 272 WebKit::WebNavigationPolicy default_policy, |
| 263 bool is_redirect) { | 273 bool is_redirect) { |
| 264 return disposition; | 274 return default_policy; |
| 265 } | 275 } |
| 266 | 276 |
| 267 // FrameLoadDelegate ------------------------------------------------------- | 277 // FrameLoadDelegate ------------------------------------------------------- |
| 268 | 278 |
| 269 // A datasource has been created for a new navigation. The given datasource | 279 // A datasource has been created for a new navigation. The given datasource |
| 270 // will become the provisional datasource for the frame. | 280 // will become the provisional datasource for the frame. |
| 271 virtual void DidCreateDataSource(WebFrame* frame, | 281 virtual void DidCreateDataSource(WebFrame* frame, |
| 272 WebKit::WebDataSource* ds) { | 282 WebKit::WebDataSource* ds) { |
| 273 } | 283 } |
| 274 | 284 |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 518 virtual void QueryFormFieldAutofill(const std::wstring& field_name, | 528 virtual void QueryFormFieldAutofill(const std::wstring& field_name, |
| 519 const std::wstring& text, | 529 const std::wstring& text, |
| 520 int64 node_id) { | 530 int64 node_id) { |
| 521 } | 531 } |
| 522 | 532 |
| 523 // Instructs the browser to remove the autofill entry specified from it DB. | 533 // Instructs the browser to remove the autofill entry specified from it DB. |
| 524 virtual void RemoveStoredAutofillEntry(const std::wstring& name, | 534 virtual void RemoveStoredAutofillEntry(const std::wstring& name, |
| 525 const std::wstring& value) { | 535 const std::wstring& value) { |
| 526 } | 536 } |
| 527 | 537 |
| 528 virtual void DidContentsSizeChange(WebWidget* webwidget, int new_width, | 538 virtual void DidContentsSizeChange(WebKit::WebWidget* webwidget, |
| 529 int new_height) { | 539 int new_width, int new_height) { |
| 530 } | 540 } |
| 531 | 541 |
| 532 // UIDelegate -------------------------------------------------------------- | 542 // UIDelegate -------------------------------------------------------------- |
| 533 | 543 |
| 534 // Asks the browser to show a modal HTML dialog. The dialog is passed the | 544 // Asks the browser to show a modal HTML dialog. The dialog is passed the |
| 535 // given arguments as a JSON string, and returns its result as a JSON string | 545 // given arguments as a JSON string, and returns its result as a JSON string |
| 536 // through json_retval. | 546 // through json_retval. |
| 537 virtual void ShowModalHTMLDialog(const GURL& url, int width, int height, | 547 virtual void ShowModalHTMLDialog(const GURL& url, int width, int height, |
| 538 const std::string& json_arguments, | 548 const std::string& json_arguments, |
| 539 std::string* json_retval) { | 549 std::string* json_retval) { |
| (...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 831 virtual void DidAddHistoryItem() { } | 841 virtual void DidAddHistoryItem() { } |
| 832 | 842 |
| 833 WebViewDelegate() { } | 843 WebViewDelegate() { } |
| 834 virtual ~WebViewDelegate() { } | 844 virtual ~WebViewDelegate() { } |
| 835 | 845 |
| 836 private: | 846 private: |
| 837 DISALLOW_COPY_AND_ASSIGN(WebViewDelegate); | 847 DISALLOW_COPY_AND_ASSIGN(WebViewDelegate); |
| 838 }; | 848 }; |
| 839 | 849 |
| 840 #endif // WEBKIT_GLUE_WEBVIEW_DELEGATE_H_ | 850 #endif // WEBKIT_GLUE_WEBVIEW_DELEGATE_H_ |
| OLD | NEW |