| 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" |
| 13 |
| 14 #if defined(OS_WIN) |
| 12 #include <windows.h> | 15 #include <windows.h> |
| 16 #endif |
| 13 #include <map> | 17 #include <map> |
| 14 | 18 |
| 15 #include "base/basictypes.h" | 19 #include "base/basictypes.h" |
| 16 #include "base/ref_counted.h" | 20 #include "base/ref_counted.h" |
| 17 #include "webkit/glue/webview_delegate.h" | 21 #include "webkit/glue/webview_delegate.h" |
| 18 #include "webkit/glue/webwidget_delegate.h" | 22 #include "webkit/glue/webwidget_delegate.h" |
| 23 #if defined(OS_WIN) |
| 19 #include "webkit/tools/test_shell/drag_delegate.h" | 24 #include "webkit/tools/test_shell/drag_delegate.h" |
| 20 #include "webkit/tools/test_shell/drop_delegate.h" | 25 #include "webkit/tools/test_shell/drop_delegate.h" |
| 26 #endif |
| 21 | 27 |
| 22 struct WebPreferences; | 28 struct WebPreferences; |
| 23 class GURL; | 29 class GURL; |
| 24 class TestShell; | 30 class TestShell; |
| 25 class WebDataSource; | 31 class WebDataSource; |
| 26 class WebWidgetHost; | 32 class WebWidgetHost; |
| 27 | 33 |
| 28 class TestWebViewDelegate : public base::RefCounted<TestWebViewDelegate>, public
WebViewDelegate { | 34 class TestWebViewDelegate : public base::RefCounted<TestWebViewDelegate>, |
| 35 public WebViewDelegate { |
| 29 public: | 36 public: |
| 30 struct CapturedContextMenuEvent { | 37 struct CapturedContextMenuEvent { |
| 31 CapturedContextMenuEvent(ContextNode::Type in_type, | 38 CapturedContextMenuEvent(ContextNode::Type in_type, |
| 32 int in_x, | 39 int in_x, |
| 33 int in_y) | 40 int in_y) |
| 34 : type(in_type), | 41 : type(in_type), |
| 35 x(in_x), | 42 x(in_x), |
| 36 y(in_y) { | 43 y(in_y) { |
| 37 } | 44 } |
| 38 | 45 |
| 39 ContextNode::Type type; | 46 ContextNode::Type type; |
| 40 int x; | 47 int x; |
| 41 int y; | 48 int y; |
| 42 }; | 49 }; |
| 43 | 50 |
| 44 typedef std::vector<CapturedContextMenuEvent> CapturedContextMenuEvents; | 51 typedef std::vector<CapturedContextMenuEvent> CapturedContextMenuEvents; |
| 45 | 52 |
| 46 TestWebViewDelegate(TestShell* shell) | 53 TestWebViewDelegate(TestShell* shell) |
| 47 : shell_(shell), | 54 : shell_(shell), |
| 48 top_loading_frame_(NULL), | 55 top_loading_frame_(NULL), |
| 49 page_id_(-1), | 56 page_id_(-1), |
| 50 last_page_id_updated_(-1), | 57 last_page_id_updated_(-1), |
| 51 page_is_loading_(false), | 58 page_is_loading_(false), |
| 52 is_custom_policy_delegate_(false), | 59 is_custom_policy_delegate_(false) |
| 53 custom_cursor_(NULL) { | 60 #if defined(OS_WIN) |
| 61 , custom_cursor_(NULL) |
| 62 #endif |
| 63 { |
| 54 } | 64 } |
| 55 virtual ~TestWebViewDelegate(); | 65 virtual ~TestWebViewDelegate(); |
| 56 | 66 |
| 57 // WebViewDelegate | 67 // WebViewDelegate |
| 58 virtual WebView* CreateWebView(WebView* webview, bool user_gesture); | 68 virtual WebView* CreateWebView(WebView* webview, bool user_gesture); |
| 59 virtual WebWidget* CreatePopupWidget(WebView* webview); | 69 virtual WebWidget* CreatePopupWidget(WebView* webview); |
| 60 virtual WebPluginDelegate* CreatePluginDelegate( | 70 virtual WebPluginDelegate* CreatePluginDelegate( |
| 61 WebView* webview, | 71 WebView* webview, |
| 62 const GURL& url, | 72 const GURL& url, |
| 63 const std::string& mime_type, | 73 const std::string& mime_type, |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 WebNavigationType type, | 185 WebNavigationType type, |
| 176 WindowOpenDisposition disposition, | 186 WindowOpenDisposition disposition, |
| 177 bool is_redirect); | 187 bool is_redirect); |
| 178 void TestWebViewDelegate::SetCustomPolicyDelegate(bool isCustom); | 188 void TestWebViewDelegate::SetCustomPolicyDelegate(bool isCustom); |
| 179 virtual WebHistoryItem* GetHistoryEntryAtOffset(int offset); | 189 virtual WebHistoryItem* GetHistoryEntryAtOffset(int offset); |
| 180 virtual void GoToEntryAtOffsetAsync(int offset); | 190 virtual void GoToEntryAtOffsetAsync(int offset); |
| 181 virtual int GetHistoryBackListCount(); | 191 virtual int GetHistoryBackListCount(); |
| 182 virtual int GetHistoryForwardListCount(); | 192 virtual int GetHistoryForwardListCount(); |
| 183 | 193 |
| 184 // WebWidgetDelegate | 194 // WebWidgetDelegate |
| 185 virtual HWND GetContainingWindow(WebWidget* webwidget); | 195 virtual gfx::ViewHandle GetContainingWindow(WebWidget* webwidget); |
| 186 virtual void DidInvalidateRect(WebWidget* webwidget, const gfx::Rect& rect); | 196 virtual void DidInvalidateRect(WebWidget* webwidget, const gfx::Rect& rect); |
| 187 virtual void DidScrollRect(WebWidget* webwidget, int dx, int dy, | 197 virtual void DidScrollRect(WebWidget* webwidget, int dx, int dy, |
| 188 const gfx::Rect& clip_rect); | 198 const gfx::Rect& clip_rect); |
| 189 virtual void Show(WebWidget* webview, WindowOpenDisposition disposition); | 199 virtual void Show(WebWidget* webview, WindowOpenDisposition disposition); |
| 190 virtual void CloseWidgetSoon(WebWidget* webwidget); | 200 virtual void CloseWidgetSoon(WebWidget* webwidget); |
| 191 virtual void Focus(WebWidget* webwidget); | 201 virtual void Focus(WebWidget* webwidget); |
| 192 virtual void Blur(WebWidget* webwidget); | 202 virtual void Blur(WebWidget* webwidget); |
| 193 virtual void SetCursor(WebWidget* webwidget, | 203 virtual void SetCursor(WebWidget* webwidget, |
| 194 const WebCursor& cursor); | 204 const WebCursor& cursor); |
| 195 virtual void GetWindowRect(WebWidget* webwidget, gfx::Rect* rect); | 205 virtual void GetWindowRect(WebWidget* webwidget, gfx::Rect* rect); |
| 196 virtual void SetWindowRect(WebWidget* webwidget, const gfx::Rect& rect); | 206 virtual void SetWindowRect(WebWidget* webwidget, const gfx::Rect& rect); |
| 197 virtual void GetRootWindowRect(WebWidget *,gfx::Rect *); | 207 virtual void GetRootWindowRect(WebWidget *,gfx::Rect *); |
| 198 virtual void DidMove(WebWidget* webwidget, const WebPluginGeometry& move); | 208 virtual void DidMove(WebWidget* webwidget, const WebPluginGeometry& move); |
| 199 virtual void RunModal(WebWidget* webwidget); | 209 virtual void RunModal(WebWidget* webwidget); |
| 200 virtual void AddRef() { | 210 virtual void AddRef() { |
| 201 RefCounted<TestWebViewDelegate>::AddRef(); | 211 base::RefCounted<TestWebViewDelegate>::AddRef(); |
| 202 } | 212 } |
| 203 virtual void Release() { | 213 virtual void Release() { |
| 204 RefCounted<TestWebViewDelegate>::Release(); | 214 base::RefCounted<TestWebViewDelegate>::Release(); |
| 205 } | 215 } |
| 206 | 216 |
| 207 // Additional accessors | 217 // Additional accessors |
| 208 WebFrame* top_loading_frame() { return top_loading_frame_; } | 218 WebFrame* top_loading_frame() { return top_loading_frame_; } |
| 219 #if defined(OS_WIN) |
| 209 IDropTarget* drop_delegate() { return drop_delegate_.get(); } | 220 IDropTarget* drop_delegate() { return drop_delegate_.get(); } |
| 210 IDropSource* drag_delegate() { return drag_delegate_.get(); } | 221 IDropSource* drag_delegate() { return drag_delegate_.get(); } |
| 222 #endif |
| 211 const CapturedContextMenuEvents& captured_context_menu_events() const { | 223 const CapturedContextMenuEvents& captured_context_menu_events() const { |
| 212 return captured_context_menu_events_; | 224 return captured_context_menu_events_; |
| 213 } | 225 } |
| 214 void clear_captured_context_menu_events() { | 226 void clear_captured_context_menu_events() { |
| 215 captured_context_menu_events_.clear(); | 227 captured_context_menu_events_.clear(); |
| 216 } | 228 } |
| 217 | 229 |
| 218 // Methods for modifying WebPreferences | 230 // Methods for modifying WebPreferences |
| 219 void SetUserStyleSheetEnabled(bool is_enabled); | 231 void SetUserStyleSheetEnabled(bool is_enabled); |
| 220 void SetUserStyleSheetLocation(const GURL& location); | 232 void SetUserStyleSheetLocation(const GURL& location); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 | 271 |
| 260 // For tracking session history. See RenderView. | 272 // For tracking session history. See RenderView. |
| 261 int page_id_; | 273 int page_id_; |
| 262 int last_page_id_updated_; | 274 int last_page_id_updated_; |
| 263 | 275 |
| 264 // Maps resource identifiers to a descriptive string. | 276 // Maps resource identifiers to a descriptive string. |
| 265 typedef std::map<uint32, std::string> ResourceMap; | 277 typedef std::map<uint32, std::string> ResourceMap; |
| 266 ResourceMap resource_identifier_map_; | 278 ResourceMap resource_identifier_map_; |
| 267 std::string GetResourceDescription(uint32 identifier); | 279 std::string GetResourceDescription(uint32 identifier); |
| 268 | 280 |
| 281 #if defined(OS_WIN) |
| 269 HCURSOR custom_cursor_; | 282 HCURSOR custom_cursor_; |
| 270 | 283 |
| 271 // Classes needed by drag and drop. | 284 // Classes needed by drag and drop. |
| 272 scoped_refptr<TestDragDelegate> drag_delegate_; | 285 scoped_refptr<TestDragDelegate> drag_delegate_; |
| 273 scoped_refptr<TestDropDelegate> drop_delegate_; | 286 scoped_refptr<TestDropDelegate> drop_delegate_; |
| 287 #endif |
| 274 | 288 |
| 275 CapturedContextMenuEvents captured_context_menu_events_; | 289 CapturedContextMenuEvents captured_context_menu_events_; |
| 276 | 290 |
| 277 DISALLOW_EVIL_CONSTRUCTORS(TestWebViewDelegate); | 291 DISALLOW_EVIL_CONSTRUCTORS(TestWebViewDelegate); |
| 278 }; | 292 }; |
| 279 | 293 |
| 280 #endif // WEBKIT_TOOLS_TEST_SHELL_TEST_WEBVIEW_DELEGATE_H__ | 294 #endif // WEBKIT_TOOLS_TEST_SHELL_TEST_WEBVIEW_DELEGATE_H_ |
| 281 | |
| OLD | NEW |