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

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

Issue 861953002: Add login url to captive portal interstitial. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: mmenke comments 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
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 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 DCHECK(state_ == STATE_TIMER_RUNNING || state_ == STATE_IDLE); 234 DCHECK(state_ == STATE_TIMER_RUNNING || state_ == STATE_IDLE);
235 DCHECK(!TimerRunning()); 235 DCHECK(!TimerRunning());
236 236
237 state_ = STATE_CHECKING_FOR_PORTAL; 237 state_ = STATE_CHECKING_FOR_PORTAL;
238 238
239 // When not enabled, just claim there's an Internet connection. 239 // When not enabled, just claim there's an Internet connection.
240 if (!enabled_) { 240 if (!enabled_) {
241 // Count this as a success, so the backoff entry won't apply exponential 241 // Count this as a success, so the backoff entry won't apply exponential
242 // backoff, but will apply the standard delay. 242 // backoff, but will apply the standard delay.
243 backoff_entry_->InformOfRequest(true); 243 backoff_entry_->InformOfRequest(true);
244 OnResult(captive_portal::RESULT_INTERNET_CONNECTED); 244 OnResult(captive_portal::RESULT_INTERNET_CONNECTED, GURL());
245 return; 245 return;
246 } 246 }
247 247
248 captive_portal_detector_.DetectCaptivePortal( 248 captive_portal_detector_.DetectCaptivePortal(
249 test_url_, base::Bind( 249 test_url_, base::Bind(
250 &CaptivePortalService::OnPortalDetectionCompleted, 250 &CaptivePortalService::OnPortalDetectionCompleted,
251 base::Unretained(this))); 251 base::Unretained(this)));
252 } 252 }
253 253
254 void CaptivePortalService::OnPortalDetectionCompleted( 254 void CaptivePortalService::OnPortalDetectionCompleted(
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 ++num_checks_with_same_result_; 300 ++num_checks_with_same_result_;
301 301
302 // Requests that have the same Result as the last one are considered 302 // Requests that have the same Result as the last one are considered
303 // "failures", to trigger backoff. 303 // "failures", to trigger backoff.
304 backoff_entry_->SetCustomReleaseTime(now + retry_after_delta); 304 backoff_entry_->SetCustomReleaseTime(now + retry_after_delta);
305 backoff_entry_->InformOfRequest(false); 305 backoff_entry_->InformOfRequest(false);
306 } 306 }
307 307
308 last_check_time_ = now; 308 last_check_time_ = now;
309 309
310 OnResult(result); 310 OnResult(result, results.landing_url);
311 } 311 }
312 312
313 void CaptivePortalService::Shutdown() { 313 void CaptivePortalService::Shutdown() {
314 DCHECK(CalledOnValidThread()); 314 DCHECK(CalledOnValidThread());
315 if (enabled_) { 315 if (enabled_) {
316 RecordRepeatHistograms( 316 RecordRepeatHistograms(
317 last_detection_result_, 317 last_detection_result_,
318 num_checks_with_same_result_, 318 num_checks_with_same_result_,
319 GetCurrentTimeTicks() - first_check_time_with_same_result_); 319 GetCurrentTimeTicks() - first_check_time_with_same_result_);
320 } 320 }
321 } 321 }
322 322
323 void CaptivePortalService::OnResult(CaptivePortalResult result) { 323 void CaptivePortalService::OnResult(CaptivePortalResult result,
324 const GURL& landing_url) {
324 DCHECK_EQ(STATE_CHECKING_FOR_PORTAL, state_); 325 DCHECK_EQ(STATE_CHECKING_FOR_PORTAL, state_);
325 state_ = STATE_IDLE; 326 state_ = STATE_IDLE;
326 327
327 Results results; 328 Results results;
328 results.previous_result = last_detection_result_; 329 results.previous_result = last_detection_result_;
329 results.result = result; 330 results.result = result;
331 results.landing_url = landing_url;
330 last_detection_result_ = result; 332 last_detection_result_ = result;
331 333
332 content::NotificationService::current()->Notify( 334 content::NotificationService::current()->Notify(
333 chrome::NOTIFICATION_CAPTIVE_PORTAL_CHECK_RESULT, 335 chrome::NOTIFICATION_CAPTIVE_PORTAL_CHECK_RESULT,
334 content::Source<Profile>(profile_), 336 content::Source<Profile>(profile_),
335 content::Details<Results>(&results)); 337 content::Details<Results>(&results));
336 } 338 }
337 339
338 void CaptivePortalService::ResetBackoffEntry(CaptivePortalResult result) { 340 void CaptivePortalService::ResetBackoffEntry(CaptivePortalResult result) {
339 if (!enabled_ || result == captive_portal::RESULT_BEHIND_CAPTIVE_PORTAL) { 341 if (!enabled_ || result == captive_portal::RESULT_BEHIND_CAPTIVE_PORTAL) {
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 return time_ticks_for_testing_; 393 return time_ticks_for_testing_;
392 } 394 }
393 395
394 bool CaptivePortalService::DetectionInProgress() const { 396 bool CaptivePortalService::DetectionInProgress() const {
395 return state_ == STATE_CHECKING_FOR_PORTAL; 397 return state_ == STATE_CHECKING_FOR_PORTAL;
396 } 398 }
397 399
398 bool CaptivePortalService::TimerRunning() const { 400 bool CaptivePortalService::TimerRunning() const {
399 return check_captive_portal_timer_.IsRunning(); 401 return check_captive_portal_timer_.IsRunning();
400 } 402 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698