| 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_login_detector.h" | 5 #include "chrome/browser/captive_portal/captive_portal_login_detector.h" |
| 6 | 6 |
| 7 #include "chrome/browser/captive_portal/captive_portal_service_factory.h" | 7 #include "chrome/browser/captive_portal/captive_portal_service_factory.h" |
| 8 #include "components/captive_portal/captive_portal_types.h" |
| 8 | 9 |
| 9 namespace captive_portal { | 10 using captive_portal::CaptivePortalResult; |
| 10 | 11 |
| 11 CaptivePortalLoginDetector::CaptivePortalLoginDetector( | 12 CaptivePortalLoginDetector::CaptivePortalLoginDetector( |
| 12 Profile* profile) | 13 Profile* profile) |
| 13 : profile_(profile), | 14 : profile_(profile), |
| 14 is_login_tab_(false), | 15 is_login_tab_(false), |
| 15 first_login_tab_load_(false) { | 16 first_login_tab_load_(false) { |
| 16 } | 17 } |
| 17 | 18 |
| 18 CaptivePortalLoginDetector::~CaptivePortalLoginDetector() { | 19 CaptivePortalLoginDetector::~CaptivePortalLoginDetector() { |
| 19 } | 20 } |
| 20 | 21 |
| 21 void CaptivePortalLoginDetector::OnStoppedLoading() { | 22 void CaptivePortalLoginDetector::OnStoppedLoading() { |
| 22 // Do nothing if this is not a login tab, or if this is a login tab's first | 23 // Do nothing if this is not a login tab, or if this is a login tab's first |
| 23 // load. | 24 // load. |
| 24 if (!is_login_tab_ || first_login_tab_load_) { | 25 if (!is_login_tab_ || first_login_tab_load_) { |
| 25 first_login_tab_load_ = false; | 26 first_login_tab_load_ = false; |
| 26 return; | 27 return; |
| 27 } | 28 } |
| 28 | 29 |
| 29 // The service is guaranteed to exist if |is_login_tab_| is true, since it's | 30 // The service is guaranteed to exist if |is_login_tab_| is true, since it's |
| 30 // only set to true once a captive portal is detected. | 31 // only set to true once a captive portal is detected. |
| 31 CaptivePortalServiceFactory::GetForProfile(profile_)->DetectCaptivePortal(); | 32 CaptivePortalServiceFactory::GetForProfile(profile_)->DetectCaptivePortal(); |
| 32 } | 33 } |
| 33 | 34 |
| 34 void CaptivePortalLoginDetector::OnCaptivePortalResults( | 35 void CaptivePortalLoginDetector::OnCaptivePortalResults( |
| 35 Result previous_result, | 36 CaptivePortalResult previous_result, |
| 36 Result result) { | 37 CaptivePortalResult result) { |
| 37 if (result != RESULT_BEHIND_CAPTIVE_PORTAL) | 38 if (result != captive_portal::RESULT_BEHIND_CAPTIVE_PORTAL) |
| 38 is_login_tab_ = false; | 39 is_login_tab_ = false; |
| 39 } | 40 } |
| 40 | 41 |
| 41 void CaptivePortalLoginDetector::SetIsLoginTab() { | 42 void CaptivePortalLoginDetector::SetIsLoginTab() { |
| 42 is_login_tab_ = true; | 43 is_login_tab_ = true; |
| 43 first_login_tab_load_ = true; | 44 first_login_tab_load_ = true; |
| 44 } | 45 } |
| 45 | |
| 46 } // namespace captive_portal | |
| OLD | NEW |