| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 |
| (...skipping 615 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 626 | 626 |
| 627 void TestWebViewDelegate::didCancelClientRedirect(WebFrame* frame) { | 627 void TestWebViewDelegate::didCancelClientRedirect(WebFrame* frame) { |
| 628 } | 628 } |
| 629 | 629 |
| 630 void TestWebViewDelegate::didCreateDataSource( | 630 void TestWebViewDelegate::didCreateDataSource( |
| 631 WebFrame* frame, WebDataSource* ds) { | 631 WebFrame* frame, WebDataSource* ds) { |
| 632 ds->setExtraData(pending_extra_data_.release()); | 632 ds->setExtraData(pending_extra_data_.release()); |
| 633 } | 633 } |
| 634 | 634 |
| 635 void TestWebViewDelegate::didStartProvisionalLoad(WebFrame* frame) { | 635 void TestWebViewDelegate::didStartProvisionalLoad(WebFrame* frame) { |
| 636 if (!top_loading_frame_) { | |
| 637 top_loading_frame_ = frame; | |
| 638 } | |
| 639 | |
| 640 UpdateAddressBar(frame->view()); | 636 UpdateAddressBar(frame->view()); |
| 641 } | 637 } |
| 642 | 638 |
| 643 void TestWebViewDelegate::didReceiveServerRedirectForProvisionalLoad( | 639 void TestWebViewDelegate::didReceiveServerRedirectForProvisionalLoad( |
| 644 WebFrame* frame) { | 640 WebFrame* frame) { |
| 645 UpdateAddressBar(frame->view()); | 641 UpdateAddressBar(frame->view()); |
| 646 } | 642 } |
| 647 | 643 |
| 648 void TestWebViewDelegate::didFailProvisionalLoad( | 644 void TestWebViewDelegate::didFailProvisionalLoad( |
| 649 WebFrame* frame, const WebURLError& error) { | 645 WebFrame* frame, const WebURLError& error) { |
| 650 LocationChangeDone(frame); | |
| 651 | |
| 652 // Don't display an error page if we're running layout tests, because | 646 // Don't display an error page if we're running layout tests, because |
| 653 // DumpRenderTree doesn't. | 647 // DumpRenderTree doesn't. |
| 654 if (shell_->layout_test_mode()) | 648 if (shell_->layout_test_mode()) |
| 655 return; | 649 return; |
| 656 | 650 |
| 657 // Don't display an error page if this is simply a cancelled load. Aside | 651 // Don't display an error page if this is simply a cancelled load. Aside |
| 658 // from being dumb, WebCore doesn't expect it and it will cause a crash. | 652 // from being dumb, WebCore doesn't expect it and it will cause a crash. |
| 659 if (error.reason == net::ERR_ABORTED) | 653 if (error.reason == net::ERR_ABORTED) |
| 660 return; | 654 return; |
| 661 | 655 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 698 unsigned pending_unload_events = frame->unloadListenerCount(); | 692 unsigned pending_unload_events = frame->unloadListenerCount(); |
| 699 if (pending_unload_events) { | 693 if (pending_unload_events) { |
| 700 printf("%s - has %u onunload handler(s)\n", | 694 printf("%s - has %u onunload handler(s)\n", |
| 701 UTF16ToUTF8(GetFrameDescription(frame)).c_str(), pending_unload_events); | 695 UTF16ToUTF8(GetFrameDescription(frame)).c_str(), pending_unload_events); |
| 702 } | 696 } |
| 703 } | 697 } |
| 704 | 698 |
| 705 void TestWebViewDelegate::didHandleOnloadEvents(WebFrame* frame) { | 699 void TestWebViewDelegate::didHandleOnloadEvents(WebFrame* frame) { |
| 706 } | 700 } |
| 707 | 701 |
| 708 void TestWebViewDelegate::didFailLoad( | |
| 709 WebFrame* frame, const WebURLError& error) { | |
| 710 LocationChangeDone(frame); | |
| 711 } | |
| 712 | |
| 713 void TestWebViewDelegate::didFinishLoad(WebFrame* frame) { | 702 void TestWebViewDelegate::didFinishLoad(WebFrame* frame) { |
| 714 TRACE_EVENT_END_ETW("frame.load", this, frame->document().url().spec()); | 703 TRACE_EVENT_END_ETW("frame.load", this, frame->document().url().spec()); |
| 715 UpdateAddressBar(frame->view()); | 704 UpdateAddressBar(frame->view()); |
| 716 LocationChangeDone(frame); | |
| 717 } | 705 } |
| 718 | 706 |
| 719 void TestWebViewDelegate::didNavigateWithinPage( | 707 void TestWebViewDelegate::didNavigateWithinPage( |
| 720 WebFrame* frame, bool is_new_navigation) { | 708 WebFrame* frame, bool is_new_navigation) { |
| 721 frame->dataSource()->setExtraData(pending_extra_data_.release()); | 709 frame->dataSource()->setExtraData(pending_extra_data_.release()); |
| 722 | 710 |
| 723 UpdateForCommittedLoad(frame, is_new_navigation); | 711 UpdateForCommittedLoad(frame, is_new_navigation); |
| 724 } | 712 } |
| 725 | 713 |
| 726 void TestWebViewDelegate::didChangeLocationWithinPage(WebFrame* frame) { | 714 void TestWebViewDelegate::didChangeLocationWithinPage(WebFrame* frame) { |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 826 return WebKit::Platform::current()->cookieJar(); | 814 return WebKit::Platform::current()->cookieJar(); |
| 827 } | 815 } |
| 828 | 816 |
| 829 // Public methods ------------------------------------------------------------ | 817 // Public methods ------------------------------------------------------------ |
| 830 | 818 |
| 831 TestWebViewDelegate::TestWebViewDelegate(TestShell* shell) | 819 TestWebViewDelegate::TestWebViewDelegate(TestShell* shell) |
| 832 : policy_delegate_enabled_(false), | 820 : policy_delegate_enabled_(false), |
| 833 policy_delegate_is_permissive_(false), | 821 policy_delegate_is_permissive_(false), |
| 834 policy_delegate_should_notify_done_(false), | 822 policy_delegate_should_notify_done_(false), |
| 835 shell_(shell), | 823 shell_(shell), |
| 836 top_loading_frame_(NULL), | |
| 837 page_id_(-1), | 824 page_id_(-1), |
| 838 last_page_id_updated_(-1), | 825 last_page_id_updated_(-1), |
| 839 using_fake_rect_(false), | 826 using_fake_rect_(false), |
| 840 #if defined(TOOLKIT_GTK) | 827 #if defined(TOOLKIT_GTK) |
| 841 cursor_type_(GDK_X_CURSOR), | 828 cursor_type_(GDK_X_CURSOR), |
| 842 #endif | 829 #endif |
| 843 block_redirects_(false), | 830 block_redirects_(false), |
| 844 request_return_null_(false) { | 831 request_return_null_(false) { |
| 845 } | 832 } |
| 846 | 833 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 887 | 874 |
| 888 WebDataSource* data_source = main_frame->dataSource(); | 875 WebDataSource* data_source = main_frame->dataSource(); |
| 889 if (!data_source) | 876 if (!data_source) |
| 890 data_source = main_frame->provisionalDataSource(); | 877 data_source = main_frame->provisionalDataSource(); |
| 891 if (!data_source) | 878 if (!data_source) |
| 892 return; | 879 return; |
| 893 | 880 |
| 894 SetAddressBarURL(data_source->request().url()); | 881 SetAddressBarURL(data_source->request().url()); |
| 895 } | 882 } |
| 896 | 883 |
| 897 void TestWebViewDelegate::LocationChangeDone(WebFrame* frame) { | |
| 898 if (frame == top_loading_frame_) { | |
| 899 top_loading_frame_ = NULL; | |
| 900 shell_->TestFinished(); | |
| 901 } | |
| 902 } | |
| 903 | |
| 904 WebWidgetHost* TestWebViewDelegate::GetWidgetHost() { | 884 WebWidgetHost* TestWebViewDelegate::GetWidgetHost() { |
| 905 if (this == shell_->delegate()) | 885 if (this == shell_->delegate()) |
| 906 return shell_->webViewHost(); | 886 return shell_->webViewHost(); |
| 907 if (this == shell_->popup_delegate()) | 887 if (this == shell_->popup_delegate()) |
| 908 return shell_->popupHost(); | 888 return shell_->popupHost(); |
| 909 return NULL; | 889 return NULL; |
| 910 } | 890 } |
| 911 | 891 |
| 912 void TestWebViewDelegate::UpdateForCommittedLoad(WebFrame* frame, | 892 void TestWebViewDelegate::UpdateForCommittedLoad(WebFrame* frame, |
| 913 bool is_new_navigation) { | 893 bool is_new_navigation) { |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1000 } | 980 } |
| 1001 | 981 |
| 1002 void TestWebViewDelegate::set_fake_window_rect(const WebRect& rect) { | 982 void TestWebViewDelegate::set_fake_window_rect(const WebRect& rect) { |
| 1003 fake_rect_ = rect; | 983 fake_rect_ = rect; |
| 1004 using_fake_rect_ = true; | 984 using_fake_rect_ = true; |
| 1005 } | 985 } |
| 1006 | 986 |
| 1007 WebRect TestWebViewDelegate::fake_window_rect() { | 987 WebRect TestWebViewDelegate::fake_window_rect() { |
| 1008 return fake_rect_; | 988 return fake_rect_; |
| 1009 } | 989 } |
| OLD | NEW |