| 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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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.SchemeIsSecure()); |
| 97 } | 97 } |
| 98 | 98 |
| 99 void CaptivePortalTabHelper::DidCommitProvisionalLoadForFrame( | 99 void CaptivePortalTabHelper::DidCommitProvisionalLoadForFrame( |
| 100 int64 frame_id, | 100 int64 frame_id, |
| 101 const string16& frame_unique_name, | 101 const base::string16& frame_unique_name, |
| 102 bool is_main_frame, | 102 bool is_main_frame, |
| 103 const GURL& url, | 103 const GURL& url, |
| 104 content::PageTransition transition_type, | 104 content::PageTransition transition_type, |
| 105 content::RenderViewHost* render_view_host) { | 105 content::RenderViewHost* render_view_host) { |
| 106 DCHECK(CalledOnValidThread()); | 106 DCHECK(CalledOnValidThread()); |
| 107 | 107 |
| 108 // Ignore subframes. | 108 // Ignore subframes. |
| 109 if (!is_main_frame) | 109 if (!is_main_frame) |
| 110 return; | 110 return; |
| 111 | 111 |
| 112 if (provisional_render_view_host_ == render_view_host) { | 112 if (provisional_render_view_host_ == render_view_host) { |
| 113 tab_reloader_->OnLoadCommitted(pending_error_code_); | 113 tab_reloader_->OnLoadCommitted(pending_error_code_); |
| 114 } else { | 114 } else { |
| 115 // This may happen if the active RenderView commits a page before a cross | 115 // This may happen if the active RenderView commits a page before a cross |
| 116 // process navigation cancels the old load. In this case, the commit of the | 116 // process navigation cancels the old load. In this case, the commit of the |
| 117 // old navigation will cancel the newer one. | 117 // old navigation will cancel the newer one. |
| 118 OnLoadAborted(); | 118 OnLoadAborted(); |
| 119 | 119 |
| 120 // Send information about the new load. | 120 // Send information about the new load. |
| 121 tab_reloader_->OnLoadStart(url.SchemeIsSecure()); | 121 tab_reloader_->OnLoadStart(url.SchemeIsSecure()); |
| 122 tab_reloader_->OnLoadCommitted(net::OK); | 122 tab_reloader_->OnLoadCommitted(net::OK); |
| 123 } | 123 } |
| 124 | 124 |
| 125 provisional_render_view_host_ = NULL; | 125 provisional_render_view_host_ = NULL; |
| 126 pending_error_code_ = net::OK; | 126 pending_error_code_ = net::OK; |
| 127 } | 127 } |
| 128 | 128 |
| 129 void CaptivePortalTabHelper::DidFailProvisionalLoad( | 129 void CaptivePortalTabHelper::DidFailProvisionalLoad( |
| 130 int64 frame_id, | 130 int64 frame_id, |
| 131 const string16& frame_unique_name, | 131 const base::string16& frame_unique_name, |
| 132 bool is_main_frame, | 132 bool is_main_frame, |
| 133 const GURL& validated_url, | 133 const GURL& validated_url, |
| 134 int error_code, | 134 int error_code, |
| 135 const string16& error_description, | 135 const base::string16& error_description, |
| 136 content::RenderViewHost* render_view_host) { | 136 content::RenderViewHost* render_view_host) { |
| 137 DCHECK(CalledOnValidThread()); | 137 DCHECK(CalledOnValidThread()); |
| 138 | 138 |
| 139 // Ignore subframes and unexpected RenderViewHosts. | 139 // Ignore subframes and unexpected RenderViewHosts. |
| 140 if (!is_main_frame || render_view_host != provisional_render_view_host_) | 140 if (!is_main_frame || render_view_host != provisional_render_view_host_) |
| 141 return; | 141 return; |
| 142 | 142 |
| 143 // Aborts generally aren't followed by loading an error page, so go ahead and | 143 // Aborts generally aren't followed by loading an error page, so go ahead and |
| 144 // reset the state now, to prevent any captive portal checks from triggering. | 144 // reset the state now, to prevent any captive portal checks from triggering. |
| 145 if (error_code == net::ERR_ABORTED) { | 145 if (error_code == net::ERR_ABORTED) { |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 content::WebContents* web_contents = chrome::AddSelectedTabWithURL( | 263 content::WebContents* web_contents = chrome::AddSelectedTabWithURL( |
| 264 browser, | 264 browser, |
| 265 CaptivePortalServiceFactory::GetForProfile(profile_)->test_url(), | 265 CaptivePortalServiceFactory::GetForProfile(profile_)->test_url(), |
| 266 content::PAGE_TRANSITION_TYPED); | 266 content::PAGE_TRANSITION_TYPED); |
| 267 captive_portal::CaptivePortalTabHelper* captive_portal_tab_helper = | 267 captive_portal::CaptivePortalTabHelper* captive_portal_tab_helper = |
| 268 captive_portal::CaptivePortalTabHelper::FromWebContents(web_contents); | 268 captive_portal::CaptivePortalTabHelper::FromWebContents(web_contents); |
| 269 captive_portal_tab_helper->SetIsLoginTab(); | 269 captive_portal_tab_helper->SetIsLoginTab(); |
| 270 } | 270 } |
| 271 | 271 |
| 272 } // namespace captive_portal | 272 } // namespace captive_portal |
| OLD | NEW |