| 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 #include <map> | 18 #include <map> |
| 18 | 19 |
| 19 #if defined(OS_LINUX) | 20 #if defined(OS_LINUX) |
| 20 #include <gdk/gdkcursor.h> | 21 #include <gdk/gdkcursor.h> |
| 21 #endif | 22 #endif |
| 22 | 23 |
| 23 #include "base/basictypes.h" | 24 #include "base/basictypes.h" |
| 24 #include "base/linked_ptr.h" | 25 #include "base/scoped_ptr.h" |
| 26 #include "base/weak_ptr.h" |
| 25 #if defined(OS_MACOSX) | 27 #if defined(OS_MACOSX) |
| 26 #include "webkit/api/public/WebRect.h" | 28 #include "webkit/api/public/WebRect.h" |
| 27 #include "webkit/api/public/WebPopupMenuInfo.h" | 29 #include "webkit/api/public/WebPopupMenuInfo.h" |
| 28 #endif | 30 #endif |
| 29 #include "webkit/glue/webcursor.h" | 31 #include "webkit/glue/webcursor.h" |
| 32 #include "webkit/glue/webplugin_page_delegate.h" |
| 30 #include "webkit/glue/webview_delegate.h" | 33 #include "webkit/glue/webview_delegate.h" |
| 31 #if defined(OS_WIN) | 34 #if defined(OS_WIN) |
| 32 #include "webkit/tools/test_shell/drag_delegate.h" | 35 #include "webkit/tools/test_shell/drag_delegate.h" |
| 33 #include "webkit/tools/test_shell/drop_delegate.h" | 36 #include "webkit/tools/test_shell/drop_delegate.h" |
| 34 #endif | 37 #endif |
| 35 #include "webkit/tools/test_shell/test_navigation_controller.h" | 38 #include "webkit/tools/test_shell/test_navigation_controller.h" |
| 36 | 39 |
| 37 struct ContextMenuMediaParams; | 40 struct ContextMenuMediaParams; |
| 38 struct WebPreferences; | 41 struct WebPreferences; |
| 39 class GURL; | 42 class GURL; |
| 40 class TestShell; | 43 class TestShell; |
| 41 class WebWidgetHost; | 44 class WebWidgetHost; |
| 42 | 45 |
| 43 class TestWebViewDelegate : public WebViewDelegate { | 46 class TestWebViewDelegate : public WebViewDelegate, |
| 47 public webkit_glue::WebPluginPageDelegate, |
| 48 public base::SupportsWeakPtr<TestWebViewDelegate> { |
| 44 public: | 49 public: |
| 45 struct CapturedContextMenuEvent { | 50 struct CapturedContextMenuEvent { |
| 46 CapturedContextMenuEvent(ContextNodeType in_node_type, | 51 CapturedContextMenuEvent(ContextNodeType in_node_type, |
| 47 int in_x, | 52 int in_x, |
| 48 int in_y) | 53 int in_y) |
| 49 : node_type(in_node_type), | 54 : node_type(in_node_type), |
| 50 x(in_x), | 55 x(in_x), |
| 51 y(in_y) { | 56 y(in_y) { |
| 52 } | 57 } |
| 53 | 58 |
| 54 ContextNodeType node_type; | 59 ContextNodeType node_type; |
| 55 int x; | 60 int x; |
| 56 int y; | 61 int y; |
| 57 }; | 62 }; |
| 58 | 63 |
| 59 typedef std::vector<CapturedContextMenuEvent> CapturedContextMenuEvents; | 64 typedef std::vector<CapturedContextMenuEvent> CapturedContextMenuEvents; |
| 60 | 65 |
| 61 // WebViewDelegate | 66 // WebViewDelegate |
| 62 virtual WebView* CreateWebView(WebView* webview, | 67 virtual WebView* CreateWebView(WebView* webview, |
| 63 bool user_gesture, | 68 bool user_gesture, |
| 64 const GURL& creator_url); | 69 const GURL& creator_url); |
| 65 virtual WebKit::WebWidget* CreatePopupWidget( | 70 virtual WebKit::WebWidget* CreatePopupWidget( |
| 66 WebView* webview, | 71 WebView* webview, |
| 67 bool activatable); | 72 bool activatable); |
| 68 #if defined(OS_MACOSX) | 73 #if defined(OS_MACOSX) |
| 69 virtual WebKit::WebWidget* CreatePopupWidgetWithInfo( | 74 virtual WebKit::WebWidget* CreatePopupWidgetWithInfo( |
| 70 WebView* webview, | 75 WebView* webview, |
| 71 const WebKit::WebPopupMenuInfo& info); | 76 const WebKit::WebPopupMenuInfo& info); |
| 72 #endif | 77 #endif |
| 73 virtual WebPluginDelegate* CreatePluginDelegate( | 78 virtual WebKit::WebPlugin* CreatePlugin( |
| 74 WebView* webview, | 79 WebKit::WebFrame* frame, |
| 75 const GURL& url, | 80 const WebKit::WebPluginParams& params); |
| 76 const std::string& mime_type, | |
| 77 const std::string& clsid, | |
| 78 std::string* actual_mime_type); | |
| 79 #if defined(OS_LINUX) | |
| 80 virtual void CreatedPluginWindow(gfx::PluginWindowHandle id); | |
| 81 virtual void WillDestroyPluginWindow(gfx::PluginWindowHandle id); | |
| 82 #endif | |
| 83 virtual WebKit::WebMediaPlayer* CreateWebMediaPlayer( | 81 virtual WebKit::WebMediaPlayer* CreateWebMediaPlayer( |
| 84 WebKit::WebMediaPlayerClient* client); | 82 WebKit::WebMediaPlayerClient* client); |
| 85 virtual WebKit::WebWorker* CreateWebWorker(WebKit::WebWorkerClient* client); | 83 virtual WebKit::WebWorker* CreateWebWorker(WebKit::WebWorkerClient* client); |
| 86 virtual void OpenURL(WebView* webview, | 84 virtual void OpenURL(WebView* webview, |
| 87 const GURL& url, | 85 const GURL& url, |
| 88 const GURL& referrer, | 86 const GURL& referrer, |
| 89 WebKit::WebNavigationPolicy policy); | 87 WebKit::WebNavigationPolicy policy); |
| 90 virtual void DidMovePlugin(const WebPluginGeometry& move); | |
| 91 virtual void RunJavaScriptAlert(WebKit::WebFrame* webframe, | 88 virtual void RunJavaScriptAlert(WebKit::WebFrame* webframe, |
| 92 const std::wstring& message); | 89 const std::wstring& message); |
| 93 virtual bool RunJavaScriptConfirm(WebKit::WebFrame* webframe, | 90 virtual bool RunJavaScriptConfirm(WebKit::WebFrame* webframe, |
| 94 const std::wstring& message); | 91 const std::wstring& message); |
| 95 virtual bool RunJavaScriptPrompt(WebKit::WebFrame* webframe, | 92 virtual bool RunJavaScriptPrompt(WebKit::WebFrame* webframe, |
| 96 const std::wstring& message, | 93 const std::wstring& message, |
| 97 const std::wstring& default_value, | 94 const std::wstring& default_value, |
| 98 std::wstring* result); | 95 std::wstring* result); |
| 99 | 96 |
| 100 virtual void SetStatusbarText(WebView* webview, | 97 virtual void SetStatusbarText(WebView* webview, |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 virtual bool ShouldDeleteRange(WebView* webview, std::wstring range); | 192 virtual bool ShouldDeleteRange(WebView* webview, std::wstring range); |
| 196 virtual bool ShouldApplyStyle(WebView* webview, | 193 virtual bool ShouldApplyStyle(WebView* webview, |
| 197 std::wstring style, | 194 std::wstring style, |
| 198 std::wstring range); | 195 std::wstring range); |
| 199 virtual bool SmartInsertDeleteEnabled(); | 196 virtual bool SmartInsertDeleteEnabled(); |
| 200 virtual bool IsSelectTrailingWhitespaceEnabled(); | 197 virtual bool IsSelectTrailingWhitespaceEnabled(); |
| 201 virtual void DidBeginEditing(); | 198 virtual void DidBeginEditing(); |
| 202 virtual void DidChangeSelection(bool is_empty_selection); | 199 virtual void DidChangeSelection(bool is_empty_selection); |
| 203 virtual void DidChangeContents(); | 200 virtual void DidChangeContents(); |
| 204 virtual void DidEndEditing(); | 201 virtual void DidEndEditing(); |
| 205 | |
| 206 virtual void DidStartLoading(WebView* webview); | |
| 207 virtual void DidStopLoading(WebView* webview); | |
| 208 | |
| 209 virtual void WindowObjectCleared(WebKit::WebFrame* webframe); | 202 virtual void WindowObjectCleared(WebKit::WebFrame* webframe); |
| 210 virtual WebKit::WebNavigationPolicy PolicyForNavigationAction( | 203 virtual WebKit::WebNavigationPolicy PolicyForNavigationAction( |
| 211 WebView* webview, | 204 WebView* webview, |
| 212 WebKit::WebFrame* frame, | 205 WebKit::WebFrame* frame, |
| 213 const WebKit::WebURLRequest& request, | 206 const WebKit::WebURLRequest& request, |
| 214 WebKit::WebNavigationType type, | 207 WebKit::WebNavigationType type, |
| 215 WebKit::WebNavigationPolicy default_policy, | 208 WebKit::WebNavigationPolicy default_policy, |
| 216 bool is_redirect); | 209 bool is_redirect); |
| 217 virtual void NavigateBackForwardSoon(int offset); | 210 virtual void NavigateBackForwardSoon(int offset); |
| 218 virtual int GetHistoryBackListCount(); | 211 virtual int GetHistoryBackListCount(); |
| 219 virtual int GetHistoryForwardListCount(); | 212 virtual int GetHistoryForwardListCount(); |
| 220 | 213 |
| 221 // WebWidgetClient | 214 // WebWidgetClient |
| 222 virtual void didInvalidateRect(const WebKit::WebRect& rect); | 215 virtual void didInvalidateRect(const WebKit::WebRect& rect); |
| 223 virtual void didScrollRect(int dx, int dy, | 216 virtual void didScrollRect(int dx, int dy, |
| 224 const WebKit::WebRect& clip_rect); | 217 const WebKit::WebRect& clip_rect); |
| 225 virtual void didFocus(); | 218 virtual void didFocus(); |
| 226 virtual void didBlur(); | 219 virtual void didBlur(); |
| 227 virtual void didChangeCursor(const WebKit::WebCursorInfo& cursor); | 220 virtual void didChangeCursor(const WebKit::WebCursorInfo& cursor); |
| 228 virtual void closeWidgetSoon(); | 221 virtual void closeWidgetSoon(); |
| 229 virtual void show(WebKit::WebNavigationPolicy policy); | 222 virtual void show(WebKit::WebNavigationPolicy policy); |
| 230 virtual void runModal(); | 223 virtual void runModal(); |
| 231 virtual WebKit::WebRect windowRect(); | 224 virtual WebKit::WebRect windowRect(); |
| 232 virtual void setWindowRect(const WebKit::WebRect& rect); | 225 virtual void setWindowRect(const WebKit::WebRect& rect); |
| 233 virtual WebKit::WebRect rootWindowRect(); | 226 virtual WebKit::WebRect rootWindowRect(); |
| 234 virtual WebKit::WebRect windowResizerRect(); | 227 virtual WebKit::WebRect windowResizerRect(); |
| 235 virtual WebKit::WebScreenInfo screenInfo(); | 228 virtual WebKit::WebScreenInfo screenInfo(); |
| 236 | 229 |
| 230 // webkit_glue::WebPluginPageDelegate |
| 231 virtual webkit_glue::WebPluginDelegate* CreatePluginDelegate( |
| 232 const GURL& url, |
| 233 const std::string& mime_type, |
| 234 const std::string& clsid, |
| 235 std::string* actual_mime_type); |
| 236 virtual void CreatedPluginWindow( |
| 237 gfx::PluginWindowHandle handle); |
| 238 virtual void WillDestroyPluginWindow( |
| 239 gfx::PluginWindowHandle handle); |
| 240 virtual void DidMovePlugin( |
| 241 const webkit_glue::WebPluginGeometry& move); |
| 242 virtual void DidStartLoadingForPlugin() {} |
| 243 virtual void DidStopLoadingForPlugin() {} |
| 244 virtual void ShowModalHTMLDialogForPlugin( |
| 245 const GURL& url, |
| 246 const gfx::Size& size, |
| 247 const std::string& json_arguments, |
| 248 std::string* json_retval) {} |
| 249 |
| 237 TestWebViewDelegate(TestShell* shell); | 250 TestWebViewDelegate(TestShell* shell); |
| 251 ~TestWebViewDelegate(); |
| 238 void Reset(); | 252 void Reset(); |
| 239 | 253 |
| 240 void SetSmartInsertDeleteEnabled(bool enabled); | 254 void SetSmartInsertDeleteEnabled(bool enabled); |
| 241 void SetSelectTrailingWhitespaceEnabled(bool enabled); | 255 void SetSelectTrailingWhitespaceEnabled(bool enabled); |
| 242 | 256 |
| 243 // Additional accessors | 257 // Additional accessors |
| 244 WebKit::WebFrame* top_loading_frame() { return top_loading_frame_; } | 258 WebKit::WebFrame* top_loading_frame() { return top_loading_frame_; } |
| 245 #if defined(OS_WIN) | 259 #if defined(OS_WIN) |
| 246 IDropTarget* drop_delegate() { return drop_delegate_.get(); } | 260 IDropTarget* drop_delegate() { return drop_delegate_.get(); } |
| 247 IDropSource* drag_delegate() { return drag_delegate_.get(); } | 261 IDropSource* drag_delegate() { return drag_delegate_.get(); } |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 326 // Non-owning pointer. The delegate is owned by the host. | 340 // Non-owning pointer. The delegate is owned by the host. |
| 327 TestShell* shell_; | 341 TestShell* shell_; |
| 328 | 342 |
| 329 // This is non-NULL IFF a load is in progress. | 343 // This is non-NULL IFF a load is in progress. |
| 330 WebKit::WebFrame* top_loading_frame_; | 344 WebKit::WebFrame* top_loading_frame_; |
| 331 | 345 |
| 332 // For tracking session history. See RenderView. | 346 // For tracking session history. See RenderView. |
| 333 int page_id_; | 347 int page_id_; |
| 334 int last_page_id_updated_; | 348 int last_page_id_updated_; |
| 335 | 349 |
| 336 linked_ptr<TestShellExtraData> pending_extra_data_; | 350 scoped_ptr<TestShellExtraData> pending_extra_data_; |
| 337 | 351 |
| 338 // Maps resource identifiers to a descriptive string. | 352 // Maps resource identifiers to a descriptive string. |
| 339 typedef std::map<uint32, std::string> ResourceMap; | 353 typedef std::map<uint32, std::string> ResourceMap; |
| 340 ResourceMap resource_identifier_map_; | 354 ResourceMap resource_identifier_map_; |
| 341 std::string GetResourceDescription(uint32 identifier); | 355 std::string GetResourceDescription(uint32 identifier); |
| 342 | 356 |
| 343 CapturedContextMenuEvents captured_context_menu_events_; | 357 CapturedContextMenuEvents captured_context_menu_events_; |
| 344 | 358 |
| 345 WebCursor current_cursor_; | 359 WebCursor current_cursor_; |
| 346 | 360 |
| 347 #if defined(OS_WIN) | 361 #if defined(OS_WIN) |
| 348 // Classes needed by drag and drop. | 362 // Classes needed by drag and drop. |
| 349 scoped_refptr<TestDragDelegate> drag_delegate_; | 363 scoped_refptr<TestDragDelegate> drag_delegate_; |
| 350 scoped_refptr<TestDropDelegate> drop_delegate_; | 364 scoped_refptr<TestDropDelegate> drop_delegate_; |
| 351 #endif | 365 #endif |
| 352 | 366 |
| 353 #if defined(OS_LINUX) | 367 #if defined(OS_LINUX) |
| 354 // The type of cursor the window is currently using. | 368 // The type of cursor the window is currently using. |
| 355 // Used for judging whether a new SetCursor call is actually changing the | 369 // Used for judging whether a new SetCursor call is actually changing the |
| 356 // cursor. | 370 // cursor. |
| 357 GdkCursorType cursor_type_; | 371 GdkCursorType cursor_type_; |
| 358 #endif | 372 #endif |
| 359 | 373 |
| 360 #if defined(OS_MACOSX) | 374 #if defined(OS_MACOSX) |
| 361 linked_ptr<WebKit::WebPopupMenuInfo> popup_menu_info_; | 375 scoped_ptr<WebKit::WebPopupMenuInfo> popup_menu_info_; |
| 362 WebKit::WebRect popup_bounds_; | 376 WebKit::WebRect popup_bounds_; |
| 363 #endif | 377 #endif |
| 364 | 378 |
| 365 // true if we want to enable smart insert/delete. | 379 // true if we want to enable smart insert/delete. |
| 366 bool smart_insert_delete_enabled_; | 380 bool smart_insert_delete_enabled_; |
| 367 | 381 |
| 368 // true if we want to enable selection of trailing whitespaces | 382 // true if we want to enable selection of trailing whitespaces |
| 369 bool select_trailing_whitespace_enabled_; | 383 bool select_trailing_whitespace_enabled_; |
| 370 | 384 |
| 371 // true if we should block any redirects | 385 // true if we should block any redirects |
| 372 bool block_redirects_; | 386 bool block_redirects_; |
| 387 |
| 388 DISALLOW_COPY_AND_ASSIGN(TestWebViewDelegate); |
| 373 }; | 389 }; |
| 374 | 390 |
| 375 #endif // WEBKIT_TOOLS_TEST_SHELL_TEST_WEBVIEW_DELEGATE_H_ | 391 #endif // WEBKIT_TOOLS_TEST_SHELL_TEST_WEBVIEW_DELEGATE_H_ |
| OLD | NEW |