| 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 // TestWebViewDelegate class: | 5 // TestWebViewDelegate class: |
| 6 // This class implements the WebViewDelegate methods for the test shell. One | 6 // This class implements the WebViewDelegate methods for the test shell. One |
| 7 // instance is owned by each TestShell. | 7 // instance is owned by each TestShell. |
| 8 | 8 |
| 9 #ifndef WEBKIT_TOOLS_TEST_SHELL_TEST_WEBVIEW_DELEGATE_H_ | 9 #ifndef WEBKIT_TOOLS_TEST_SHELL_TEST_WEBVIEW_DELEGATE_H_ |
| 10 #define WEBKIT_TOOLS_TEST_SHELL_TEST_WEBVIEW_DELEGATE_H_ | 10 #define WEBKIT_TOOLS_TEST_SHELL_TEST_WEBVIEW_DELEGATE_H_ |
| 11 | 11 |
| 12 #include "build/build_config.h" | 12 #include "build/build_config.h" |
| 13 | 13 |
| 14 #if defined(OS_WIN) | 14 #if defined(OS_WIN) |
| 15 #include <windows.h> | 15 #include <windows.h> |
| 16 #endif | 16 #endif |
| 17 | 17 |
| 18 #include <map> | 18 #include <map> |
| 19 | 19 |
| 20 #if defined(OS_LINUX) | 20 #if defined(OS_LINUX) |
| 21 #include <gdk/gdkcursor.h> | 21 #include <gdk/gdkcursor.h> |
| 22 #endif | 22 #endif |
| 23 | 23 |
| 24 #include "base/basictypes.h" | 24 #include "base/basictypes.h" |
| 25 #include "base/scoped_ptr.h" | 25 #include "base/scoped_ptr.h" |
| 26 #include "base/weak_ptr.h" | 26 #include "base/weak_ptr.h" |
| 27 #include "webkit/api/public/WebEditingClient.h" | 27 #include "webkit/api/public/WebEditingClient.h" |
| 28 #include "webkit/api/public/WebFrameClient.h" |
| 28 #if defined(OS_MACOSX) | 29 #if defined(OS_MACOSX) |
| 29 #include "webkit/api/public/WebRect.h" | 30 #include "webkit/api/public/WebRect.h" |
| 30 #include "webkit/api/public/WebPopupMenuInfo.h" | 31 #include "webkit/api/public/WebPopupMenuInfo.h" |
| 31 #endif | 32 #endif |
| 32 #include "webkit/glue/webcursor.h" | 33 #include "webkit/glue/webcursor.h" |
| 33 #include "webkit/glue/webplugin_page_delegate.h" | 34 #include "webkit/glue/webplugin_page_delegate.h" |
| 34 #include "webkit/glue/webview_delegate.h" | 35 #include "webkit/glue/webview_delegate.h" |
| 35 #if defined(OS_WIN) | 36 #if defined(OS_WIN) |
| 36 #include "webkit/tools/test_shell/drag_delegate.h" | 37 #include "webkit/tools/test_shell/drag_delegate.h" |
| 37 #include "webkit/tools/test_shell/drop_delegate.h" | 38 #include "webkit/tools/test_shell/drop_delegate.h" |
| 38 #endif | 39 #endif |
| 39 #include "webkit/tools/test_shell/test_navigation_controller.h" | 40 #include "webkit/tools/test_shell/test_navigation_controller.h" |
| 40 | 41 |
| 41 struct ContextMenuMediaParams; | 42 struct ContextMenuMediaParams; |
| 42 struct WebPreferences; | 43 struct WebPreferences; |
| 43 class GURL; | 44 class GURL; |
| 44 class TestShell; | 45 class TestShell; |
| 45 class WebWidgetHost; | 46 class WebWidgetHost; |
| 46 | 47 |
| 47 class TestWebViewDelegate : public WebViewDelegate, | 48 class TestWebViewDelegate : public WebViewDelegate, |
| 48 public WebKit::WebEditingClient, | 49 public WebKit::WebEditingClient, |
| 50 public WebKit::WebFrameClient, |
| 49 public webkit_glue::WebPluginPageDelegate, | 51 public webkit_glue::WebPluginPageDelegate, |
| 50 public base::SupportsWeakPtr<TestWebViewDelegate> { | 52 public base::SupportsWeakPtr<TestWebViewDelegate> { |
| 51 public: | 53 public: |
| 52 struct CapturedContextMenuEvent { | 54 struct CapturedContextMenuEvent { |
| 53 CapturedContextMenuEvent(ContextNodeType in_node_type, | 55 CapturedContextMenuEvent(ContextNodeType in_node_type, |
| 54 int in_x, | 56 int in_x, |
| 55 int in_y) | 57 int in_y) |
| 56 : node_type(in_node_type), | 58 : node_type(in_node_type), |
| 57 x(in_x), | 59 x(in_x), |
| 58 y(in_y) { | 60 y(in_y) { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 70 bool user_gesture, | 72 bool user_gesture, |
| 71 const GURL& creator_url); | 73 const GURL& creator_url); |
| 72 virtual WebKit::WebWidget* CreatePopupWidget( | 74 virtual WebKit::WebWidget* CreatePopupWidget( |
| 73 WebView* webview, | 75 WebView* webview, |
| 74 bool activatable); | 76 bool activatable); |
| 75 #if defined(OS_MACOSX) | 77 #if defined(OS_MACOSX) |
| 76 virtual WebKit::WebWidget* CreatePopupWidgetWithInfo( | 78 virtual WebKit::WebWidget* CreatePopupWidgetWithInfo( |
| 77 WebView* webview, | 79 WebView* webview, |
| 78 const WebKit::WebPopupMenuInfo& info); | 80 const WebKit::WebPopupMenuInfo& info); |
| 79 #endif | 81 #endif |
| 80 virtual WebKit::WebPlugin* CreatePlugin( | |
| 81 WebKit::WebFrame* frame, | |
| 82 const WebKit::WebPluginParams& params); | |
| 83 virtual WebKit::WebMediaPlayer* CreateWebMediaPlayer( | |
| 84 WebKit::WebMediaPlayerClient* client); | |
| 85 virtual WebKit::WebWorker* CreateWebWorker(WebKit::WebWorkerClient* client); | |
| 86 virtual void OpenURL(WebView* webview, | |
| 87 const GURL& url, | |
| 88 const GURL& referrer, | |
| 89 WebKit::WebNavigationPolicy policy); | |
| 90 virtual void RunJavaScriptAlert(WebKit::WebFrame* webframe, | 82 virtual void RunJavaScriptAlert(WebKit::WebFrame* webframe, |
| 91 const std::wstring& message); | 83 const std::wstring& message); |
| 92 virtual bool RunJavaScriptConfirm(WebKit::WebFrame* webframe, | 84 virtual bool RunJavaScriptConfirm(WebKit::WebFrame* webframe, |
| 93 const std::wstring& message); | 85 const std::wstring& message); |
| 94 virtual bool RunJavaScriptPrompt(WebKit::WebFrame* webframe, | 86 virtual bool RunJavaScriptPrompt(WebKit::WebFrame* webframe, |
| 95 const std::wstring& message, | 87 const std::wstring& message, |
| 96 const std::wstring& default_value, | 88 const std::wstring& default_value, |
| 97 std::wstring* result); | 89 std::wstring* result); |
| 98 | 90 |
| 99 virtual void SetStatusbarText(WebView* webview, | 91 virtual void SetStatusbarText(WebView* webview, |
| (...skipping 14 matching lines...) Expand all Loading... |
| 114 const GURL& link_url, | 106 const GURL& link_url, |
| 115 const GURL& image_url, | 107 const GURL& image_url, |
| 116 const GURL& page_url, | 108 const GURL& page_url, |
| 117 const GURL& frame_url, | 109 const GURL& frame_url, |
| 118 const ContextMenuMediaParams& media_params, | 110 const ContextMenuMediaParams& media_params, |
| 119 const std::wstring& selection_text, | 111 const std::wstring& selection_text, |
| 120 const std::wstring& misspelled_word, | 112 const std::wstring& misspelled_word, |
| 121 int edit_flags, | 113 int edit_flags, |
| 122 const std::string& security_info, | 114 const std::string& security_info, |
| 123 const std::string& frame_charset); | 115 const std::string& frame_charset); |
| 124 virtual void DidCreateDataSource(WebKit::WebFrame* frame, | |
| 125 WebKit::WebDataSource* ds); | |
| 126 virtual void DidStartProvisionalLoadForFrame( | |
| 127 WebView* webview, | |
| 128 WebKit::WebFrame* frame, | |
| 129 NavigationGesture gesture); | |
| 130 virtual void DidReceiveProvisionalLoadServerRedirect( | |
| 131 WebView* webview, WebKit::WebFrame* frame); | |
| 132 virtual void DidFailProvisionalLoadWithError( | |
| 133 WebView* webview, | |
| 134 const WebKit::WebURLError& error, | |
| 135 WebKit::WebFrame* frame); | |
| 136 virtual void DidCommitLoadForFrame( | |
| 137 WebView* webview, | |
| 138 WebKit::WebFrame* frame, | |
| 139 bool is_new_navigation); | |
| 140 virtual void DidReceiveTitle(WebView* webview, | |
| 141 const std::wstring& title, | |
| 142 WebKit::WebFrame* frame); | |
| 143 virtual void DidFinishDocumentLoadForFrame(WebView* webview, | |
| 144 WebKit::WebFrame* frame); | |
| 145 virtual void DidHandleOnloadEventsForFrame(WebView* webview, | |
| 146 WebKit::WebFrame* frame); | |
| 147 virtual void DidChangeLocationWithinPageForFrame(WebView* webview, | |
| 148 WebKit::WebFrame* frame, | |
| 149 bool is_new_navigation); | |
| 150 virtual void DidReceiveIconForFrame(WebView* webview, WebKit::WebFrame* frame)
; | 116 virtual void DidReceiveIconForFrame(WebView* webview, WebKit::WebFrame* frame)
; |
| 151 | |
| 152 virtual void WillPerformClientRedirect(WebView* webview, | |
| 153 WebKit::WebFrame* frame, | |
| 154 const GURL& src_url, | |
| 155 const GURL& dest_url, | |
| 156 unsigned int delay_seconds, | |
| 157 unsigned int fire_date); | |
| 158 virtual void DidCancelClientRedirect(WebView* webview, | |
| 159 WebKit::WebFrame* frame); | |
| 160 | |
| 161 virtual void DidFinishLoadForFrame(WebView* webview, WebKit::WebFrame* frame); | |
| 162 virtual void DidFailLoadWithError(WebView* webview, | |
| 163 const WebKit::WebURLError& error, | |
| 164 WebKit::WebFrame* for_frame); | |
| 165 | |
| 166 virtual void AssignIdentifierToRequest(WebKit::WebFrame* webframe, | |
| 167 uint32 identifier, | |
| 168 const WebKit::WebURLRequest& request); | |
| 169 virtual void WillSendRequest(WebKit::WebFrame* webframe, | |
| 170 uint32 identifier, | |
| 171 WebKit::WebURLRequest* request, | |
| 172 const WebKit::WebURLResponse& redirect_response); | |
| 173 virtual void DidReceiveResponse(WebKit::WebFrame* webframe, | |
| 174 uint32 identifier, | |
| 175 const WebKit::WebURLResponse& response); | |
| 176 virtual void DidFinishLoading(WebKit::WebFrame* webframe, uint32 identifier); | |
| 177 virtual void DidFailLoadingWithError(WebKit::WebFrame* webframe, | |
| 178 uint32 identifier, | |
| 179 const WebKit::WebURLError& error); | |
| 180 | |
| 181 #if 0 | |
| 182 virtual bool ShouldBeginEditing(WebView* webview, std::wstring range); | |
| 183 virtual bool ShouldEndEditing(WebView* webview, std::wstring range); | |
| 184 virtual bool ShouldInsertNode(WebView* webview, | |
| 185 std::wstring node, | |
| 186 std::wstring range, | |
| 187 std::wstring action); | |
| 188 virtual bool ShouldInsertText(WebView* webview, | |
| 189 std::wstring text, | |
| 190 std::wstring range, | |
| 191 std::wstring action); | |
| 192 virtual bool ShouldChangeSelectedRange(WebView* webview, | |
| 193 std::wstring fromRange, | |
| 194 std::wstring toRange, | |
| 195 std::wstring affinity, | |
| 196 bool stillSelecting); | |
| 197 virtual bool ShouldDeleteRange(WebView* webview, std::wstring range); | |
| 198 virtual bool ShouldApplyStyle(WebView* webview, | |
| 199 std::wstring style, | |
| 200 std::wstring range); | |
| 201 virtual bool SmartInsertDeleteEnabled(); | |
| 202 virtual bool IsSelectTrailingWhitespaceEnabled(); | |
| 203 virtual void DidBeginEditing(); | |
| 204 virtual void DidChangeSelection(bool is_empty_selection); | |
| 205 virtual void DidChangeContents(); | |
| 206 virtual void DidEndEditing(); | |
| 207 #endif | |
| 208 | |
| 209 virtual void WindowObjectCleared(WebKit::WebFrame* webframe); | |
| 210 virtual WebKit::WebNavigationPolicy PolicyForNavigationAction( | |
| 211 WebView* webview, | |
| 212 WebKit::WebFrame* frame, | |
| 213 const WebKit::WebURLRequest& request, | |
| 214 WebKit::WebNavigationType type, | |
| 215 WebKit::WebNavigationPolicy default_policy, | |
| 216 bool is_redirect); | |
| 217 virtual void NavigateBackForwardSoon(int offset); | 117 virtual void NavigateBackForwardSoon(int offset); |
| 218 virtual int GetHistoryBackListCount(); | 118 virtual int GetHistoryBackListCount(); |
| 219 virtual int GetHistoryForwardListCount(); | 119 virtual int GetHistoryForwardListCount(); |
| 220 | 120 |
| 221 // WebKit::WebWidgetClient | 121 // WebKit::WebWidgetClient |
| 222 virtual void didInvalidateRect(const WebKit::WebRect& rect); | 122 virtual void didInvalidateRect(const WebKit::WebRect& rect); |
| 223 virtual void didScrollRect(int dx, int dy, | 123 virtual void didScrollRect(int dx, int dy, |
| 224 const WebKit::WebRect& clip_rect); | 124 const WebKit::WebRect& clip_rect); |
| 225 virtual void didFocus(); | 125 virtual void didFocus(); |
| 226 virtual void didBlur(); | 126 virtual void didBlur(); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 251 const WebKit::WebString& style, const WebKit::WebRange& range); | 151 const WebKit::WebString& style, const WebKit::WebRange& range); |
| 252 virtual bool isSmartInsertDeleteEnabled(); | 152 virtual bool isSmartInsertDeleteEnabled(); |
| 253 virtual bool isSelectTrailingWhitespaceEnabled(); | 153 virtual bool isSelectTrailingWhitespaceEnabled(); |
| 254 virtual void setInputMethodEnabled(bool enabled) {} | 154 virtual void setInputMethodEnabled(bool enabled) {} |
| 255 virtual void didBeginEditing(); | 155 virtual void didBeginEditing(); |
| 256 virtual void didChangeSelection(bool is_selection_empty); | 156 virtual void didChangeSelection(bool is_selection_empty); |
| 257 virtual void didChangeContents(); | 157 virtual void didChangeContents(); |
| 258 virtual void didExecuteCommand(const WebKit::WebString& command_name) {} | 158 virtual void didExecuteCommand(const WebKit::WebString& command_name) {} |
| 259 virtual void didEndEditing(); | 159 virtual void didEndEditing(); |
| 260 | 160 |
| 161 // WebKit::WebFrameClient |
| 162 virtual WebKit::WebPlugin* createPlugin( |
| 163 WebKit::WebFrame*, const WebKit::WebPluginParams&); |
| 164 virtual WebKit::WebWorker* createWorker( |
| 165 WebKit::WebFrame*, WebKit::WebWorkerClient*); |
| 166 virtual WebKit::WebMediaPlayer* createMediaPlayer( |
| 167 WebKit::WebFrame*, WebKit::WebMediaPlayerClient*); |
| 168 virtual void willClose(WebKit::WebFrame*); |
| 169 virtual void loadURLExternally( |
| 170 WebKit::WebFrame*, const WebKit::WebURLRequest&, |
| 171 WebKit::WebNavigationPolicy); |
| 172 virtual WebKit::WebNavigationPolicy decidePolicyForNavigation( |
| 173 WebKit::WebFrame*, const WebKit::WebURLRequest&, |
| 174 WebKit::WebNavigationType, WebKit::WebNavigationPolicy default_policy, |
| 175 bool isRedirect); |
| 176 virtual void willSubmitForm(WebKit::WebFrame*, const WebKit::WebForm&); |
| 177 virtual void willPerformClientRedirect( |
| 178 WebKit::WebFrame*, const WebKit::WebURL& from, const WebKit::WebURL& to, |
| 179 double interval, double fire_time); |
| 180 virtual void didCancelClientRedirect(WebKit::WebFrame*); |
| 181 virtual void didCompleteClientRedirect( |
| 182 WebKit::WebFrame*, const WebKit::WebURL& from); |
| 183 virtual void didCreateDataSource( |
| 184 WebKit::WebFrame*, WebKit::WebDataSource*); |
| 185 virtual void didStartProvisionalLoad(WebKit::WebFrame*); |
| 186 virtual void didReceiveServerRedirectForProvisionalLoad(WebKit::WebFrame*); |
| 187 virtual void didFailProvisionalLoad( |
| 188 WebKit::WebFrame*, const WebKit::WebURLError&); |
| 189 virtual void didReceiveDocumentData( |
| 190 WebKit::WebFrame*, const char* data, size_t length, |
| 191 bool& preventDefault); |
| 192 virtual void didCommitProvisionalLoad( |
| 193 WebKit::WebFrame*, bool is_new_navigation); |
| 194 virtual void didClearWindowObject(WebKit::WebFrame*); |
| 195 virtual void didCreateDocumentElement(WebKit::WebFrame*); |
| 196 virtual void didReceiveTitle( |
| 197 WebKit::WebFrame*, const WebKit::WebString& title); |
| 198 virtual void didFinishDocumentLoad(WebKit::WebFrame*); |
| 199 virtual void didHandleOnloadEvents(WebKit::WebFrame*); |
| 200 virtual void didFailLoad( |
| 201 WebKit::WebFrame*, const WebKit::WebURLError&); |
| 202 virtual void didFinishLoad(WebKit::WebFrame*); |
| 203 virtual void didChangeLocationWithinPage( |
| 204 WebKit::WebFrame*, bool isNewNavigation); |
| 205 virtual void assignIdentifierToRequest( |
| 206 WebKit::WebFrame*, unsigned identifier, const WebKit::WebURLRequest&); |
| 207 virtual void willSendRequest( |
| 208 WebKit::WebFrame*, unsigned identifier, WebKit::WebURLRequest&, |
| 209 const WebKit::WebURLResponse& redirectResponse); |
| 210 virtual void didReceiveResponse( |
| 211 WebKit::WebFrame*, unsigned identifier, const WebKit::WebURLResponse&); |
| 212 virtual void didFinishResourceLoad( |
| 213 WebKit::WebFrame*, unsigned identifier); |
| 214 virtual void didFailResourceLoad( |
| 215 WebKit::WebFrame*, unsigned identifier, const WebKit::WebURLError&); |
| 216 virtual void didLoadResourceFromMemoryCache( |
| 217 WebKit::WebFrame*, const WebKit::WebURLRequest&, |
| 218 const WebKit::WebURLResponse&); |
| 219 virtual void didExhaustMemoryAvailableForScript(WebKit::WebFrame*); |
| 220 virtual void didChangeContentsSize( |
| 221 WebKit::WebFrame*, const WebKit::WebSize&); |
| 222 |
| 261 // webkit_glue::WebPluginPageDelegate | 223 // webkit_glue::WebPluginPageDelegate |
| 262 virtual webkit_glue::WebPluginDelegate* CreatePluginDelegate( | 224 virtual webkit_glue::WebPluginDelegate* CreatePluginDelegate( |
| 263 const GURL& url, | 225 const GURL& url, |
| 264 const std::string& mime_type, | 226 const std::string& mime_type, |
| 265 std::string* actual_mime_type); | 227 std::string* actual_mime_type); |
| 266 virtual void CreatedPluginWindow( | 228 virtual void CreatedPluginWindow( |
| 267 gfx::PluginWindowHandle handle); | 229 gfx::PluginWindowHandle handle); |
| 268 virtual void WillDestroyPluginWindow( | 230 virtual void WillDestroyPluginWindow( |
| 269 gfx::PluginWindowHandle handle); | 231 gfx::PluginWindowHandle handle); |
| 270 virtual void DidMovePlugin( | 232 virtual void DidMovePlugin( |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 412 // true if we want to enable selection of trailing whitespaces | 374 // true if we want to enable selection of trailing whitespaces |
| 413 bool select_trailing_whitespace_enabled_; | 375 bool select_trailing_whitespace_enabled_; |
| 414 | 376 |
| 415 // true if we should block any redirects | 377 // true if we should block any redirects |
| 416 bool block_redirects_; | 378 bool block_redirects_; |
| 417 | 379 |
| 418 DISALLOW_COPY_AND_ASSIGN(TestWebViewDelegate); | 380 DISALLOW_COPY_AND_ASSIGN(TestWebViewDelegate); |
| 419 }; | 381 }; |
| 420 | 382 |
| 421 #endif // WEBKIT_TOOLS_TEST_SHELL_TEST_WEBVIEW_DELEGATE_H_ | 383 #endif // WEBKIT_TOOLS_TEST_SHELL_TEST_WEBVIEW_DELEGATE_H_ |
| OLD | NEW |