| 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 // This file contains the implementation of TestWebViewDelegate, which serves | 5 // This file contains the implementation of TestWebViewDelegate, which serves |
| 6 // as the WebViewDelegate for the TestShellWebHost. The host is expected to | 6 // as the WebViewDelegate for the TestShellWebHost. The host is expected to |
| 7 // have initialized a MessageLoop before these methods are called. | 7 // have initialized a MessageLoop before these methods are called. |
| 8 | 8 |
| 9 #include "config.h" | 9 #include "config.h" |
| 10 | 10 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 #include "webkit/api/public/WebURL.h" | 31 #include "webkit/api/public/WebURL.h" |
| 32 #include "webkit/api/public/WebURLError.h" | 32 #include "webkit/api/public/WebURLError.h" |
| 33 #include "webkit/api/public/WebURLRequest.h" | 33 #include "webkit/api/public/WebURLRequest.h" |
| 34 #include "webkit/api/public/WebURLResponse.h" | 34 #include "webkit/api/public/WebURLResponse.h" |
| 35 #include "webkit/appcache/appcache_interfaces.h" | 35 #include "webkit/appcache/appcache_interfaces.h" |
| 36 #include "webkit/glue/glue_serialize.h" | 36 #include "webkit/glue/glue_serialize.h" |
| 37 #include "webkit/glue/media/buffered_data_source.h" | 37 #include "webkit/glue/media/buffered_data_source.h" |
| 38 #include "webkit/glue/media/media_resource_loader_bridge_factory.h" | 38 #include "webkit/glue/media/media_resource_loader_bridge_factory.h" |
| 39 #include "webkit/glue/media/simple_data_source.h" | 39 #include "webkit/glue/media/simple_data_source.h" |
| 40 #include "webkit/glue/webdropdata.h" | 40 #include "webkit/glue/webdropdata.h" |
| 41 #include "webkit/glue/webplugin_impl.h" |
| 41 #include "webkit/glue/webpreferences.h" | 42 #include "webkit/glue/webpreferences.h" |
| 42 #include "webkit/glue/webkit_glue.h" | 43 #include "webkit/glue/webkit_glue.h" |
| 43 #include "webkit/glue/webview.h" | 44 #include "webkit/glue/webview.h" |
| 44 #include "webkit/glue/plugins/plugin_list.h" | 45 #include "webkit/glue/plugins/plugin_list.h" |
| 45 #include "webkit/glue/plugins/webplugin_delegate_impl.h" | 46 #include "webkit/glue/plugins/webplugin_delegate_impl.h" |
| 46 #include "webkit/glue/webmediaplayer_impl.h" | 47 #include "webkit/glue/webmediaplayer_impl.h" |
| 47 #include "webkit/glue/window_open_disposition.h" | 48 #include "webkit/glue/window_open_disposition.h" |
| 48 #include "webkit/tools/test_shell/test_navigation_controller.h" | 49 #include "webkit/tools/test_shell/test_navigation_controller.h" |
| 49 #include "webkit/tools/test_shell/test_shell.h" | 50 #include "webkit/tools/test_shell/test_shell.h" |
| 50 #include "webkit/tools/test_shell/test_webworker_helper.h" | 51 #include "webkit/tools/test_shell/test_webworker_helper.h" |
| 51 | 52 |
| 52 #if defined(OS_WIN) | 53 #if defined(OS_WIN) |
| 53 // TODO(port): make these files work everywhere. | 54 // TODO(port): make these files work everywhere. |
| 54 #include "webkit/tools/test_shell/drag_delegate.h" | 55 #include "webkit/tools/test_shell/drag_delegate.h" |
| 55 #include "webkit/tools/test_shell/drop_delegate.h" | 56 #include "webkit/tools/test_shell/drop_delegate.h" |
| 56 #endif | 57 #endif |
| 57 | 58 |
| 58 using WebKit::WebData; | 59 using WebKit::WebData; |
| 59 using WebKit::WebDataSource; | 60 using WebKit::WebDataSource; |
| 60 using WebKit::WebDragData; | 61 using WebKit::WebDragData; |
| 61 using WebKit::WebFrame; | 62 using WebKit::WebFrame; |
| 62 using WebKit::WebHistoryItem; | 63 using WebKit::WebHistoryItem; |
| 63 using WebKit::WebNavigationType; | 64 using WebKit::WebNavigationType; |
| 64 using WebKit::WebNavigationPolicy; | 65 using WebKit::WebNavigationPolicy; |
| 66 using WebKit::WebPlugin; |
| 67 using WebKit::WebPluginParams; |
| 65 using WebKit::WebRect; | 68 using WebKit::WebRect; |
| 66 using WebKit::WebScreenInfo; | 69 using WebKit::WebScreenInfo; |
| 67 using WebKit::WebSize; | 70 using WebKit::WebSize; |
| 68 using WebKit::WebString; | 71 using WebKit::WebString; |
| 69 using WebKit::WebURL; | 72 using WebKit::WebURL; |
| 70 using WebKit::WebURLError; | 73 using WebKit::WebURLError; |
| 71 using WebKit::WebURLRequest; | 74 using WebKit::WebURLRequest; |
| 72 using WebKit::WebURLResponse; | 75 using WebKit::WebURLResponse; |
| 73 using WebKit::WebWidget; | 76 using WebKit::WebWidget; |
| 74 using WebKit::WebWorker; | 77 using WebKit::WebWorker; |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 bool user_gesture, | 180 bool user_gesture, |
| 178 const GURL& creator_url) { | 181 const GURL& creator_url) { |
| 179 return shell_->CreateWebView(webview); | 182 return shell_->CreateWebView(webview); |
| 180 } | 183 } |
| 181 | 184 |
| 182 WebWidget* TestWebViewDelegate::CreatePopupWidget(WebView* webview, | 185 WebWidget* TestWebViewDelegate::CreatePopupWidget(WebView* webview, |
| 183 bool activatable) { | 186 bool activatable) { |
| 184 return shell_->CreatePopupWidget(webview); | 187 return shell_->CreatePopupWidget(webview); |
| 185 } | 188 } |
| 186 | 189 |
| 190 WebPlugin* TestWebViewDelegate::CreatePlugin( |
| 191 WebFrame* frame, const WebPluginParams& params) { |
| 192 return new webkit_glue::WebPluginImpl(frame, params, AsWeakPtr()); |
| 193 } |
| 194 |
| 187 WebKit::WebMediaPlayer* TestWebViewDelegate::CreateWebMediaPlayer( | 195 WebKit::WebMediaPlayer* TestWebViewDelegate::CreateWebMediaPlayer( |
| 188 WebKit::WebMediaPlayerClient* client) { | 196 WebKit::WebMediaPlayerClient* client) { |
| 189 scoped_refptr<media::FilterFactoryCollection> factory = | 197 scoped_refptr<media::FilterFactoryCollection> factory = |
| 190 new media::FilterFactoryCollection(); | 198 new media::FilterFactoryCollection(); |
| 191 | 199 |
| 192 // TODO(hclam): this is the same piece of code as in RenderView, maybe they | 200 // TODO(hclam): this is the same piece of code as in RenderView, maybe they |
| 193 // should be grouped together. | 201 // should be grouped together. |
| 194 webkit_glue::MediaResourceLoaderBridgeFactory* bridge_factory = | 202 webkit_glue::MediaResourceLoaderBridgeFactory* bridge_factory = |
| 195 new webkit_glue::MediaResourceLoaderBridgeFactory( | 203 new webkit_glue::MediaResourceLoaderBridgeFactory( |
| 196 GURL::EmptyGURL(), // referrer | 204 GURL::EmptyGURL(), // referrer |
| (...skipping 18 matching lines...) Expand all Loading... |
| 215 | 223 |
| 216 void TestWebViewDelegate::OpenURL(WebView* webview, const GURL& url, | 224 void TestWebViewDelegate::OpenURL(WebView* webview, const GURL& url, |
| 217 const GURL& referrer, | 225 const GURL& referrer, |
| 218 WebNavigationPolicy policy) { | 226 WebNavigationPolicy policy) { |
| 219 DCHECK_NE(policy, WebKit::WebNavigationPolicyCurrentTab); | 227 DCHECK_NE(policy, WebKit::WebNavigationPolicyCurrentTab); |
| 220 TestShell* shell = NULL; | 228 TestShell* shell = NULL; |
| 221 if (TestShell::CreateNewWindow(UTF8ToWide(url.spec()), &shell)) | 229 if (TestShell::CreateNewWindow(UTF8ToWide(url.spec()), &shell)) |
| 222 shell->Show(policy); | 230 shell->Show(policy); |
| 223 } | 231 } |
| 224 | 232 |
| 225 void TestWebViewDelegate::DidStartLoading(WebView* webview) { | |
| 226 // Ignored | |
| 227 } | |
| 228 | |
| 229 void TestWebViewDelegate::DidStopLoading(WebView* webview) { | |
| 230 // Ignored | |
| 231 } | |
| 232 | |
| 233 void TestWebViewDelegate::WindowObjectCleared(WebFrame* webframe) { | 233 void TestWebViewDelegate::WindowObjectCleared(WebFrame* webframe) { |
| 234 shell_->BindJSObjectsToWindow(webframe); | 234 shell_->BindJSObjectsToWindow(webframe); |
| 235 } | 235 } |
| 236 | 236 |
| 237 WebNavigationPolicy TestWebViewDelegate::PolicyForNavigationAction( | 237 WebNavigationPolicy TestWebViewDelegate::PolicyForNavigationAction( |
| 238 WebView* webview, | 238 WebView* webview, |
| 239 WebFrame* frame, | 239 WebFrame* frame, |
| 240 const WebURLRequest& request, | 240 const WebURLRequest& request, |
| 241 WebNavigationType type, | 241 WebNavigationType type, |
| 242 WebNavigationPolicy default_policy, | 242 WebNavigationPolicy default_policy, |
| (...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 810 prefs->Apply(shell_->webView()); | 810 prefs->Apply(shell_->webView()); |
| 811 } | 811 } |
| 812 | 812 |
| 813 void TestWebViewDelegate::SetUserStyleSheetLocation(const GURL& location) { | 813 void TestWebViewDelegate::SetUserStyleSheetLocation(const GURL& location) { |
| 814 WebPreferences* prefs = shell_->GetWebPreferences(); | 814 WebPreferences* prefs = shell_->GetWebPreferences(); |
| 815 prefs->user_style_sheet_enabled = true; | 815 prefs->user_style_sheet_enabled = true; |
| 816 prefs->user_style_sheet_location = location; | 816 prefs->user_style_sheet_location = location; |
| 817 prefs->Apply(shell_->webView()); | 817 prefs->Apply(shell_->webView()); |
| 818 } | 818 } |
| 819 | 819 |
| 820 // WebWidgetDelegate --------------------------------------------------------- | 820 // WebWidgetClient ----------------------------------------------------------- |
| 821 | 821 |
| 822 void TestWebViewDelegate::didInvalidateRect(const WebRect& rect) { | 822 void TestWebViewDelegate::didInvalidateRect(const WebRect& rect) { |
| 823 if (WebWidgetHost* host = GetWidgetHost()) | 823 if (WebWidgetHost* host = GetWidgetHost()) |
| 824 host->DidInvalidateRect(rect); | 824 host->DidInvalidateRect(rect); |
| 825 } | 825 } |
| 826 | 826 |
| 827 void TestWebViewDelegate::didScrollRect(int dx, int dy, | 827 void TestWebViewDelegate::didScrollRect(int dx, int dy, |
| 828 const WebRect& clip_rect) { | 828 const WebRect& clip_rect) { |
| 829 if (WebWidgetHost* host = GetWidgetHost()) | 829 if (WebWidgetHost* host = GetWidgetHost()) |
| 830 host->DidScrollRect(dx, dy, clip_rect); | 830 host->DidScrollRect(dx, dy, clip_rect); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 862 #endif | 862 #endif |
| 863 smart_insert_delete_enabled_(true), | 863 smart_insert_delete_enabled_(true), |
| 864 #if defined(OS_WIN) | 864 #if defined(OS_WIN) |
| 865 select_trailing_whitespace_enabled_(true), | 865 select_trailing_whitespace_enabled_(true), |
| 866 #else | 866 #else |
| 867 select_trailing_whitespace_enabled_(false), | 867 select_trailing_whitespace_enabled_(false), |
| 868 #endif | 868 #endif |
| 869 block_redirects_(false) { | 869 block_redirects_(false) { |
| 870 } | 870 } |
| 871 | 871 |
| 872 TestWebViewDelegate::~TestWebViewDelegate() { |
| 873 } |
| 874 |
| 872 void TestWebViewDelegate::Reset() { | 875 void TestWebViewDelegate::Reset() { |
| 873 *this = TestWebViewDelegate(shell_); | 876 // Do a little placement new dance... |
| 877 TestShell* shell = shell_; |
| 878 this->~TestWebViewDelegate(); |
| 879 new (this) TestWebViewDelegate(shell); |
| 874 } | 880 } |
| 875 | 881 |
| 876 void TestWebViewDelegate::SetSmartInsertDeleteEnabled(bool enabled) { | 882 void TestWebViewDelegate::SetSmartInsertDeleteEnabled(bool enabled) { |
| 877 smart_insert_delete_enabled_ = enabled; | 883 smart_insert_delete_enabled_ = enabled; |
| 878 // In upstream WebKit, smart insert/delete is mutually exclusive with select | 884 // In upstream WebKit, smart insert/delete is mutually exclusive with select |
| 879 // trailing whitespace, however, we allow both because Chromium on Windows | 885 // trailing whitespace, however, we allow both because Chromium on Windows |
| 880 // allows both. | 886 // allows both. |
| 881 } | 887 } |
| 882 | 888 |
| 883 void TestWebViewDelegate::SetSelectTrailingWhitespaceEnabled(bool enabled) { | 889 void TestWebViewDelegate::SetSelectTrailingWhitespaceEnabled(bool enabled) { |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1024 return L"main frame \"" + name + L"\""; | 1030 return L"main frame \"" + name + L"\""; |
| 1025 else | 1031 else |
| 1026 return L"main frame"; | 1032 return L"main frame"; |
| 1027 } else { | 1033 } else { |
| 1028 if (name.length()) | 1034 if (name.length()) |
| 1029 return L"frame \"" + name + L"\""; | 1035 return L"frame \"" + name + L"\""; |
| 1030 else | 1036 else |
| 1031 return L"frame (anonymous)"; | 1037 return L"frame (anonymous)"; |
| 1032 } | 1038 } |
| 1033 } | 1039 } |
| OLD | NEW |