| 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 #if defined(OS_WIN) |
| 12 #include <windows.h> | 13 #include <windows.h> |
| 14 #endif |
| 15 |
| 13 #include <map> | 16 #include <map> |
| 14 | 17 |
| 15 #include "base/basictypes.h" | 18 #include "base/basictypes.h" |
| 16 #include "base/ref_counted.h" | 19 #include "base/ref_counted.h" |
| 17 #include "webkit/glue/webview_delegate.h" | 20 #include "webkit/glue/webview_delegate.h" |
| 18 #include "webkit/glue/webwidget_delegate.h" | 21 #include "webkit/glue/webwidget_delegate.h" |
| 22 |
| 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>, public
WebViewDelegate { |
| 29 public: | 35 public: |
| 30 struct CapturedContextMenuEvent { | 36 struct CapturedContextMenuEvent { |
| 31 CapturedContextMenuEvent(ContextNode::Type in_type, | 37 CapturedContextMenuEvent(ContextNode::Type in_type, |
| 32 int in_x, | 38 int in_x, |
| 33 int in_y) | 39 int in_y) |
| 34 : type(in_type), | 40 : type(in_type), |
| 35 x(in_x), | 41 x(in_x), |
| 36 y(in_y) { | 42 y(in_y) { |
| 37 } | 43 } |
| 38 | 44 |
| 39 ContextNode::Type type; | 45 ContextNode::Type type; |
| 40 int x; | 46 int x; |
| 41 int y; | 47 int y; |
| 42 }; | 48 }; |
| 43 | 49 |
| 44 typedef std::vector<CapturedContextMenuEvent> CapturedContextMenuEvents; | 50 typedef std::vector<CapturedContextMenuEvent> CapturedContextMenuEvents; |
| 45 | 51 |
| 46 TestWebViewDelegate(TestShell* shell) | 52 TestWebViewDelegate(TestShell* shell) |
| 47 : shell_(shell), | 53 : page_is_loading_(false), |
| 54 is_custom_policy_delegate_(false), |
| 55 shell_(shell), |
| 48 top_loading_frame_(NULL), | 56 top_loading_frame_(NULL), |
| 49 page_id_(-1), | 57 page_id_(-1), |
| 50 last_page_id_updated_(-1), | 58 last_page_id_updated_(-1), |
| 51 page_is_loading_(false), | |
| 52 is_custom_policy_delegate_(false), | |
| 53 custom_cursor_(NULL) { | 59 custom_cursor_(NULL) { |
| 54 } | 60 } |
| 55 virtual ~TestWebViewDelegate(); | 61 virtual ~TestWebViewDelegate(); |
| 56 | 62 |
| 57 // WebViewDelegate | 63 // WebViewDelegate |
| 58 virtual WebView* CreateWebView(WebView* webview, bool user_gesture); | 64 virtual WebView* CreateWebView(WebView* webview, bool user_gesture); |
| 59 virtual WebWidget* CreatePopupWidget(WebView* webview); | 65 virtual WebWidget* CreatePopupWidget(WebView* webview); |
| 60 virtual WebPluginDelegate* CreatePluginDelegate( | 66 virtual WebPluginDelegate* CreatePluginDelegate( |
| 61 WebView* webview, | 67 WebView* webview, |
| 62 const GURL& url, | 68 const GURL& url, |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 virtual void DidStopLoading(WebView* webview); | 174 virtual void DidStopLoading(WebView* webview); |
| 169 | 175 |
| 170 virtual void WindowObjectCleared(WebFrame* webframe); | 176 virtual void WindowObjectCleared(WebFrame* webframe); |
| 171 virtual WindowOpenDisposition DispositionForNavigationAction( | 177 virtual WindowOpenDisposition DispositionForNavigationAction( |
| 172 WebView* webview, | 178 WebView* webview, |
| 173 WebFrame* frame, | 179 WebFrame* frame, |
| 174 const WebRequest* request, | 180 const WebRequest* request, |
| 175 WebNavigationType type, | 181 WebNavigationType type, |
| 176 WindowOpenDisposition disposition, | 182 WindowOpenDisposition disposition, |
| 177 bool is_redirect); | 183 bool is_redirect); |
| 178 void TestWebViewDelegate::SetCustomPolicyDelegate(bool isCustom); | 184 void SetCustomPolicyDelegate(bool isCustom); |
| 179 virtual WebHistoryItem* GetHistoryEntryAtOffset(int offset); | 185 virtual WebHistoryItem* GetHistoryEntryAtOffset(int offset); |
| 180 virtual void GoToEntryAtOffsetAsync(int offset); | 186 virtual void GoToEntryAtOffsetAsync(int offset); |
| 181 virtual int GetHistoryBackListCount(); | 187 virtual int GetHistoryBackListCount(); |
| 182 virtual int GetHistoryForwardListCount(); | 188 virtual int GetHistoryForwardListCount(); |
| 183 | 189 |
| 184 // WebWidgetDelegate | 190 // WebWidgetDelegate |
| 191 #if defined(OS_WIN) |
| 185 virtual HWND GetContainingWindow(WebWidget* webwidget); | 192 virtual HWND GetContainingWindow(WebWidget* webwidget); |
| 193 #else |
| 194 virtual void* GetContainingWindow(WebWidget* webwidget) { return NULL; } |
| 195 #endif |
| 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) |
| 220 // TODO(evanm): restore these once we have drag'n'drop ported. |
| 209 IDropTarget* drop_delegate() { return drop_delegate_.get(); } | 221 IDropTarget* drop_delegate() { return drop_delegate_.get(); } |
| 210 IDropSource* drag_delegate() { return drag_delegate_.get(); } | 222 IDropSource* drag_delegate() { return drag_delegate_.get(); } |
| 223 #endif |
| 211 const CapturedContextMenuEvents& captured_context_menu_events() const { | 224 const CapturedContextMenuEvents& captured_context_menu_events() const { |
| 212 return captured_context_menu_events_; | 225 return captured_context_menu_events_; |
| 213 } | 226 } |
| 214 void clear_captured_context_menu_events() { | 227 void clear_captured_context_menu_events() { |
| 215 captured_context_menu_events_.clear(); | 228 captured_context_menu_events_.clear(); |
| 216 } | 229 } |
| 217 | 230 |
| 218 // Methods for modifying WebPreferences | 231 // Methods for modifying WebPreferences |
| 219 void SetUserStyleSheetEnabled(bool is_enabled); | 232 void SetUserStyleSheetEnabled(bool is_enabled); |
| 220 void SetUserStyleSheetLocation(const GURL& location); | 233 void SetUserStyleSheetLocation(const GURL& location); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 | 272 |
| 260 // For tracking session history. See RenderView. | 273 // For tracking session history. See RenderView. |
| 261 int page_id_; | 274 int page_id_; |
| 262 int last_page_id_updated_; | 275 int last_page_id_updated_; |
| 263 | 276 |
| 264 // Maps resource identifiers to a descriptive string. | 277 // Maps resource identifiers to a descriptive string. |
| 265 typedef std::map<uint32, std::string> ResourceMap; | 278 typedef std::map<uint32, std::string> ResourceMap; |
| 266 ResourceMap resource_identifier_map_; | 279 ResourceMap resource_identifier_map_; |
| 267 std::string GetResourceDescription(uint32 identifier); | 280 std::string GetResourceDescription(uint32 identifier); |
| 268 | 281 |
| 282 #if defined(OS_WIN) |
| 269 HCURSOR custom_cursor_; | 283 HCURSOR custom_cursor_; |
| 270 | 284 |
| 271 // Classes needed by drag and drop. | 285 // Classes needed by drag and drop. |
| 272 scoped_refptr<TestDragDelegate> drag_delegate_; | 286 scoped_refptr<TestDragDelegate> drag_delegate_; |
| 273 scoped_refptr<TestDropDelegate> drop_delegate_; | 287 scoped_refptr<TestDropDelegate> drop_delegate_; |
| 288 #else |
| 289 void* custom_cursor_; // TODO(port): currently unused. |
| 290 #endif |
| 274 | 291 |
| 275 CapturedContextMenuEvents captured_context_menu_events_; | 292 CapturedContextMenuEvents captured_context_menu_events_; |
| 276 | 293 |
| 277 DISALLOW_EVIL_CONSTRUCTORS(TestWebViewDelegate); | 294 DISALLOW_EVIL_CONSTRUCTORS(TestWebViewDelegate); |
| 278 }; | 295 }; |
| 279 | 296 |
| 280 #endif // WEBKIT_TOOLS_TEST_SHELL_TEST_WEBVIEW_DELEGATE_H__ | 297 #endif // WEBKIT_TOOLS_TEST_SHELL_TEST_WEBVIEW_DELEGATE_H__ |
| 281 | |
| OLD | NEW |