| 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 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 shell_->BindJSObjectsToWindow(webframe); | 129 shell_->BindJSObjectsToWindow(webframe); |
| 130 } | 130 } |
| 131 | 131 |
| 132 WindowOpenDisposition TestWebViewDelegate::DispositionForNavigationAction( | 132 WindowOpenDisposition TestWebViewDelegate::DispositionForNavigationAction( |
| 133 WebView* webview, | 133 WebView* webview, |
| 134 WebFrame* frame, | 134 WebFrame* frame, |
| 135 const WebRequest* request, | 135 const WebRequest* request, |
| 136 WebNavigationType type, | 136 WebNavigationType type, |
| 137 WindowOpenDisposition disposition, | 137 WindowOpenDisposition disposition, |
| 138 bool is_redirect) { | 138 bool is_redirect) { |
| 139 if (is_custom_policy_delegate_) { | 139 WindowOpenDisposition result; |
| 140 if (policy_delegate_enabled_) { |
| 140 std::wstring frame_name = frame->GetName(); | 141 std::wstring frame_name = frame->GetName(); |
| 142 std::string url_description; |
| 143 if (request->GetURL().SchemeIs("file")) { |
| 144 url_description = request->GetURL().ExtractFileName(); |
| 145 } else { |
| 146 url_description = request->GetURL().spec(); |
| 147 } |
| 141 printf("Policy delegate: attempt to load %s with navigation type '%s'\n", | 148 printf("Policy delegate: attempt to load %s with navigation type '%s'\n", |
| 142 request->GetURL().spec().c_str(), WebNavigationTypeToString(type)); | 149 url_description.c_str(), WebNavigationTypeToString(type)); |
| 143 return IGNORE_ACTION; | 150 result = policy_delegate_is_permissive_ ? CURRENT_TAB : IGNORE_ACTION; |
| 151 if (policy_delegate_should_notify_done_) |
| 152 shell_->layout_test_controller()->PolicyDelegateDone(); |
| 144 } else { | 153 } else { |
| 145 return WebViewDelegate::DispositionForNavigationAction( | 154 result = WebViewDelegate::DispositionForNavigationAction( |
| 146 webview, frame, request, type, disposition, is_redirect); | 155 webview, frame, request, type, disposition, is_redirect); |
| 147 } | 156 } |
| 148 } | 157 return result; |
| 149 | |
| 150 | |
| 151 void TestWebViewDelegate::SetCustomPolicyDelegate(bool isCustom) { | |
| 152 is_custom_policy_delegate_ = isCustom; | |
| 153 } | 158 } |
| 154 | 159 |
| 155 void TestWebViewDelegate::AssignIdentifierToRequest(WebView* webview, | 160 void TestWebViewDelegate::AssignIdentifierToRequest(WebView* webview, |
| 156 uint32 identifier, | 161 uint32 identifier, |
| 157 const WebRequest& request) { | 162 const WebRequest& request) { |
| 158 if (shell_->ShouldDumpResourceLoadCallbacks()) { | 163 if (shell_->ShouldDumpResourceLoadCallbacks()) { |
| 159 resource_identifier_map_[identifier] = request.GetURL().possibly_invalid_spe
c(); | 164 resource_identifier_map_[identifier] = request.GetURL().possibly_invalid_spe
c(); |
| 160 } | 165 } |
| 161 } | 166 } |
| 162 | 167 |
| (...skipping 577 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 740 | 745 |
| 741 void TestWebViewDelegate::RegisterDragDrop() { | 746 void TestWebViewDelegate::RegisterDragDrop() { |
| 742 #if defined(OS_WIN) | 747 #if defined(OS_WIN) |
| 743 // TODO(port): add me once drag and drop works. | 748 // TODO(port): add me once drag and drop works. |
| 744 DCHECK(!drop_delegate_); | 749 DCHECK(!drop_delegate_); |
| 745 drop_delegate_ = new TestDropDelegate(shell_->webViewWnd(), | 750 drop_delegate_ = new TestDropDelegate(shell_->webViewWnd(), |
| 746 shell_->webView()); | 751 shell_->webView()); |
| 747 #endif | 752 #endif |
| 748 } | 753 } |
| 749 | 754 |
| 755 void TestWebViewDelegate::SetCustomPolicyDelegate(bool is_custom, |
| 756 bool is_permissive) { |
| 757 policy_delegate_enabled_ = is_custom; |
| 758 policy_delegate_is_permissive_ = is_permissive; |
| 759 } |
| 760 |
| 761 void TestWebViewDelegate::WaitForPolicyDelegate() { |
| 762 policy_delegate_enabled_ = true; |
| 763 policy_delegate_should_notify_done_ = true; |
| 764 } |
| 765 |
| 750 // Private methods ----------------------------------------------------------- | 766 // Private methods ----------------------------------------------------------- |
| 751 | 767 |
| 752 void TestWebViewDelegate::UpdateAddressBar(WebView* webView) { | 768 void TestWebViewDelegate::UpdateAddressBar(WebView* webView) { |
| 753 WebFrame* mainFrame = webView->GetMainFrame(); | 769 WebFrame* mainFrame = webView->GetMainFrame(); |
| 754 | 770 |
| 755 WebDataSource* dataSource = mainFrame->GetDataSource(); | 771 WebDataSource* dataSource = mainFrame->GetDataSource(); |
| 756 if (!dataSource) | 772 if (!dataSource) |
| 757 dataSource = mainFrame->GetProvisionalDataSource(); | 773 dataSource = mainFrame->GetProvisionalDataSource(); |
| 758 if (!dataSource) | 774 if (!dataSource) |
| 759 return; | 775 return; |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 863 } | 879 } |
| 864 } | 880 } |
| 865 | 881 |
| 866 WebWorker* TestWebViewDelegate::CreateWebWorker(WebWorkerClient* client) { | 882 WebWorker* TestWebViewDelegate::CreateWebWorker(WebWorkerClient* client) { |
| 867 #if ENABLE(WORKERS) | 883 #if ENABLE(WORKERS) |
| 868 return TestWebWorkerHelper::CreateWebWorker(client); | 884 return TestWebWorkerHelper::CreateWebWorker(client); |
| 869 #else | 885 #else |
| 870 return NULL; | 886 return NULL; |
| 871 #endif | 887 #endif |
| 872 } | 888 } |
| OLD | NEW |