| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 #include "chrome/renderer/net/net_error_helper.h" | 5 #include "chrome/renderer/net/net_error_helper.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 using error_page::ErrorPageParams; | 59 using error_page::ErrorPageParams; |
| 60 using error_page::LocalizedError; | 60 using error_page::LocalizedError; |
| 61 using error_page::NetErrorHelperCore; | 61 using error_page::NetErrorHelperCore; |
| 62 | 62 |
| 63 namespace { | 63 namespace { |
| 64 | 64 |
| 65 // Number of seconds to wait for the navigation correction service to return | 65 // Number of seconds to wait for the navigation correction service to return |
| 66 // suggestions. If it takes too long, just use the local error page. | 66 // suggestions. If it takes too long, just use the local error page. |
| 67 const int kNavigationCorrectionFetchTimeoutSec = 3; | 67 const int kNavigationCorrectionFetchTimeoutSec = 3; |
| 68 | 68 |
| 69 NetErrorHelperCore::PageType GetLoadingPageType(RenderFrame* render_frame) { | 69 NetErrorHelperCore::PageType GetLoadingPageType( |
| 70 blink::WebFrame* web_frame = render_frame->GetWebFrame(); | 70 blink::WebDataSource* data_source) { |
| 71 GURL url = web_frame->provisionalDataSource()->getRequest().url(); | 71 GURL url = data_source->getRequest().url(); |
| 72 if (!url.is_valid() || url.spec() != kUnreachableWebDataURL) | 72 if (!url.is_valid() || url.spec() != kUnreachableWebDataURL) |
| 73 return NetErrorHelperCore::NON_ERROR_PAGE; | 73 return NetErrorHelperCore::NON_ERROR_PAGE; |
| 74 return NetErrorHelperCore::ERROR_PAGE; | 74 return NetErrorHelperCore::ERROR_PAGE; |
| 75 } | 75 } |
| 76 | 76 |
| 77 NetErrorHelperCore::FrameType GetFrameType(RenderFrame* render_frame) { | 77 NetErrorHelperCore::FrameType GetFrameType(RenderFrame* render_frame) { |
| 78 if (render_frame->IsMainFrame()) | 78 if (render_frame->IsMainFrame()) |
| 79 return NetErrorHelperCore::MAIN_FRAME; | 79 return NetErrorHelperCore::MAIN_FRAME; |
| 80 return NetErrorHelperCore::SUB_FRAME; | 80 return NetErrorHelperCore::SUB_FRAME; |
| 81 } | 81 } |
| (...skipping 29 matching lines...) Expand all Loading... |
| 111 | 111 |
| 112 void NetErrorHelper::ButtonPressed( | 112 void NetErrorHelper::ButtonPressed( |
| 113 error_page::NetErrorHelperCore::Button button) { | 113 error_page::NetErrorHelperCore::Button button) { |
| 114 core_->ExecuteButtonPress(button); | 114 core_->ExecuteButtonPress(button); |
| 115 } | 115 } |
| 116 | 116 |
| 117 void NetErrorHelper::TrackClick(int tracking_id) { | 117 void NetErrorHelper::TrackClick(int tracking_id) { |
| 118 core_->TrackClick(tracking_id); | 118 core_->TrackClick(tracking_id); |
| 119 } | 119 } |
| 120 | 120 |
| 121 void NetErrorHelper::DidStartProvisionalLoad() { | 121 void NetErrorHelper::DidStartProvisionalLoad( |
| 122 blink::WebDataSource* data_source) { |
| 122 core_->OnStartLoad(GetFrameType(render_frame()), | 123 core_->OnStartLoad(GetFrameType(render_frame()), |
| 123 GetLoadingPageType(render_frame())); | 124 GetLoadingPageType(data_source)); |
| 124 } | 125 } |
| 125 | 126 |
| 126 void NetErrorHelper::DidCommitProvisionalLoad(bool is_new_navigation, | 127 void NetErrorHelper::DidCommitProvisionalLoad(bool is_new_navigation, |
| 127 bool is_same_page_navigation) { | 128 bool is_same_page_navigation) { |
| 128 // If this is a "same page" navigation, it's not a real navigation. There | 129 // If this is a "same page" navigation, it's not a real navigation. There |
| 129 // wasn't a start event for it, either, so just ignore it. | 130 // wasn't a start event for it, either, so just ignore it. |
| 130 if (is_same_page_navigation) | 131 if (is_same_page_navigation) |
| 131 return; | 132 return; |
| 132 | 133 |
| 133 // Invalidate weak pointers from old error page controllers. If loading a new | 134 // Invalidate weak pointers from old error page controllers. If loading a new |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 384 | 385 |
| 385 void NetErrorHelper::OnNetworkDiagnosticsClientRequest( | 386 void NetErrorHelper::OnNetworkDiagnosticsClientRequest( |
| 386 chrome::mojom::NetworkDiagnosticsClientAssociatedRequest request) { | 387 chrome::mojom::NetworkDiagnosticsClientAssociatedRequest request) { |
| 387 DCHECK(!network_diagnostics_client_binding_.is_bound()); | 388 DCHECK(!network_diagnostics_client_binding_.is_bound()); |
| 388 network_diagnostics_client_binding_.Bind(std::move(request)); | 389 network_diagnostics_client_binding_.Bind(std::move(request)); |
| 389 } | 390 } |
| 390 | 391 |
| 391 void NetErrorHelper::SetCanShowNetworkDiagnosticsDialog(bool can_show) { | 392 void NetErrorHelper::SetCanShowNetworkDiagnosticsDialog(bool can_show) { |
| 392 core_->OnSetCanShowNetworkDiagnosticsDialog(can_show); | 393 core_->OnSetCanShowNetworkDiagnosticsDialog(can_show); |
| 393 } | 394 } |
| OLD | NEW |