| 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 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 } | 210 } |
| 211 if (policy_delegate_should_notify_done_) | 211 if (policy_delegate_should_notify_done_) |
| 212 shell_->layout_test_controller()->PolicyDelegateDone(); | 212 shell_->layout_test_controller()->PolicyDelegateDone(); |
| 213 } else { | 213 } else { |
| 214 result = default_policy; | 214 result = default_policy; |
| 215 } | 215 } |
| 216 return result; | 216 return result; |
| 217 } | 217 } |
| 218 | 218 |
| 219 void TestWebViewDelegate::AssignIdentifierToRequest( | 219 void TestWebViewDelegate::AssignIdentifierToRequest( |
| 220 WebView* webview, | 220 WebFrame* webframe, |
| 221 uint32 identifier, | 221 uint32 identifier, |
| 222 const WebURLRequest& request) { | 222 const WebURLRequest& request) { |
| 223 if (shell_->ShouldDumpResourceLoadCallbacks()) | 223 if (shell_->ShouldDumpResourceLoadCallbacks()) |
| 224 resource_identifier_map_[identifier] = request.url().spec(); | 224 resource_identifier_map_[identifier] = request.url().spec(); |
| 225 } | 225 } |
| 226 | 226 |
| 227 std::string TestWebViewDelegate::GetResourceDescription(uint32 identifier) { | 227 std::string TestWebViewDelegate::GetResourceDescription(uint32 identifier) { |
| 228 ResourceMap::iterator it = resource_identifier_map_.find(identifier); | 228 ResourceMap::iterator it = resource_identifier_map_.find(identifier); |
| 229 return it != resource_identifier_map_.end() ? it->second : "<unknown>"; | 229 return it != resource_identifier_map_.end() ? it->second : "<unknown>"; |
| 230 } | 230 } |
| 231 | 231 |
| 232 void TestWebViewDelegate::WillSendRequest(WebView* webview, | 232 void TestWebViewDelegate::WillSendRequest(WebFrame* webframe, |
| 233 uint32 identifier, | 233 uint32 identifier, |
| 234 WebURLRequest* request) { | 234 WebURLRequest* request) { |
| 235 GURL url = request->url(); | 235 GURL url = request->url(); |
| 236 std::string request_url = url.possibly_invalid_spec(); | 236 std::string request_url = url.possibly_invalid_spec(); |
| 237 std::string host = url.host(); | 237 std::string host = url.host(); |
| 238 | 238 |
| 239 if (shell_->ShouldDumpResourceLoadCallbacks()) { | 239 if (shell_->ShouldDumpResourceLoadCallbacks()) { |
| 240 printf("%s - willSendRequest <WebRequest URL \"%s\">\n", | 240 printf("%s - willSendRequest <WebRequest URL \"%s\">\n", |
| 241 GetResourceDescription(identifier).c_str(), | 241 GetResourceDescription(identifier).c_str(), |
| 242 request_url.c_str()); | 242 request_url.c_str()); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 253 // To block the request, we set its URL to an empty one. | 253 // To block the request, we set its URL to an empty one. |
| 254 request->setURL(WebURL()); | 254 request->setURL(WebURL()); |
| 255 return; | 255 return; |
| 256 } | 256 } |
| 257 | 257 |
| 258 TRACE_EVENT_BEGIN("url.load", identifier, request_url); | 258 TRACE_EVENT_BEGIN("url.load", identifier, request_url); |
| 259 // Set the new substituted URL. | 259 // Set the new substituted URL. |
| 260 request->setURL(GURL(TestShell::RewriteLocalUrl(request_url))); | 260 request->setURL(GURL(TestShell::RewriteLocalUrl(request_url))); |
| 261 } | 261 } |
| 262 | 262 |
| 263 void TestWebViewDelegate::DidFinishLoading(WebView* webview, | 263 void TestWebViewDelegate::DidFinishLoading(WebFrame* webframe, |
| 264 uint32 identifier) { | 264 uint32 identifier) { |
| 265 TRACE_EVENT_END("url.load", identifier, ""); | 265 TRACE_EVENT_END("url.load", identifier, ""); |
| 266 if (shell_->ShouldDumpResourceLoadCallbacks()) { | 266 if (shell_->ShouldDumpResourceLoadCallbacks()) { |
| 267 printf("%s - didFinishLoading\n", | 267 printf("%s - didFinishLoading\n", |
| 268 GetResourceDescription(identifier).c_str()); | 268 GetResourceDescription(identifier).c_str()); |
| 269 } | 269 } |
| 270 | 270 |
| 271 resource_identifier_map_.erase(identifier); | 271 resource_identifier_map_.erase(identifier); |
| 272 } | 272 } |
| 273 | 273 |
| 274 void TestWebViewDelegate::DidFailLoadingWithError(WebView* webview, | 274 void TestWebViewDelegate::DidFailLoadingWithError(WebFrame* webframe, |
| 275 uint32 identifier, | 275 uint32 identifier, |
| 276 const WebURLError& error) { | 276 const WebURLError& error) { |
| 277 if (shell_->ShouldDumpResourceLoadCallbacks()) { | 277 if (shell_->ShouldDumpResourceLoadCallbacks()) { |
| 278 printf("%s - didFailLoadingWithError <WebError code %d," | 278 printf("%s - didFailLoadingWithError <WebError code %d," |
| 279 " failing URL \"%s\">\n", | 279 " failing URL \"%s\">\n", |
| 280 GetResourceDescription(identifier).c_str(), | 280 GetResourceDescription(identifier).c_str(), |
| 281 error.reason, | 281 error.reason, |
| 282 error.unreachableURL.spec().data()); | 282 error.unreachableURL.spec().data()); |
| 283 } | 283 } |
| 284 | 284 |
| (...skipping 639 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 924 return L"main frame \"" + name + L"\""; | 924 return L"main frame \"" + name + L"\""; |
| 925 else | 925 else |
| 926 return L"main frame"; | 926 return L"main frame"; |
| 927 } else { | 927 } else { |
| 928 if (name.length()) | 928 if (name.length()) |
| 929 return L"frame \"" + name + L"\""; | 929 return L"frame \"" + name + L"\""; |
| 930 else | 930 else |
| 931 return L"frame (anonymous)"; | 931 return L"frame (anonymous)"; |
| 932 } | 932 } |
| 933 } | 933 } |
| OLD | NEW |