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 #include "chrome/browser/captive_portal/captive_portal_tab_helper.h" | 5 #include "chrome/browser/captive_portal/captive_portal_tab_helper.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "chrome/browser/captive_portal/captive_portal_login_detector.h" | 8 #include "chrome/browser/captive_portal/captive_portal_login_detector.h" |
9 #include "chrome/browser/captive_portal/captive_portal_service_factory.h" | 9 #include "chrome/browser/captive_portal/captive_portal_service_factory.h" |
10 #include "chrome/browser/captive_portal/captive_portal_tab_reloader.h" | 10 #include "chrome/browser/captive_portal/captive_portal_tab_reloader.h" |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 // row. The second time, provisional_render_view_host_ will be NULL. | 86 // row. The second time, provisional_render_view_host_ will be NULL. |
87 if (is_error_page && provisional_render_view_host_ == render_view_host) | 87 if (is_error_page && provisional_render_view_host_ == render_view_host) |
88 return; | 88 return; |
89 // Otherwise, abort the old load. | 89 // Otherwise, abort the old load. |
90 OnLoadAborted(); | 90 OnLoadAborted(); |
91 } | 91 } |
92 | 92 |
93 provisional_render_view_host_ = render_view_host; | 93 provisional_render_view_host_ = render_view_host; |
94 pending_error_code_ = net::OK; | 94 pending_error_code_ = net::OK; |
95 | 95 |
96 tab_reloader_->OnLoadStart(validated_url.SchemeIsSecure()); | 96 tab_reloader_->OnLoadStart(validated_url.SchemeUsesTLS()); |
97 } | 97 } |
98 | 98 |
99 void CaptivePortalTabHelper::DidCommitProvisionalLoadForFrame( | 99 void CaptivePortalTabHelper::DidCommitProvisionalLoadForFrame( |
100 content::RenderFrameHost* render_frame_host, | 100 content::RenderFrameHost* render_frame_host, |
101 const GURL& url, | 101 const GURL& url, |
102 ui::PageTransition transition_type) { | 102 ui::PageTransition transition_type) { |
103 DCHECK(CalledOnValidThread()); | 103 DCHECK(CalledOnValidThread()); |
104 | 104 |
105 // Ignore subframes. | 105 // Ignore subframes. |
106 if (render_frame_host->GetParent()) | 106 if (render_frame_host->GetParent()) |
107 return; | 107 return; |
108 | 108 |
109 if (provisional_render_view_host_ == render_frame_host->GetRenderViewHost()) { | 109 if (provisional_render_view_host_ == render_frame_host->GetRenderViewHost()) { |
110 tab_reloader_->OnLoadCommitted(pending_error_code_); | 110 tab_reloader_->OnLoadCommitted(pending_error_code_); |
111 } else { | 111 } else { |
112 // This may happen if the active RenderView commits a page before a cross | 112 // This may happen if the active RenderView commits a page before a cross |
113 // process navigation cancels the old load. In this case, the commit of the | 113 // process navigation cancels the old load. In this case, the commit of the |
114 // old navigation will cancel the newer one. | 114 // old navigation will cancel the newer one. |
115 OnLoadAborted(); | 115 OnLoadAborted(); |
116 | 116 |
117 // Send information about the new load. | 117 // Send information about the new load. |
118 tab_reloader_->OnLoadStart(url.SchemeIsSecure()); | 118 tab_reloader_->OnLoadStart(url.SchemeUsesTLS()); |
119 tab_reloader_->OnLoadCommitted(net::OK); | 119 tab_reloader_->OnLoadCommitted(net::OK); |
120 } | 120 } |
121 | 121 |
122 provisional_render_view_host_ = NULL; | 122 provisional_render_view_host_ = NULL; |
123 pending_error_code_ = net::OK; | 123 pending_error_code_ = net::OK; |
124 } | 124 } |
125 | 125 |
126 void CaptivePortalTabHelper::DidFailProvisionalLoad( | 126 void CaptivePortalTabHelper::DidFailProvisionalLoad( |
127 content::RenderFrameHost* render_frame_host, | 127 content::RenderFrameHost* render_frame_host, |
128 const GURL& validated_url, | 128 const GURL& validated_url, |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 void CaptivePortalTabHelper::OnRedirect(int child_id, | 232 void CaptivePortalTabHelper::OnRedirect(int child_id, |
233 ResourceType resource_type, | 233 ResourceType resource_type, |
234 const GURL& new_url) { | 234 const GURL& new_url) { |
235 // Only main frame redirects for the provisional RenderViewHost matter. | 235 // Only main frame redirects for the provisional RenderViewHost matter. |
236 if (resource_type != content::RESOURCE_TYPE_MAIN_FRAME || | 236 if (resource_type != content::RESOURCE_TYPE_MAIN_FRAME || |
237 !provisional_render_view_host_ || | 237 !provisional_render_view_host_ || |
238 provisional_render_view_host_->GetProcess()->GetID() != child_id) { | 238 provisional_render_view_host_->GetProcess()->GetID() != child_id) { |
239 return; | 239 return; |
240 } | 240 } |
241 | 241 |
242 tab_reloader_->OnRedirect(new_url.SchemeIsSecure()); | 242 tab_reloader_->OnRedirect(new_url.SchemeUsesTLS()); |
243 } | 243 } |
244 | 244 |
245 void CaptivePortalTabHelper::OnCaptivePortalResults( | 245 void CaptivePortalTabHelper::OnCaptivePortalResults( |
246 CaptivePortalResult previous_result, | 246 CaptivePortalResult previous_result, |
247 CaptivePortalResult result) { | 247 CaptivePortalResult result) { |
248 tab_reloader_->OnCaptivePortalResults(previous_result, result); | 248 tab_reloader_->OnCaptivePortalResults(previous_result, result); |
249 login_detector_->OnCaptivePortalResults(previous_result, result); | 249 login_detector_->OnCaptivePortalResults(previous_result, result); |
250 } | 250 } |
251 | 251 |
252 void CaptivePortalTabHelper::OnLoadAborted() { | 252 void CaptivePortalTabHelper::OnLoadAborted() { |
(...skipping 10 matching lines...) Expand all Loading... |
263 } | 263 } |
264 | 264 |
265 void CaptivePortalTabHelper::SetTabReloaderForTest( | 265 void CaptivePortalTabHelper::SetTabReloaderForTest( |
266 CaptivePortalTabReloader* tab_reloader) { | 266 CaptivePortalTabReloader* tab_reloader) { |
267 tab_reloader_.reset(tab_reloader); | 267 tab_reloader_.reset(tab_reloader); |
268 } | 268 } |
269 | 269 |
270 CaptivePortalTabReloader* CaptivePortalTabHelper::GetTabReloaderForTest() { | 270 CaptivePortalTabReloader* CaptivePortalTabHelper::GetTabReloaderForTest() { |
271 return tab_reloader_.get(); | 271 return tab_reloader_.get(); |
272 } | 272 } |
OLD | NEW |