Revert of Add button to add new FSP services to Files app. (patchset #8 id:140001...
[chromium-blink-merge.git] / chrome / browser / captive_portal / captive_portal_login_detector.cc
blob5b2d13f084dea895cbc450f5a21b7f649c730b33
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(
13 Profile* profile)
14 : profile_(profile),
15 is_login_tab_(false),
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
24 // load.
25 if (!is_login_tab_ || first_login_tab_load_) {
26 first_login_tab_load_ = false;
27 return;
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() {
43 is_login_tab_ = true;
44 first_login_tab_load_ = true;