Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(273)

Side by Side Diff: webkit/tools/test_shell/test_webview_delegate.cc

Issue 115575: Move ExtraData from WebRequest to WebDataSource.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 printf("%s - didFailLoadingWithError <WebError code %d," 236 printf("%s - didFailLoadingWithError <WebError code %d,"
237 " failing URL \"%s\">\n", 237 " failing URL \"%s\">\n",
238 GetResourceDescription(identifier).c_str(), 238 GetResourceDescription(identifier).c_str(),
239 error.GetErrorCode(), 239 error.GetErrorCode(),
240 error.GetFailedURL().spec().c_str()); 240 error.GetFailedURL().spec().c_str());
241 } 241 }
242 242
243 resource_identifier_map_.erase(identifier); 243 resource_identifier_map_.erase(identifier);
244 } 244 }
245 245
246 void TestWebViewDelegate::DidCreateDataSource(WebFrame* frame,
247 WebDataSource* ds) {
248 ds->SetExtraData(pending_extra_data_.release());
249 }
250
246 void TestWebViewDelegate::DidStartProvisionalLoadForFrame( 251 void TestWebViewDelegate::DidStartProvisionalLoadForFrame(
247 WebView* webview, 252 WebView* webview,
248 WebFrame* frame, 253 WebFrame* frame,
249 NavigationGesture gesture) { 254 NavigationGesture gesture) {
250 if (shell_->ShouldDumpFrameLoadCallbacks()) { 255 if (shell_->ShouldDumpFrameLoadCallbacks()) {
251 printf("%S - didStartProvisionalLoadForFrame\n", 256 printf("%S - didStartProvisionalLoadForFrame\n",
252 GetFrameDescription(frame).c_str()); 257 GetFrameDescription(frame).c_str());
253 } 258 }
254 259
255 if (!top_loading_frame_) { 260 if (!top_loading_frame_) {
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 // Don't display an error page if we're running layout tests, because 294 // Don't display an error page if we're running layout tests, because
290 // DumpRenderTree doesn't. 295 // DumpRenderTree doesn't.
291 if (shell_->layout_test_mode()) 296 if (shell_->layout_test_mode())
292 return; 297 return;
293 298
294 // Don't display an error page if this is simply a cancelled load. Aside 299 // Don't display an error page if this is simply a cancelled load. Aside
295 // from being dumb, WebCore doesn't expect it and it will cause a crash. 300 // from being dumb, WebCore doesn't expect it and it will cause a crash.
296 if (error.GetErrorCode() == net::ERR_ABORTED) 301 if (error.GetErrorCode() == net::ERR_ABORTED)
297 return; 302 return;
298 303
299 const WebRequest& failed_request = 304 const WebDataSource* failed_ds = frame->GetProvisionalDataSource();
300 frame->GetProvisionalDataSource()->GetRequest(); 305
301 TestShellExtraRequestData* extra_data = 306 TestShellExtraData* extra_data =
302 static_cast<TestShellExtraRequestData*>(failed_request.GetExtraData()); 307 static_cast<TestShellExtraData*>(failed_ds->GetExtraData());
303 bool replace = extra_data && extra_data->pending_page_id != -1; 308 bool replace = extra_data && extra_data->pending_page_id != -1;
304 309
305 scoped_ptr<WebRequest> request(failed_request.Clone()); 310 scoped_ptr<WebRequest> request(failed_ds->GetRequest().Clone());
306 311
307 std::string error_text = 312 std::string error_text =
308 StringPrintf("Error %d when loading url %s", error.GetErrorCode(), 313 StringPrintf("Error %d when loading url %s", error.GetErrorCode(),
309 request->GetURL().spec().c_str()); 314 request->GetURL().spec().c_str());
310 request->SetURL(GURL("testshell-error:")); 315 request->SetURL(GURL("testshell-error:"));
311 316
312 frame->LoadAlternateHTMLString(request.get(), error_text, 317 frame->LoadAlternateHTMLString(request.get(), error_text,
313 error.GetFailedURL(), replace); 318 error.GetFailedURL(), replace);
314 } 319 }
315 320
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 void TestWebViewDelegate::DidHandleOnloadEventsForFrame(WebView* webview, 384 void TestWebViewDelegate::DidHandleOnloadEventsForFrame(WebView* webview,
380 WebFrame* frame) { 385 WebFrame* frame) {
381 if (shell_->ShouldDumpFrameLoadCallbacks()) { 386 if (shell_->ShouldDumpFrameLoadCallbacks()) {
382 printf("%S - didHandleOnloadEventsForFrame\n", 387 printf("%S - didHandleOnloadEventsForFrame\n",
383 GetFrameDescription(frame).c_str()); 388 GetFrameDescription(frame).c_str());
384 } 389 }
385 } 390 }
386 391
387 void TestWebViewDelegate::DidChangeLocationWithinPageForFrame( 392 void TestWebViewDelegate::DidChangeLocationWithinPageForFrame(
388 WebView* webview, WebFrame* frame, bool is_new_navigation) { 393 WebView* webview, WebFrame* frame, bool is_new_navigation) {
394 frame->GetDataSource()->SetExtraData(pending_extra_data_.release());
395
389 if (shell_->ShouldDumpFrameLoadCallbacks()) { 396 if (shell_->ShouldDumpFrameLoadCallbacks()) {
390 printf("%S - didChangeLocationWithinPageForFrame\n", 397 printf("%S - didChangeLocationWithinPageForFrame\n",
391 GetFrameDescription(frame).c_str()); 398 GetFrameDescription(frame).c_str());
392 } 399 }
393 400
394 UpdateForCommittedLoad(frame, is_new_navigation); 401 UpdateForCommittedLoad(frame, is_new_navigation);
395 } 402 }
396 403
397 void TestWebViewDelegate::DidReceiveIconForFrame(WebView* webview, 404 void TestWebViewDelegate::DidReceiveIconForFrame(WebView* webview,
398 WebFrame* frame) { 405 WebFrame* frame) {
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after
802 WebWidgetHost* TestWebViewDelegate::GetHostForWidget(WebWidget* webwidget) { 809 WebWidgetHost* TestWebViewDelegate::GetHostForWidget(WebWidget* webwidget) {
803 if (webwidget == shell_->webView()) 810 if (webwidget == shell_->webView())
804 return shell_->webViewHost(); 811 return shell_->webViewHost();
805 if (webwidget == shell_->popup()) 812 if (webwidget == shell_->popup())
806 return shell_->popupHost(); 813 return shell_->popupHost();
807 return NULL; 814 return NULL;
808 } 815 }
809 816
810 void TestWebViewDelegate::UpdateForCommittedLoad(WebFrame* frame, 817 void TestWebViewDelegate::UpdateForCommittedLoad(WebFrame* frame,
811 bool is_new_navigation) { 818 bool is_new_navigation) {
812 WebView* webview = shell_->webView();
813
814 // Code duplicated from RenderView::DidCommitLoadForFrame. 819 // Code duplicated from RenderView::DidCommitLoadForFrame.
815 const WebRequest& request = 820 TestShellExtraData* extra_data = static_cast<TestShellExtraData*>(
816 webview->GetMainFrame()->GetDataSource()->GetRequest(); 821 frame->GetDataSource()->GetExtraData());
817 TestShellExtraRequestData* extra_data =
818 static_cast<TestShellExtraRequestData*>(request.GetExtraData());
819 822
820 if (is_new_navigation) { 823 if (is_new_navigation) {
821 // New navigation. 824 // New navigation.
822 UpdateSessionHistory(frame); 825 UpdateSessionHistory(frame);
823 page_id_ = next_page_id_++; 826 page_id_ = next_page_id_++;
824 } else if (extra_data && extra_data->pending_page_id != -1 && 827 } else if (extra_data && extra_data->pending_page_id != -1 &&
825 !extra_data->request_committed) { 828 !extra_data->request_committed) {
826 // This is a successful session history navigation! 829 // This is a successful session history navigation!
827 UpdateSessionHistory(frame); 830 UpdateSessionHistory(frame);
828 page_id_ = extra_data->pending_page_id; 831 page_id_ = extra_data->pending_page_id;
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
888 return L"main frame \"" + name + L"\""; 891 return L"main frame \"" + name + L"\"";
889 else 892 else
890 return L"main frame"; 893 return L"main frame";
891 } else { 894 } else {
892 if (name.length()) 895 if (name.length())
893 return L"frame \"" + name + L"\""; 896 return L"frame \"" + name + L"\"";
894 else 897 else
895 return L"frame (anonymous)"; 898 return L"frame (anonymous)";
896 } 899 }
897 } 900 }
OLDNEW
« chrome/renderer/render_view.cc ('K') | « webkit/tools/test_shell/test_webview_delegate.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698