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

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

Issue 164225: Switch to WebFrame from the WebKit API.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 4 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
11 #include "webkit/tools/test_shell/test_webview_delegate.h" 11 #include "webkit/tools/test_shell/test_webview_delegate.h"
12 12
13 #include "base/file_util.h" 13 #include "base/file_util.h"
14 #include "base/gfx/point.h" 14 #include "base/gfx/point.h"
15 #include "base/gfx/native_widget_types.h" 15 #include "base/gfx/native_widget_types.h"
16 #include "base/message_loop.h" 16 #include "base/message_loop.h"
17 #include "base/process_util.h" 17 #include "base/process_util.h"
18 #include "base/string_util.h" 18 #include "base/string_util.h"
19 #include "base/trace_event.h" 19 #include "base/trace_event.h"
20 #include "net/base/net_errors.h" 20 #include "net/base/net_errors.h"
21 #include "webkit/api/public/WebData.h" 21 #include "webkit/api/public/WebData.h"
22 #include "webkit/api/public/WebDataSource.h" 22 #include "webkit/api/public/WebDataSource.h"
23 #include "webkit/api/public/WebDragData.h" 23 #include "webkit/api/public/WebDragData.h"
24 #include "webkit/api/public/WebHistoryItem.h" 24 #include "webkit/api/public/WebHistoryItem.h"
25 #include "webkit/api/public/WebFrame.h"
25 #include "webkit/api/public/WebKit.h" 26 #include "webkit/api/public/WebKit.h"
26 #include "webkit/api/public/WebScreenInfo.h" 27 #include "webkit/api/public/WebScreenInfo.h"
27 #include "webkit/api/public/WebString.h" 28 #include "webkit/api/public/WebString.h"
28 #include "webkit/api/public/WebURL.h" 29 #include "webkit/api/public/WebURL.h"
29 #include "webkit/api/public/WebURLError.h" 30 #include "webkit/api/public/WebURLError.h"
30 #include "webkit/api/public/WebURLRequest.h" 31 #include "webkit/api/public/WebURLRequest.h"
31 #include "webkit/api/public/WebURLResponse.h" 32 #include "webkit/api/public/WebURLResponse.h"
32 #include "webkit/glue/glue_serialize.h" 33 #include "webkit/glue/glue_serialize.h"
33 #include "webkit/glue/media/buffered_data_source.h" 34 #include "webkit/glue/media/buffered_data_source.h"
34 #include "webkit/glue/media/media_resource_loader_bridge_factory.h" 35 #include "webkit/glue/media/media_resource_loader_bridge_factory.h"
35 #include "webkit/glue/media/simple_data_source.h" 36 #include "webkit/glue/media/simple_data_source.h"
36 #include "webkit/glue/webappcachecontext.h" 37 #include "webkit/glue/webappcachecontext.h"
37 #include "webkit/glue/webdropdata.h" 38 #include "webkit/glue/webdropdata.h"
38 #include "webkit/glue/webframe.h"
39 #include "webkit/glue/webpreferences.h" 39 #include "webkit/glue/webpreferences.h"
40 #include "webkit/glue/webkit_glue.h" 40 #include "webkit/glue/webkit_glue.h"
41 #include "webkit/glue/webview.h" 41 #include "webkit/glue/webview.h"
42 #include "webkit/glue/plugins/plugin_list.h" 42 #include "webkit/glue/plugins/plugin_list.h"
43 #include "webkit/glue/plugins/webplugin_delegate_impl.h" 43 #include "webkit/glue/plugins/webplugin_delegate_impl.h"
44 #include "webkit/glue/webmediaplayer_impl.h" 44 #include "webkit/glue/webmediaplayer_impl.h"
45 #include "webkit/glue/window_open_disposition.h" 45 #include "webkit/glue/window_open_disposition.h"
46 #include "webkit/tools/test_shell/test_navigation_controller.h" 46 #include "webkit/tools/test_shell/test_navigation_controller.h"
47 #include "webkit/tools/test_shell/test_shell.h" 47 #include "webkit/tools/test_shell/test_shell.h"
48 #include "webkit/tools/test_shell/test_webworker_helper.h" 48 #include "webkit/tools/test_shell/test_webworker_helper.h"
49 49
50 #if defined(OS_WIN) 50 #if defined(OS_WIN)
51 // TODO(port): make these files work everywhere. 51 // TODO(port): make these files work everywhere.
52 #include "webkit/tools/test_shell/drag_delegate.h" 52 #include "webkit/tools/test_shell/drag_delegate.h"
53 #include "webkit/tools/test_shell/drop_delegate.h" 53 #include "webkit/tools/test_shell/drop_delegate.h"
54 #endif 54 #endif
55 55
56 using WebKit::WebData; 56 using WebKit::WebData;
57 using WebKit::WebDataSource; 57 using WebKit::WebDataSource;
58 using WebKit::WebDragData; 58 using WebKit::WebDragData;
59 using WebKit::WebFrame;
59 using WebKit::WebHistoryItem; 60 using WebKit::WebHistoryItem;
60 using WebKit::WebNavigationType; 61 using WebKit::WebNavigationType;
61 using WebKit::WebNavigationPolicy; 62 using WebKit::WebNavigationPolicy;
62 using WebKit::WebRect; 63 using WebKit::WebRect;
63 using WebKit::WebScreenInfo; 64 using WebKit::WebScreenInfo;
64 using WebKit::WebSize; 65 using WebKit::WebSize;
65 using WebKit::WebString; 66 using WebKit::WebString;
66 using WebKit::WebURL; 67 using WebKit::WebURL;
67 using WebKit::WebURLError; 68 using WebKit::WebURLError;
68 using WebKit::WebURLRequest; 69 using WebKit::WebURLRequest;
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 234
234 WebNavigationPolicy TestWebViewDelegate::PolicyForNavigationAction( 235 WebNavigationPolicy TestWebViewDelegate::PolicyForNavigationAction(
235 WebView* webview, 236 WebView* webview,
236 WebFrame* frame, 237 WebFrame* frame,
237 const WebURLRequest& request, 238 const WebURLRequest& request,
238 WebNavigationType type, 239 WebNavigationType type,
239 WebNavigationPolicy default_policy, 240 WebNavigationPolicy default_policy,
240 bool is_redirect) { 241 bool is_redirect) {
241 WebNavigationPolicy result; 242 WebNavigationPolicy result;
242 if (policy_delegate_enabled_) { 243 if (policy_delegate_enabled_) {
243 std::wstring frame_name = frame->GetName();
244 printf("Policy delegate: attempt to load %s with navigation type '%s'\n", 244 printf("Policy delegate: attempt to load %s with navigation type '%s'\n",
245 GetURLDescription(request.url()).c_str(), 245 GetURLDescription(request.url()).c_str(),
246 WebNavigationTypeToString(type)); 246 WebNavigationTypeToString(type));
247 if (policy_delegate_is_permissive_) { 247 if (policy_delegate_is_permissive_) {
248 result = WebKit::WebNavigationPolicyCurrentTab; 248 result = WebKit::WebNavigationPolicyCurrentTab;
249 } else { 249 } else {
250 result = WebKit::WebNavigationPolicyIgnore; 250 result = WebKit::WebNavigationPolicyIgnore;
251 } 251 }
252 if (policy_delegate_should_notify_done_) 252 if (policy_delegate_should_notify_done_)
253 shell_->layout_test_controller()->PolicyDelegateDone(); 253 shell_->layout_test_controller()->PolicyDelegateDone();
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 GetFrameDescription(frame).c_str()); 364 GetFrameDescription(frame).c_str());
365 } 365 }
366 366
367 if (!top_loading_frame_) { 367 if (!top_loading_frame_) {
368 top_loading_frame_ = frame; 368 top_loading_frame_ = frame;
369 } 369 }
370 370
371 if (shell_->layout_test_controller()->StopProvisionalFrameLoads()) { 371 if (shell_->layout_test_controller()->StopProvisionalFrameLoads()) {
372 printf("%S - stopping load in didStartProvisionalLoadForFrame callback\n", 372 printf("%S - stopping load in didStartProvisionalLoadForFrame callback\n",
373 GetFrameDescription(frame).c_str()); 373 GetFrameDescription(frame).c_str());
374 frame->StopLoading(); 374 frame->stopLoading();
375 } 375 }
376 UpdateAddressBar(webview); 376 UpdateAddressBar(webview);
377 } 377 }
378 378
379 void TestWebViewDelegate::DidReceiveProvisionalLoadServerRedirect( 379 void TestWebViewDelegate::DidReceiveProvisionalLoadServerRedirect(
380 WebView* webview, 380 WebView* webview,
381 WebFrame* frame) { 381 WebFrame* frame) {
382 if (shell_->ShouldDumpFrameLoadCallbacks()) { 382 if (shell_->ShouldDumpFrameLoadCallbacks()) {
383 printf("%S - didReceiveServerRedirectForProvisionalLoadForFrame\n", 383 printf("%S - didReceiveServerRedirectForProvisionalLoadForFrame\n",
384 GetFrameDescription(frame).c_str()); 384 GetFrameDescription(frame).c_str());
(...skipping 16 matching lines...) Expand all
401 // Don't display an error page if we're running layout tests, because 401 // Don't display an error page if we're running layout tests, because
402 // DumpRenderTree doesn't. 402 // DumpRenderTree doesn't.
403 if (shell_->layout_test_mode()) 403 if (shell_->layout_test_mode())
404 return; 404 return;
405 405
406 // Don't display an error page if this is simply a cancelled load. Aside 406 // Don't display an error page if this is simply a cancelled load. Aside
407 // from being dumb, WebCore doesn't expect it and it will cause a crash. 407 // from being dumb, WebCore doesn't expect it and it will cause a crash.
408 if (error.reason == net::ERR_ABORTED) 408 if (error.reason == net::ERR_ABORTED)
409 return; 409 return;
410 410
411 const WebDataSource* failed_ds = frame->GetProvisionalDataSource(); 411 const WebDataSource* failed_ds = frame->provisionalDataSource();
412 412
413 TestShellExtraData* extra_data = 413 TestShellExtraData* extra_data =
414 static_cast<TestShellExtraData*>(failed_ds->extraData()); 414 static_cast<TestShellExtraData*>(failed_ds->extraData());
415 bool replace = extra_data && extra_data->pending_page_id != -1; 415 bool replace = extra_data && extra_data->pending_page_id != -1;
416 416
417 const std::string& error_text = 417 const std::string& error_text =
418 StringPrintf("Error %d when loading url %s", error.reason, 418 StringPrintf("Error %d when loading url %s", error.reason,
419 failed_ds->request().url().spec().data()); 419 failed_ds->request().url().spec().data());
420 420
421 // Make sure we never show errors in view source mode. 421 // Make sure we never show errors in view source mode.
422 frame->SetInViewSourceMode(false); 422 frame->enableViewSourceMode(false);
423 423
424 frame->LoadHTMLString( 424 frame->loadHTMLString(
425 error_text, GURL("testshell-error:"), error.unreachableURL, replace); 425 error_text, GURL("testshell-error:"), error.unreachableURL, replace);
426 } 426 }
427 427
428 void TestWebViewDelegate::DidCommitLoadForFrame(WebView* webview, 428 void TestWebViewDelegate::DidCommitLoadForFrame(WebView* webview,
429 WebFrame* frame, 429 WebFrame* frame,
430 bool is_new_navigation) { 430 bool is_new_navigation) {
431 if (shell_->ShouldDumpFrameLoadCallbacks()) { 431 if (shell_->ShouldDumpFrameLoadCallbacks()) {
432 printf("%S - didCommitLoadForFrame\n", 432 printf("%S - didCommitLoadForFrame\n",
433 GetFrameDescription(frame).c_str()); 433 GetFrameDescription(frame).c_str());
434 } 434 }
(...skipping 11 matching lines...) Expand all
446 446
447 if (shell_->ShouldDumpTitleChanges()) { 447 if (shell_->ShouldDumpTitleChanges()) {
448 printf("TITLE CHANGED: %S\n", title.c_str()); 448 printf("TITLE CHANGED: %S\n", title.c_str());
449 } 449 }
450 450
451 SetPageTitle(title); 451 SetPageTitle(title);
452 } 452 }
453 453
454 void TestWebViewDelegate::DidFinishLoadForFrame(WebView* webview, 454 void TestWebViewDelegate::DidFinishLoadForFrame(WebView* webview,
455 WebFrame* frame) { 455 WebFrame* frame) {
456 TRACE_EVENT_END("frame.load", this, frame->GetURL().spec()); 456 TRACE_EVENT_END("frame.load", this, frame->url().spec());
457 if (shell_->ShouldDumpFrameLoadCallbacks()) { 457 if (shell_->ShouldDumpFrameLoadCallbacks()) {
458 printf("%S - didFinishLoadForFrame\n", 458 printf("%S - didFinishLoadForFrame\n",
459 GetFrameDescription(frame).c_str()); 459 GetFrameDescription(frame).c_str());
460 } 460 }
461 461
462 UpdateAddressBar(webview); 462 UpdateAddressBar(webview);
463 LocationChangeDone(frame); 463 LocationChangeDone(frame);
464 } 464 }
465 465
466 void TestWebViewDelegate::DidFailLoadWithError(WebView* webview, 466 void TestWebViewDelegate::DidFailLoadWithError(WebView* webview,
467 const WebURLError& error, 467 const WebURLError& error,
468 WebFrame* frame) { 468 WebFrame* frame) {
469 if (shell_->ShouldDumpFrameLoadCallbacks()) { 469 if (shell_->ShouldDumpFrameLoadCallbacks()) {
470 printf("%S - didFailLoadWithError\n", 470 printf("%S - didFailLoadWithError\n",
471 GetFrameDescription(frame).c_str()); 471 GetFrameDescription(frame).c_str());
472 } 472 }
473 473
474 LocationChangeDone(frame); 474 LocationChangeDone(frame);
475 } 475 }
476 476
477 void TestWebViewDelegate::DidFinishDocumentLoadForFrame(WebView* webview, 477 void TestWebViewDelegate::DidFinishDocumentLoadForFrame(WebView* webview,
478 WebFrame* frame) { 478 WebFrame* frame) {
479 if (shell_->ShouldDumpFrameLoadCallbacks()) { 479 if (shell_->ShouldDumpFrameLoadCallbacks()) {
480 printf("%S - didFinishDocumentLoadForFrame\n", 480 printf("%S - didFinishDocumentLoadForFrame\n",
481 GetFrameDescription(frame).c_str()); 481 GetFrameDescription(frame).c_str());
482 } else { 482 } else {
483 unsigned pending_unload_events = frame->PendingFrameUnloadEventCount(); 483 unsigned pending_unload_events = frame->unloadListenerCount();
484 if (pending_unload_events) { 484 if (pending_unload_events) {
485 printf("%S - has %u onunload handler(s)\n", 485 printf("%S - has %u onunload handler(s)\n",
486 GetFrameDescription(frame).c_str(), pending_unload_events); 486 GetFrameDescription(frame).c_str(), pending_unload_events);
487 } 487 }
488 } 488 }
489 } 489 }
490 490
491 void TestWebViewDelegate::DidHandleOnloadEventsForFrame(WebView* webview, 491 void TestWebViewDelegate::DidHandleOnloadEventsForFrame(WebView* webview,
492 WebFrame* frame) { 492 WebFrame* frame) {
493 if (shell_->ShouldDumpFrameLoadCallbacks()) { 493 if (shell_->ShouldDumpFrameLoadCallbacks()) {
494 printf("%S - didHandleOnloadEventsForFrame\n", 494 printf("%S - didHandleOnloadEventsForFrame\n",
495 GetFrameDescription(frame).c_str()); 495 GetFrameDescription(frame).c_str());
496 } 496 }
497 } 497 }
498 498
499 void TestWebViewDelegate::DidChangeLocationWithinPageForFrame( 499 void TestWebViewDelegate::DidChangeLocationWithinPageForFrame(
500 WebView* webview, WebFrame* frame, bool is_new_navigation) { 500 WebView* webview, WebFrame* frame, bool is_new_navigation) {
501 frame->GetDataSource()->setExtraData(pending_extra_data_.release()); 501 frame->dataSource()->setExtraData(pending_extra_data_.release());
502 502
503 if (shell_->ShouldDumpFrameLoadCallbacks()) { 503 if (shell_->ShouldDumpFrameLoadCallbacks()) {
504 printf("%S - didChangeLocationWithinPageForFrame\n", 504 printf("%S - didChangeLocationWithinPageForFrame\n",
505 GetFrameDescription(frame).c_str()); 505 GetFrameDescription(frame).c_str());
506 } 506 }
507 507
508 UpdateForCommittedLoad(frame, is_new_navigation); 508 UpdateForCommittedLoad(frame, is_new_navigation);
509 } 509 }
510 510
511 void TestWebViewDelegate::DidReceiveIconForFrame(WebView* webview, 511 void TestWebViewDelegate::DidReceiveIconForFrame(WebView* webview,
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after
877 void TestWebViewDelegate::WaitForPolicyDelegate() { 877 void TestWebViewDelegate::WaitForPolicyDelegate() {
878 policy_delegate_enabled_ = true; 878 policy_delegate_enabled_ = true;
879 policy_delegate_should_notify_done_ = true; 879 policy_delegate_should_notify_done_ = true;
880 } 880 }
881 881
882 // Private methods ----------------------------------------------------------- 882 // Private methods -----------------------------------------------------------
883 883
884 void TestWebViewDelegate::UpdateAddressBar(WebView* webView) { 884 void TestWebViewDelegate::UpdateAddressBar(WebView* webView) {
885 WebFrame* mainFrame = webView->GetMainFrame(); 885 WebFrame* mainFrame = webView->GetMainFrame();
886 886
887 WebDataSource* dataSource = mainFrame->GetDataSource(); 887 WebDataSource* dataSource = mainFrame->dataSource();
888 if (!dataSource) 888 if (!dataSource)
889 dataSource = mainFrame->GetProvisionalDataSource(); 889 dataSource = mainFrame->provisionalDataSource();
890 if (!dataSource) 890 if (!dataSource)
891 return; 891 return;
892 892
893 // TODO(abarth): This is wrong! 893 // TODO(abarth): This is wrong!
894 SetAddressBarURL(dataSource->request().firstPartyForCookies()); 894 SetAddressBarURL(dataSource->request().firstPartyForCookies());
895 } 895 }
896 896
897 void TestWebViewDelegate::LocationChangeDone(WebFrame* frame) { 897 void TestWebViewDelegate::LocationChangeDone(WebFrame* frame) {
898 if (frame == top_loading_frame_) { 898 if (frame == top_loading_frame_) {
899 top_loading_frame_ = NULL; 899 top_loading_frame_ = NULL;
900 900
901 if (shell_->layout_test_mode()) 901 if (shell_->layout_test_mode())
902 shell_->layout_test_controller()->LocationChangeDone(); 902 shell_->layout_test_controller()->LocationChangeDone();
903 } 903 }
904 } 904 }
905 905
906 WebWidgetHost* TestWebViewDelegate::GetWidgetHost() { 906 WebWidgetHost* TestWebViewDelegate::GetWidgetHost() {
907 if (this == shell_->delegate()) 907 if (this == shell_->delegate())
908 return shell_->webViewHost(); 908 return shell_->webViewHost();
909 if (this == shell_->popup_delegate()) 909 if (this == shell_->popup_delegate())
910 return shell_->popupHost(); 910 return shell_->popupHost();
911 return NULL; 911 return NULL;
912 } 912 }
913 913
914 void TestWebViewDelegate::UpdateForCommittedLoad(WebFrame* frame, 914 void TestWebViewDelegate::UpdateForCommittedLoad(WebFrame* frame,
915 bool is_new_navigation) { 915 bool is_new_navigation) {
916 // Code duplicated from RenderView::DidCommitLoadForFrame. 916 // Code duplicated from RenderView::DidCommitLoadForFrame.
917 TestShellExtraData* extra_data = static_cast<TestShellExtraData*>( 917 TestShellExtraData* extra_data = static_cast<TestShellExtraData*>(
918 frame->GetDataSource()->extraData()); 918 frame->dataSource()->extraData());
919 919
920 if (is_new_navigation) { 920 if (is_new_navigation) {
921 // New navigation. 921 // New navigation.
922 UpdateSessionHistory(frame); 922 UpdateSessionHistory(frame);
923 page_id_ = next_page_id_++; 923 page_id_ = next_page_id_++;
924 } else if (extra_data && extra_data->pending_page_id != -1 && 924 } else if (extra_data && extra_data->pending_page_id != -1 &&
925 !extra_data->request_committed) { 925 !extra_data->request_committed) {
926 // This is a successful session history navigation! 926 // This is a successful session history navigation!
927 UpdateSessionHistory(frame); 927 UpdateSessionHistory(frame);
928 page_id_ = extra_data->pending_page_id; 928 page_id_ = extra_data->pending_page_id;
929 } 929 }
930 930
931 // Don't update session history multiple times. 931 // Don't update session history multiple times.
932 if (extra_data) 932 if (extra_data)
933 extra_data->request_committed = true; 933 extra_data->request_committed = true;
934 934
935 UpdateURL(frame); 935 UpdateURL(frame);
936 } 936 }
937 937
938 void TestWebViewDelegate::UpdateURL(WebFrame* frame) { 938 void TestWebViewDelegate::UpdateURL(WebFrame* frame) {
939 WebDataSource* ds = frame->GetDataSource(); 939 WebDataSource* ds = frame->dataSource();
940 DCHECK(ds); 940 DCHECK(ds);
941 941
942 const WebURLRequest& request = ds->request(); 942 const WebURLRequest& request = ds->request();
943 943
944 // Type is unused. 944 // Type is unused.
945 scoped_ptr<TestNavigationEntry> entry(new TestNavigationEntry); 945 scoped_ptr<TestNavigationEntry> entry(new TestNavigationEntry);
946 946
947 // Bug 654101: the referrer will be empty on https->http transitions. It 947 // Bug 654101: the referrer will be empty on https->http transitions. It
948 // would be nice if we could get the real referrer from somewhere. 948 // would be nice if we could get the real referrer from somewhere.
949 entry->SetPageID(page_id_); 949 entry->SetPageID(page_id_);
950 if (ds->hasUnreachableURL()) { 950 if (ds->hasUnreachableURL()) {
951 entry->SetURL(ds->unreachableURL()); 951 entry->SetURL(ds->unreachableURL());
952 } else { 952 } else {
953 entry->SetURL(request.url()); 953 entry->SetURL(request.url());
954 } 954 }
955 955
956 const WebHistoryItem& history_item = frame->GetCurrentHistoryItem(); 956 const WebHistoryItem& history_item = frame->currentHistoryItem();
957 if (!history_item.isNull()) 957 if (!history_item.isNull())
958 entry->SetContentState(webkit_glue::HistoryItemToString(history_item)); 958 entry->SetContentState(webkit_glue::HistoryItemToString(history_item));
959 959
960 shell_->navigation_controller()->DidNavigateToEntry(entry.release()); 960 shell_->navigation_controller()->DidNavigateToEntry(entry.release());
961 961
962 last_page_id_updated_ = std::max(last_page_id_updated_, page_id_); 962 last_page_id_updated_ = std::max(last_page_id_updated_, page_id_);
963 } 963 }
964 964
965 void TestWebViewDelegate::UpdateSessionHistory(WebFrame* frame) { 965 void TestWebViewDelegate::UpdateSessionHistory(WebFrame* frame) {
966 // If we have a valid page ID at this point, then it corresponds to the page 966 // If we have a valid page ID at this point, then it corresponds to the page
967 // we are navigating away from. Otherwise, this is the first navigation, so 967 // we are navigating away from. Otherwise, this is the first navigation, so
968 // there is no past session history to record. 968 // there is no past session history to record.
969 if (page_id_ == -1) 969 if (page_id_ == -1)
970 return; 970 return;
971 971
972 TestNavigationEntry* entry = static_cast<TestNavigationEntry*>( 972 TestNavigationEntry* entry = static_cast<TestNavigationEntry*>(
973 shell_->navigation_controller()->GetEntryWithPageID(page_id_)); 973 shell_->navigation_controller()->GetEntryWithPageID(page_id_));
974 if (!entry) 974 if (!entry)
975 return; 975 return;
976 976
977 const WebHistoryItem& history_item = 977 const WebHistoryItem& history_item =
978 shell_->webView()->GetMainFrame()->GetPreviousHistoryItem(); 978 shell_->webView()->GetMainFrame()->previousHistoryItem();
979 if (history_item.isNull()) 979 if (history_item.isNull())
980 return; 980 return;
981 981
982 entry->SetContentState(webkit_glue::HistoryItemToString(history_item)); 982 entry->SetContentState(webkit_glue::HistoryItemToString(history_item));
983 } 983 }
984 984
985 std::wstring TestWebViewDelegate::GetFrameDescription(WebFrame* webframe) { 985 std::wstring TestWebViewDelegate::GetFrameDescription(WebFrame* webframe) {
986 std::wstring name = webframe->GetName(); 986 std::wstring name = UTF16ToWideHack(webframe->name());
987 987
988 if (webframe == shell_->webView()->GetMainFrame()) { 988 if (webframe == shell_->webView()->GetMainFrame()) {
989 if (name.length()) 989 if (name.length())
990 return L"main frame \"" + name + L"\""; 990 return L"main frame \"" + name + L"\"";
991 else 991 else
992 return L"main frame"; 992 return L"main frame";
993 } else { 993 } else {
994 if (name.length()) 994 if (name.length())
995 return L"frame \"" + name + L"\""; 995 return L"frame \"" + name + L"\"";
996 else 996 else
997 return L"frame (anonymous)"; 997 return L"frame (anonymous)";
998 } 998 }
999 } 999 }
OLDNEW
« no previous file with comments | « webkit/tools/test_shell/test_webview_delegate.h ('k') | webkit/tools/test_shell/test_webview_delegate_gtk.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698