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"
9 namespace captive_portal
{
11 CaptivePortalLoginDetector::CaptivePortalLoginDetector(
15 first_login_tab_load_(false) {
18 CaptivePortalLoginDetector::~CaptivePortalLoginDetector() {
21 void CaptivePortalLoginDetector::OnStoppedLoading() {
22 // Do nothing if this is not a login tab, or if this is a login tab's first
24 if (!is_login_tab_
|| first_login_tab_load_
) {
25 first_login_tab_load_
= false;
29 // 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 CaptivePortalServiceFactory::GetForProfile(profile_
)->DetectCaptivePortal();
34 void CaptivePortalLoginDetector::OnCaptivePortalResults(
35 Result previous_result
,
37 if (result
!= RESULT_BEHIND_CAPTIVE_PORTAL
)
38 is_login_tab_
= false;
41 void CaptivePortalLoginDetector::SetIsLoginTab() {
43 first_login_tab_load_
= true;
46 } // namespace captive_portal