Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(211)

Side by Side Diff: chrome/browser/captive_portal/captive_portal_service.cc

Issue 318213002: Add custom interstitial for captive portals. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix Android builds Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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_service.h" 5 #include "chrome/browser/captive_portal/captive_portal_service.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 203
204 UpdateEnabledState(); 204 UpdateEnabledState();
205 } 205 }
206 206
207 CaptivePortalService::~CaptivePortalService() { 207 CaptivePortalService::~CaptivePortalService() {
208 } 208 }
209 209
210 void CaptivePortalService::DetectCaptivePortal() { 210 void CaptivePortalService::DetectCaptivePortal() {
211 DCHECK(CalledOnValidThread()); 211 DCHECK(CalledOnValidThread());
212 212
213 // Detection should be disabled only in tests.
214 if (testing_state_ == IGNORE_REQUESTS_FOR_TESTING)
215 return;
216
213 // If a request is pending or running, do nothing. 217 // If a request is pending or running, do nothing.
214 if (state_ == STATE_CHECKING_FOR_PORTAL || state_ == STATE_TIMER_RUNNING) 218 if (state_ == STATE_CHECKING_FOR_PORTAL || state_ == STATE_TIMER_RUNNING)
215 return; 219 return;
216 220
217 base::TimeDelta time_until_next_check = backoff_entry_->GetTimeUntilRelease(); 221 base::TimeDelta time_until_next_check = backoff_entry_->GetTimeUntilRelease();
218 222
219 // Start asynchronously. 223 // Start asynchronously.
220 state_ = STATE_TIMER_RUNNING; 224 state_ = STATE_TIMER_RUNNING;
221 check_captive_portal_timer_.Start( 225 check_captive_portal_timer_.Start(
222 FROM_HERE, 226 FROM_HERE,
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 backoff_entry_.reset(new RecheckBackoffEntry(this)); 349 backoff_entry_.reset(new RecheckBackoffEntry(this));
346 } 350 }
347 351
348 void CaptivePortalService::UpdateEnabledState() { 352 void CaptivePortalService::UpdateEnabledState() {
349 DCHECK(CalledOnValidThread()); 353 DCHECK(CalledOnValidThread());
350 bool enabled_before = enabled_; 354 bool enabled_before = enabled_;
351 enabled_ = testing_state_ != DISABLED_FOR_TESTING && 355 enabled_ = testing_state_ != DISABLED_FOR_TESTING &&
352 resolve_errors_with_web_service_.GetValue(); 356 resolve_errors_with_web_service_.GetValue();
353 357
354 if (testing_state_ != SKIP_OS_CHECK_FOR_TESTING && 358 if (testing_state_ != SKIP_OS_CHECK_FOR_TESTING &&
359 testing_state_ != IGNORE_REQUESTS_FOR_TESTING &&
355 ShouldDeferToNativeCaptivePortalDetection()) { 360 ShouldDeferToNativeCaptivePortalDetection()) {
356 enabled_ = false; 361 enabled_ = false;
357 } 362 }
358 363
359 if (enabled_before == enabled_) 364 if (enabled_before == enabled_)
360 return; 365 return;
361 366
362 // Clear data used for histograms. 367 // Clear data used for histograms.
363 num_checks_with_same_result_ = 0; 368 num_checks_with_same_result_ = 0;
364 first_check_time_with_same_result_ = base::TimeTicks(); 369 first_check_time_with_same_result_ = base::TimeTicks();
(...skipping 21 matching lines...) Expand all
386 return time_ticks_for_testing_; 391 return time_ticks_for_testing_;
387 } 392 }
388 393
389 bool CaptivePortalService::DetectionInProgress() const { 394 bool CaptivePortalService::DetectionInProgress() const {
390 return state_ == STATE_CHECKING_FOR_PORTAL; 395 return state_ == STATE_CHECKING_FOR_PORTAL;
391 } 396 }
392 397
393 bool CaptivePortalService::TimerRunning() const { 398 bool CaptivePortalService::TimerRunning() const {
394 return check_captive_portal_timer_.IsRunning(); 399 return check_captive_portal_timer_.IsRunning();
395 } 400 }
OLDNEW
« no previous file with comments | « chrome/browser/captive_portal/captive_portal_service.h ('k') | chrome/browser/captive_portal/captive_portal_tab_helper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698