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
3 // found in the LICENSE file.
5 #include "chrome/browser/captive_portal/captive_portal_login_detector.h"
7 #include "chrome/browser/captive_portal/captive_portal_service_factory.h"
8 #include "components/captive_portal/captive_portal_types.h"
10 using captive_portal::CaptivePortalResult
;
12 CaptivePortalLoginDetector::CaptivePortalLoginDetector(
16 first_login_tab_load_(false) {
19 CaptivePortalLoginDetector::~CaptivePortalLoginDetector() {
22 void CaptivePortalLoginDetector::OnStoppedLoading() {
23 // Do nothing if this is not a login tab, or if this is a login tab's first
25 if (!is_login_tab_
|| first_login_tab_load_
) {
26 first_login_tab_load_
= false;
30 // The service is guaranteed to exist if |is_login_tab_| is true, since it's
31 // only set to true once a captive portal is detected.
32 CaptivePortalServiceFactory::GetForProfile(profile_
)->DetectCaptivePortal();
35 void CaptivePortalLoginDetector::OnCaptivePortalResults(
36 CaptivePortalResult previous_result
,
37 CaptivePortalResult result
) {
38 if (result
!= captive_portal::RESULT_BEHIND_CAPTIVE_PORTAL
)
39 is_login_tab_
= false;
42 void CaptivePortalLoginDetector::SetIsLoginTab() {
44 first_login_tab_load_
= true;