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

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

Issue 9735: test_webview_delegate.cc was forked for the Mac test shell, and then (Closed)
Patch Set: Created 12 years, 1 month 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
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 "webkit/tools/test_shell/test_webview_delegate.h" 9 #include "webkit/tools/test_shell/test_webview_delegate.h"
10 10
11 #include <objidl.h> 11 #include "base/file_util.h"
12 #include <shlobj.h>
13 #include <shlwapi.h>
14
15 #include "base/gfx/point.h" 12 #include "base/gfx/point.h"
16 #include "base/message_loop.h" 13 #include "base/message_loop.h"
17 #include "base/string_util.h" 14 #include "base/string_util.h"
18 #include "base/trace_event.h" 15 #include "base/trace_event.h"
19 #include "net/base/net_errors.h" 16 #include "net/base/net_errors.h"
20 #include "webkit/glue/webdatasource.h" 17 #include "webkit/glue/webdatasource.h"
21 #include "webkit/glue/webdropdata.h" 18 #include "webkit/glue/webdropdata.h"
22 #include "webkit/glue/weberror.h" 19 #include "webkit/glue/weberror.h"
23 #include "webkit/glue/webframe.h" 20 #include "webkit/glue/webframe.h"
24 #include "webkit/glue/webpreferences.h" 21 #include "webkit/glue/webpreferences.h"
25 #include "webkit/glue/weburlrequest.h" 22 #include "webkit/glue/weburlrequest.h"
26 #include "webkit/glue/webkit_glue.h" 23 #include "webkit/glue/webkit_glue.h"
27 #include "webkit/glue/webview.h" 24 #include "webkit/glue/webview.h"
28 #include "webkit/glue/plugins/plugin_list.h" 25 #include "webkit/glue/plugins/plugin_list.h"
29 #include "webkit/glue/plugins/webplugin_delegate_impl.h"
30 #include "webkit/glue/window_open_disposition.h" 26 #include "webkit/glue/window_open_disposition.h"
31 #include "webkit/tools/test_shell/drag_delegate.h"
32 #include "webkit/tools/test_shell/drop_delegate.h"
33 #include "webkit/tools/test_shell/test_navigation_controller.h" 27 #include "webkit/tools/test_shell/test_navigation_controller.h"
34 #include "webkit/tools/test_shell/test_shell.h" 28 #include "webkit/tools/test_shell/test_shell.h"
35 29
30 #if defined(OS_WIN)
31 // TODO(port): make these files work everywhere.
32 #include "webkit/glue/plugins/webplugin_delegate_impl.h"
33 #include "webkit/tools/test_shell/drag_delegate.h"
34 #include "webkit/tools/test_shell/drop_delegate.h"
35 #endif
36
36 namespace { 37 namespace {
37 38
38 static int next_page_id_ = 1;
39
40 // Used to write a platform neutral file:/// URL by only taking the filename 39 // Used to write a platform neutral file:/// URL by only taking the filename
41 // (e.g., converts "file:///tmp/foo.txt" to just "foo.txt"). 40 // (e.g., converts "file:///tmp/foo.txt" to just "foo.txt").
42 std::wstring UrlSuitableForTestResult(const std::wstring& url) { 41 std::wstring UrlSuitableForTestResult(const std::wstring& url) {
43 if (url.empty() || std::wstring::npos == url.find(L"file://")) 42 if (url.empty() || std::wstring::npos == url.find(L"file://"))
44 return url; 43 return url;
45 44
46 return PathFindFileNameW(url.c_str()); 45 return file_util::GetFilenameFromPath(url);
47 } 46 }
48 47
49 // Adds a file called "DRTFakeFile" to |data_object| (CF_HDROP). Use to fake 48 int next_page_id_ = 1;
50 // dragging a file.
51 void AddDRTFakeFileToDataObject(IDataObject* data_object) {
52 STGMEDIUM medium = {0};
53 medium.tymed = TYMED_HGLOBAL;
54
55 const char filename[] = "DRTFakeFile";
56 const int filename_len = arraysize(filename);
57
58 // Allocate space for the DROPFILES struct, filename, and 2 null characters.
59 medium.hGlobal = GlobalAlloc(GPTR, sizeof(DROPFILES) + filename_len + 2);
60 DCHECK(medium.hGlobal);
61 DROPFILES* drop_files = static_cast<DROPFILES*>(GlobalLock(medium.hGlobal));
62 drop_files->pFiles = sizeof(DROPFILES);
63 drop_files->fWide = 0; // Filenames are ascii
64 strcpy_s(reinterpret_cast<char*>(drop_files) + sizeof(DROPFILES),
65 filename_len, filename);
66 GlobalUnlock(medium.hGlobal);
67
68 FORMATETC file_desc_fmt = {CF_HDROP, 0, DVASPECT_CONTENT, -1, TYMED_HGLOBAL};
69 data_object->SetData(&file_desc_fmt, &medium, TRUE);
70 }
71 49
72 } // namespace 50 } // namespace
73 51
74 // WebViewDelegate ----------------------------------------------------------- 52 // WebViewDelegate -----------------------------------------------------------
75 53
76 TestWebViewDelegate::~TestWebViewDelegate() {
77 if (custom_cursor_)
78 DestroyIcon(custom_cursor_);
79 RevokeDragDrop(shell_->webViewWnd());
80 }
81
82 WebView* TestWebViewDelegate::CreateWebView(WebView* webview, 54 WebView* TestWebViewDelegate::CreateWebView(WebView* webview,
83 bool user_gesture) { 55 bool user_gesture) {
84 return shell_->CreateWebView(webview); 56 return shell_->CreateWebView(webview);
85 } 57 }
86 58
87 WebWidget* TestWebViewDelegate::CreatePopupWidget(WebView* webview) { 59 WebWidget* TestWebViewDelegate::CreatePopupWidget(WebView* webview) {
88 return shell_->CreatePopupWidget(webview); 60 return shell_->CreatePopupWidget(webview);
89 } 61 }
90 62
91 WebPluginDelegate* TestWebViewDelegate::CreatePluginDelegate(
92 WebView* webview,
93 const GURL& url,
94 const std::string& mime_type,
95 const std::string& clsid,
96 std::string* actual_mime_type) {
97 HWND hwnd = GetContainingWindow(webview);
98 if (!hwnd)
99 return NULL;
100
101 bool allow_wildcard = true;
102 WebPluginInfo info;
103 if (!NPAPI::PluginList::Singleton()->GetPluginInfo(url, mime_type, clsid,
104 allow_wildcard, &info,
105 actual_mime_type))
106 return NULL;
107
108 if (actual_mime_type && !actual_mime_type->empty())
109 return WebPluginDelegateImpl::Create(info.file, *actual_mime_type, hwnd);
110 else
111 return WebPluginDelegateImpl::Create(info.file, mime_type, hwnd);
112 }
113
114 void TestWebViewDelegate::OpenURL(WebView* webview, const GURL& url, 63 void TestWebViewDelegate::OpenURL(WebView* webview, const GURL& url,
115 const GURL& referrer, 64 const GURL& referrer,
116 WindowOpenDisposition disposition) { 65 WindowOpenDisposition disposition) {
117 DCHECK_NE(disposition, CURRENT_TAB); // No code for this 66 DCHECK_NE(disposition, CURRENT_TAB); // No code for this
118 if (disposition == SUPPRESS_OPEN) 67 if (disposition == SUPPRESS_OPEN)
119 return; 68 return;
120 TestShell* shell; 69 TestShell* shell = NULL;
121 if (TestShell::CreateNewWindow(UTF8ToWide(url.spec()), &shell)) 70 if (TestShell::CreateNewWindow(UTF8ToWide(url.spec()), &shell))
122 shell->Show(shell->webView(), disposition); 71 shell->Show(shell->webView(), disposition);
123 } 72 }
124 73
125 void TestWebViewDelegate::DidStartLoading(WebView* webview) { 74 void TestWebViewDelegate::DidStartLoading(WebView* webview) {
126 if (page_is_loading_) { 75 if (page_is_loading_) {
127 LOG(ERROR) << "DidStartLoading called while loading"; 76 LOG(ERROR) << "DidStartLoading called while loading";
128 return; 77 return;
129 } 78 }
130 page_is_loading_ = true; 79 page_is_loading_ = true;
(...skipping 14 matching lines...) Expand all
145 WindowOpenDisposition TestWebViewDelegate::DispositionForNavigationAction( 94 WindowOpenDisposition TestWebViewDelegate::DispositionForNavigationAction(
146 WebView* webview, 95 WebView* webview,
147 WebFrame* frame, 96 WebFrame* frame,
148 const WebRequest* request, 97 const WebRequest* request,
149 WebNavigationType type, 98 WebNavigationType type,
150 WindowOpenDisposition disposition, 99 WindowOpenDisposition disposition,
151 bool is_redirect) { 100 bool is_redirect) {
152 if (is_custom_policy_delegate_) { 101 if (is_custom_policy_delegate_) {
153 std::wstring frame_name = frame->GetName(); 102 std::wstring frame_name = frame->GetName();
154 printf("Policy delegate: attempt to load %s\n", 103 printf("Policy delegate: attempt to load %s\n",
155 request->GetURL().spec().c_str()); 104 request->GetURL().spec().c_str());
156 return IGNORE_ACTION; 105 return IGNORE_ACTION;
157 } else { 106 } else {
158 return WebViewDelegate::DispositionForNavigationAction( 107 return WebViewDelegate::DispositionForNavigationAction(
159 webview, frame, request, type, disposition, is_redirect); 108 webview, frame, request, type, disposition, is_redirect);
160 } 109 }
161 } 110 }
162 111
163 void TestWebViewDelegate::SetCustomPolicyDelegate(bool isCustom) { 112 void TestWebViewDelegate::SetCustomPolicyDelegate(bool isCustom) {
164 is_custom_policy_delegate_ = isCustom; 113 is_custom_policy_delegate_ = isCustom;
165 } 114 }
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 const std::wstring& title, 247 const std::wstring& title,
299 WebFrame* frame) { 248 WebFrame* frame) {
300 if (shell_->ShouldDumpFrameLoadCallbacks()) { 249 if (shell_->ShouldDumpFrameLoadCallbacks()) {
301 printf("%S - didReceiveTitle\n", 250 printf("%S - didReceiveTitle\n",
302 GetFrameDescription(frame).c_str()); 251 GetFrameDescription(frame).c_str());
303 } 252 }
304 253
305 if (shell_->ShouldDumpTitleChanges()) { 254 if (shell_->ShouldDumpTitleChanges()) {
306 printf("TITLE CHANGED: %S\n", title.c_str()); 255 printf("TITLE CHANGED: %S\n", title.c_str());
307 } 256 }
257
258 SetPageTitle(title);
308 } 259 }
309 260
310 void TestWebViewDelegate::DidFinishLoadForFrame(WebView* webview, 261 void TestWebViewDelegate::DidFinishLoadForFrame(WebView* webview,
311 WebFrame* frame) { 262 WebFrame* frame) {
312 TRACE_EVENT_END("frame.load", this, frame->GetURL().spec()); 263 TRACE_EVENT_END("frame.load", this, frame->GetURL().spec());
313 if (shell_->ShouldDumpFrameLoadCallbacks()) { 264 if (shell_->ShouldDumpFrameLoadCallbacks()) {
314 printf("%S - didFinishLoadForFrame\n", 265 printf("%S - didFinishLoadForFrame\n",
315 GetFrameDescription(frame).c_str()); 266 GetFrameDescription(frame).c_str());
316 } 267 }
317 268
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 } 368 }
418 369
419 std::string utf8 = WideToUTF8(new_message); 370 std::string utf8 = WideToUTF8(new_message);
420 printf("CONSOLE MESSAGE: line %d: %s\n", line_no, utf8.c_str()); 371 printf("CONSOLE MESSAGE: line %d: %s\n", line_no, utf8.c_str());
421 } 372 }
422 } 373 }
423 374
424 void TestWebViewDelegate::RunJavaScriptAlert(WebView* webview, 375 void TestWebViewDelegate::RunJavaScriptAlert(WebView* webview,
425 const std::wstring& message) { 376 const std::wstring& message) {
426 if (shell_->interactive()) { 377 if (shell_->interactive()) {
427 MessageBox(shell_->mainWnd(), 378 ShowJavaScriptAlert(message);
428 message.c_str(),
429 L"JavaScript Alert",
430 MB_OK);
431 } else { 379 } else {
432 std::string utf8 = WideToUTF8(message); 380 std::string utf8 = WideToUTF8(message);
433 printf("ALERT: %s\n", utf8.c_str()); 381 printf("ALERT: %s\n", utf8.c_str());
434 } 382 }
435 } 383 }
436 384
437 bool TestWebViewDelegate::RunJavaScriptConfirm(WebView* webview, 385 bool TestWebViewDelegate::RunJavaScriptConfirm(WebView* webview,
438 const std::wstring& message) { 386 const std::wstring& message) {
439 if (!shell_->interactive()) { 387 if (!shell_->interactive()) {
440 // When running tests, write to stdout. 388 // When running tests, write to stdout.
(...skipping 11 matching lines...) Expand all
452 // When running tests, write to stdout. 400 // When running tests, write to stdout.
453 std::string utf8_message = WideToUTF8(message); 401 std::string utf8_message = WideToUTF8(message);
454 std::string utf8_default_value = WideToUTF8(default_value); 402 std::string utf8_default_value = WideToUTF8(default_value);
455 printf("PROMPT: %s, default text: %s\n", utf8_message.c_str(), 403 printf("PROMPT: %s, default text: %s\n", utf8_message.c_str(),
456 utf8_default_value.c_str()); 404 utf8_default_value.c_str());
457 return true; 405 return true;
458 } 406 }
459 return false; 407 return false;
460 } 408 }
461 409
462 void TestWebViewDelegate::StartDragging(WebView* webview,
463 const WebDropData& drop_data) {
464
465 if (!drag_delegate_)
466 drag_delegate_ = new TestDragDelegate(shell_->webViewWnd(),
467 shell_->webView());
468 if (webkit_glue::IsLayoutTestMode()) {
469 if (shell_->layout_test_controller()->ShouldAddFileToPasteboard()) {
470 // Add a file called DRTFakeFile to the drag&drop clipboard.
471 AddDRTFakeFileToDataObject(drop_data.data_object);
472 }
473
474 // When running a test, we need to fake a drag drop operation otherwise
475 // Windows waits for real mouse events to know when the drag is over.
476 EventSendingController::DoDragDrop(drop_data.data_object);
477 } else {
478 const DWORD ok_effect = DROPEFFECT_COPY | DROPEFFECT_LINK | DROPEFFECT_MOVE;
479 DWORD effect;
480 HRESULT res = DoDragDrop(drop_data.data_object, drag_delegate_.get(),
481 ok_effect, &effect);
482 DCHECK(DRAGDROP_S_DROP == res || DRAGDROP_S_CANCEL == res);
483 }
484 webview->DragSourceSystemDragEnded();
485 }
486
487 void TestWebViewDelegate::ShowContextMenu(WebView* webview, 410 void TestWebViewDelegate::ShowContextMenu(WebView* webview,
488 ContextNode::Type type, 411 ContextNode::Type type,
489 int x, 412 int x,
490 int y, 413 int y,
491 const GURL& link_url, 414 const GURL& link_url,
492 const GURL& image_url, 415 const GURL& image_url,
493 const GURL& page_url, 416 const GURL& page_url,
494 const GURL& frame_url, 417 const GURL& frame_url,
495 const std::wstring& selection_text, 418 const std::wstring& selection_text,
496 const std::wstring& misspelled_word, 419 const std::wstring& misspelled_word,
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
653 576
654 void TestWebViewDelegate::SetUserStyleSheetLocation(const GURL& location) { 577 void TestWebViewDelegate::SetUserStyleSheetLocation(const GURL& location) {
655 WebPreferences* prefs = shell_->GetWebPreferences(); 578 WebPreferences* prefs = shell_->GetWebPreferences();
656 prefs->user_style_sheet_enabled = true; 579 prefs->user_style_sheet_enabled = true;
657 prefs->user_style_sheet_location = location; 580 prefs->user_style_sheet_location = location;
658 shell_->webView()->SetPreferences(*prefs); 581 shell_->webView()->SetPreferences(*prefs);
659 } 582 }
660 583
661 // WebWidgetDelegate --------------------------------------------------------- 584 // WebWidgetDelegate ---------------------------------------------------------
662 585
663 HWND TestWebViewDelegate::GetContainingWindow(WebWidget* webwidget) { 586 gfx::ViewHandle TestWebViewDelegate::GetContainingWindow(WebWidget* webwidget) {
664 if (WebWidgetHost* host = GetHostForWidget(webwidget)) 587 if (WebWidgetHost* host = GetHostForWidget(webwidget))
665 return host->window_handle(); 588 return host->window_handle();
666 589
667 return NULL; 590 return NULL;
668 } 591 }
669 592
670 void TestWebViewDelegate::DidInvalidateRect(WebWidget* webwidget, 593 void TestWebViewDelegate::DidInvalidateRect(WebWidget* webwidget,
671 const gfx::Rect& rect) { 594 const gfx::Rect& rect) {
672 if (WebWidgetHost* host = GetHostForWidget(webwidget)) 595 if (WebWidgetHost* host = GetHostForWidget(webwidget))
673 host->DidInvalidateRect(rect); 596 host->DidInvalidateRect(rect);
674 } 597 }
675 598
676 void TestWebViewDelegate::DidScrollRect(WebWidget* webwidget, int dx, int dy, 599 void TestWebViewDelegate::DidScrollRect(WebWidget* webwidget, int dx, int dy,
677 const gfx::Rect& clip_rect) { 600 const gfx::Rect& clip_rect) {
678 if (WebWidgetHost* host = GetHostForWidget(webwidget)) 601 if (WebWidgetHost* host = GetHostForWidget(webwidget))
679 host->DidScrollRect(dx, dy, clip_rect); 602 host->DidScrollRect(dx, dy, clip_rect);
680 } 603 }
681 604
682 void TestWebViewDelegate::Show(WebWidget* webwidget, WindowOpenDisposition) {
683 if (webwidget == shell_->webView()) {
684 ShowWindow(shell_->mainWnd(), SW_SHOW);
685 UpdateWindow(shell_->mainWnd());
686 } else if (webwidget == shell_->popup()) {
687 ShowWindow(shell_->popupWnd(), SW_SHOW);
688 UpdateWindow(shell_->popupWnd());
689 }
690 }
691
692 void TestWebViewDelegate::CloseWidgetSoon(WebWidget* webwidget) {
693 if (webwidget == shell_->webView()) {
694 PostMessage(shell_->mainWnd(), WM_CLOSE, 0, 0);
695 } else if (webwidget == shell_->popup()) {
696 shell_->ClosePopup();
697 }
698 }
699
700 void TestWebViewDelegate::Focus(WebWidget* webwidget) { 605 void TestWebViewDelegate::Focus(WebWidget* webwidget) {
701 if (WebWidgetHost* host = GetHostForWidget(webwidget)) 606 if (WebWidgetHost* host = GetHostForWidget(webwidget))
702 shell_->SetFocus(host, true); 607 shell_->SetFocus(host, true);
703 } 608 }
704 609
705 void TestWebViewDelegate::Blur(WebWidget* webwidget) { 610 void TestWebViewDelegate::Blur(WebWidget* webwidget) {
706 if (WebWidgetHost* host = GetHostForWidget(webwidget)) 611 if (WebWidgetHost* host = GetHostForWidget(webwidget))
707 shell_->SetFocus(host, false); 612 shell_->SetFocus(host, false);
708 } 613 }
709 614
710 void TestWebViewDelegate::SetCursor(WebWidget* webwidget,
711 const WebCursor& cursor) {
712 if (WebWidgetHost* host = GetHostForWidget(webwidget)) {
713 if (custom_cursor_) {
714 DestroyIcon(custom_cursor_);
715 custom_cursor_ = NULL;
716 }
717 if (cursor.IsCustom()) {
718 custom_cursor_ = cursor.GetCustomCursor();
719 host->SetCursor(custom_cursor_);
720 } else {
721 HINSTANCE mod_handle = GetModuleHandle(NULL);
722 host->SetCursor(cursor.GetCursor(mod_handle));
723 }
724 }
725 }
726
727 void TestWebViewDelegate::GetWindowRect(WebWidget* webwidget,
728 gfx::Rect* out_rect) {
729 if (WebWidgetHost* host = GetHostForWidget(webwidget)) {
730 RECT rect;
731 ::GetWindowRect(host->window_handle(), &rect);
732 *out_rect = gfx::Rect(rect);
733 }
734 }
735
736 void TestWebViewDelegate::SetWindowRect(WebWidget* webwidget,
737 const gfx::Rect& rect) {
738 if (webwidget == shell_->webView()) {
739 // ignored
740 } else if (webwidget == shell_->popup()) {
741 MoveWindow(shell_->popupWnd(),
742 rect.x(), rect.y(), rect.width(), rect.height(), FALSE);
743 }
744 }
745
746 void TestWebViewDelegate::GetRootWindowRect(WebWidget* webwidget,
747 gfx::Rect* out_rect) {
748 if (WebWidgetHost* host = GetHostForWidget(webwidget)) {
749 RECT rect;
750 HWND root_window = ::GetAncestor(host->window_handle(), GA_ROOT);
751 ::GetWindowRect(root_window, &rect);
752 *out_rect = gfx::Rect(rect);
753 }
754 }
755 615
756 void TestWebViewDelegate::DidMove(WebWidget* webwidget, 616 void TestWebViewDelegate::DidMove(WebWidget* webwidget,
757 const WebPluginGeometry& move) { 617 const WebPluginGeometry& move) {
618 #if defined(OS_WIN)
619 // TODO(port): add me once plugins work.
758 WebPluginDelegateImpl::MoveWindow( 620 WebPluginDelegateImpl::MoveWindow(
759 move.window, move.window_rect, move.clip_rect, move.cutout_rects, 621 move.window, move.window_rect, move.clip_rect, move.cutout_rects,
760 move.visible); 622 move.visible);
761 } 623 #endif
762
763 void TestWebViewDelegate::RunModal(WebWidget* webwidget) {
764 Show(webwidget, NEW_WINDOW);
765
766 WindowList* wl = TestShell::windowList();
767 for (WindowList::const_iterator i = wl->begin(); i != wl->end(); ++i) {
768 if (*i != shell_->mainWnd())
769 EnableWindow(*i, FALSE);
770 }
771
772 shell_->set_is_modal(true);
773 MessageLoop::current()->Run();
774
775 for (WindowList::const_iterator i = wl->begin(); i != wl->end(); ++i)
776 EnableWindow(*i, TRUE);
777 } 624 }
778 625
779 bool TestWebViewDelegate::IsHidden() { 626 bool TestWebViewDelegate::IsHidden() {
780 return false; 627 return false;
781 } 628 }
782 629
783 void TestWebViewDelegate::RegisterDragDrop() { 630 void TestWebViewDelegate::RegisterDragDrop() {
631 #if defined(OS_WIN)
632 // TODO(port): add me once drag and drop works.
784 DCHECK(!drop_delegate_); 633 DCHECK(!drop_delegate_);
785 drop_delegate_ = new TestDropDelegate(shell_->webViewWnd(), 634 drop_delegate_ = new TestDropDelegate(shell_->webViewWnd(),
786 shell_->webView()); 635 shell_->webView());
636 #endif
787 } 637 }
788 638
789 // Private methods ----------------------------------------------------------- 639 // Private methods -----------------------------------------------------------
790 640
791 void TestWebViewDelegate::UpdateAddressBar(WebView* webView) { 641 void TestWebViewDelegate::UpdateAddressBar(WebView* webView) {
792 WebFrame* mainFrame = webView->GetMainFrame(); 642 WebFrame* mainFrame = webView->GetMainFrame();
793 643
794 WebDataSource* dataSource = mainFrame->GetDataSource(); 644 WebDataSource* dataSource = mainFrame->GetDataSource();
795 if (!dataSource) 645 if (!dataSource)
796 dataSource = mainFrame->GetProvisionalDataSource(); 646 dataSource = mainFrame->GetProvisionalDataSource();
797 if (!dataSource) 647 if (!dataSource)
798 return; 648 return;
799 649
800 std::wstring frameURL = 650 SetAddressBarURL(dataSource->GetRequest().GetMainDocumentURL());
801 UTF8ToWide(dataSource->GetRequest().GetMainDocumentURL().spec());
802 SendMessage(shell_->editWnd(), WM_SETTEXT, 0,
803 reinterpret_cast<LPARAM>(frameURL.c_str()));
804 } 651 }
805 652
806 void TestWebViewDelegate::LocationChangeDone(WebDataSource* data_source) { 653 void TestWebViewDelegate::LocationChangeDone(WebDataSource* data_source) {
807 if (data_source->GetWebFrame() == top_loading_frame_) { 654 if (data_source->GetWebFrame() == top_loading_frame_) {
808 top_loading_frame_ = NULL; 655 top_loading_frame_ = NULL;
809 656
810 if (!shell_->interactive()) 657 if (!shell_->interactive())
811 shell_->layout_test_controller()->LocationChangeDone(); 658 shell_->layout_test_controller()->LocationChangeDone();
812 } 659 }
813 } 660 }
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
847 694
848 UpdateURL(frame); 695 UpdateURL(frame);
849 } 696 }
850 697
851 void TestWebViewDelegate::UpdateURL(WebFrame* frame) { 698 void TestWebViewDelegate::UpdateURL(WebFrame* frame) {
852 WebDataSource* ds = frame->GetDataSource(); 699 WebDataSource* ds = frame->GetDataSource();
853 DCHECK(ds); 700 DCHECK(ds);
854 701
855 const WebRequest& request = ds->GetRequest(); 702 const WebRequest& request = ds->GetRequest();
856 703
857 // We don't hold a reference to the extra data. The request's reference will
858 // be sufficient because we won't modify it during our call. MAY BE NULL.
859 TestShellExtraRequestData* extra_data =
860 static_cast<TestShellExtraRequestData*>(request.GetExtraData());
861
862 // Type is unused. 704 // Type is unused.
863 scoped_ptr<TestNavigationEntry> entry(new TestNavigationEntry); 705 scoped_ptr<TestNavigationEntry> entry(new TestNavigationEntry);
864 706
865 // Bug 654101: the referrer will be empty on https->http transitions. It 707 // Bug 654101: the referrer will be empty on https->http transitions. It
866 // would be nice if we could get the real referrer from somewhere. 708 // would be nice if we could get the real referrer from somewhere.
867 entry->SetPageID(page_id_); 709 entry->SetPageID(page_id_);
868 if (ds->HasUnreachableURL()) { 710 if (ds->HasUnreachableURL()) {
869 entry->SetURL(GURL(ds->GetUnreachableURL())); 711 entry->SetURL(GURL(ds->GetUnreachableURL()));
870 } else { 712 } else {
871 entry->SetURL(GURL(request.GetURL())); 713 entry->SetURL(GURL(request.GetURL()));
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
909 else 751 else
910 return L"main frame"; 752 return L"main frame";
911 } else { 753 } else {
912 if (name.length()) 754 if (name.length())
913 return L"frame \"" + name + L"\""; 755 return L"frame \"" + name + L"\"";
914 else 756 else
915 return L"frame (anonymous)"; 757 return L"frame (anonymous)";
916 } 758 }
917 } 759 }
918 760
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698