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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
75 void CaptivePortalTabHelper::DidRedirectNavigation( | 75 void CaptivePortalTabHelper::DidRedirectNavigation( |
76 content::NavigationHandle* navigation_handle) { | 76 content::NavigationHandle* navigation_handle) { |
77 DCHECK(CalledOnValidThread()); | 77 DCHECK(CalledOnValidThread()); |
78 if (navigation_handle != navigation_handle_) | 78 if (navigation_handle != navigation_handle_) |
79 return; | 79 return; |
80 DCHECK(navigation_handle->IsInMainFrame()); | 80 DCHECK(navigation_handle->IsInMainFrame()); |
81 tab_reloader_->OnRedirect( | 81 tab_reloader_->OnRedirect( |
82 navigation_handle->GetURL().SchemeIsCryptographic()); | 82 navigation_handle->GetURL().SchemeIsCryptographic()); |
83 } | 83 } |
84 | 84 |
85 void CaptivePortalTabHelper::DidCommitNavigation( | 85 void CaptivePortalTabHelper::DidFinishNavigation( |
86 content::NavigationHandle* navigation_handle) { | 86 content::NavigationHandle* navigation_handle) { |
87 DCHECK(CalledOnValidThread()); | 87 DCHECK(CalledOnValidThread()); |
88 if (!navigation_handle->IsInMainFrame()) | 88 if (!navigation_handle->IsInMainFrame()) |
89 return; | 89 return; |
90 | 90 |
91 if (navigation_handle_ != navigation_handle) | 91 bool navigation_has_committed = navigation_handle->HasCommittedDocument() || |
92 navigation_handle->HasCommittedErrorPage(); | |
Charlie Reis
2015/09/18 17:05:20
Seems like lots of places will have to use this pa
clamy
2015/09/18 20:37:33
Done.
| |
93 | |
94 if (navigation_handle_ != navigation_handle) { | |
95 if (!navigation_has_committed) | |
96 return; | |
92 DidStartNavigation(navigation_handle); | 97 DidStartNavigation(navigation_handle); |
98 } | |
93 | 99 |
94 tab_reloader_->OnLoadCommitted(navigation_handle->GetNetErrorCode()); | 100 if (navigation_has_committed) |
101 tab_reloader_->OnLoadCommitted(navigation_handle->GetNetErrorCode()); | |
102 else | |
103 tab_reloader_->OnAbort(); | |
104 | |
105 navigation_handle_ = nullptr; | |
95 } | 106 } |
96 | 107 |
97 void CaptivePortalTabHelper::DidFinishNavigation( | 108 void CaptivePortalTabHelper::DidStopLoading() { |
98 content::NavigationHandle* navigation_handle) { | |
99 DCHECK(CalledOnValidThread()); | |
100 if (navigation_handle != navigation_handle_) | |
101 return; | |
102 DCHECK(navigation_handle->IsInMainFrame()); | |
103 | |
104 if (!navigation_handle->HasCommittedDocument() && | |
105 !navigation_handle->HasCommittedErrorPage()) { | |
106 tab_reloader_->OnAbort(); | |
107 } | |
108 | |
109 login_detector_->OnStoppedLoading(); | 109 login_detector_->OnStoppedLoading(); |
110 | |
111 navigation_handle_ = nullptr; | |
112 } | 110 } |
113 | 111 |
114 void CaptivePortalTabHelper::Observe( | 112 void CaptivePortalTabHelper::Observe( |
115 int type, | 113 int type, |
116 const content::NotificationSource& source, | 114 const content::NotificationSource& source, |
117 const content::NotificationDetails& details) { | 115 const content::NotificationDetails& details) { |
118 DCHECK(CalledOnValidThread()); | 116 DCHECK(CalledOnValidThread()); |
119 DCHECK_EQ(chrome::NOTIFICATION_CAPTIVE_PORTAL_CHECK_RESULT, type); | 117 DCHECK_EQ(chrome::NOTIFICATION_CAPTIVE_PORTAL_CHECK_RESULT, type); |
120 DCHECK_EQ(profile_, content::Source<Profile>(source).ptr()); | 118 DCHECK_EQ(profile_, content::Source<Profile>(source).ptr()); |
121 | 119 |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
183 } | 181 } |
184 | 182 |
185 void CaptivePortalTabHelper::SetTabReloaderForTest( | 183 void CaptivePortalTabHelper::SetTabReloaderForTest( |
186 CaptivePortalTabReloader* tab_reloader) { | 184 CaptivePortalTabReloader* tab_reloader) { |
187 tab_reloader_.reset(tab_reloader); | 185 tab_reloader_.reset(tab_reloader); |
188 } | 186 } |
189 | 187 |
190 CaptivePortalTabReloader* CaptivePortalTabHelper::GetTabReloaderForTest() { | 188 CaptivePortalTabReloader* CaptivePortalTabHelper::GetTabReloaderForTest() { |
191 return tab_reloader_.get(); | 189 return tab_reloader_.get(); |
192 } | 190 } |
OLD | NEW |