OLD | NEW |
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/ssl/ssl_blocking_page.h" | 5 #include "chrome/browser/ssl/ssl_blocking_page.h" |
6 | 6 |
7 #include "base/i18n/rtl.h" | 7 #include "base/i18n/rtl.h" |
8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
10 #include "base/strings/string_piece.h" | 10 #include "base/strings/string_piece.h" |
(...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
510 int num_visits, | 510 int num_visits, |
511 base::Time first_visit) { | 511 base::Time first_visit) { |
512 num_visits_ = num_visits; | 512 num_visits_ = num_visits; |
513 } | 513 } |
514 | 514 |
515 void SSLBlockingPage::Observe( | 515 void SSLBlockingPage::Observe( |
516 int type, | 516 int type, |
517 const content::NotificationSource& source, | 517 const content::NotificationSource& source, |
518 const content::NotificationDetails& details) { | 518 const content::NotificationDetails& details) { |
519 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION) | 519 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION) |
| 520 // When detection is disabled, captive portal service always sends |
| 521 // RESULT_INTERNET_CONNECTED. Ignore any probe results in that case. |
| 522 if (!captive_portal_detection_enabled_) |
| 523 return; |
520 if (type == chrome::NOTIFICATION_CAPTIVE_PORTAL_CHECK_RESULT) { | 524 if (type == chrome::NOTIFICATION_CAPTIVE_PORTAL_CHECK_RESULT) { |
521 captive_portal_probe_completed_ = true; | 525 captive_portal_probe_completed_ = true; |
522 captive_portal::CaptivePortalService::Results* results = | 526 captive_portal::CaptivePortalService::Results* results = |
523 content::Details<captive_portal::CaptivePortalService::Results>( | 527 content::Details<captive_portal::CaptivePortalService::Results>( |
524 details).ptr(); | 528 details).ptr(); |
525 // If a captive portal was detected at any point when the interstitial was | 529 // If a captive portal was detected at any point when the interstitial was |
526 // displayed, assume that the interstitial was caused by a captive portal. | 530 // displayed, assume that the interstitial was caused by a captive portal. |
527 // Example scenario: | 531 // Example scenario: |
528 // 1- Interstitial displayed and captive portal detected, setting the flag. | 532 // 1- Interstitial displayed and captive portal detected, setting the flag. |
529 // 2- Captive portal detection automatically opens portal login page. | 533 // 2- Captive portal detection automatically opens portal login page. |
530 // 3- User logs in on the portal login page. | 534 // 3- User logs in on the portal login page. |
531 // A notification will be received here for RESULT_INTERNET_CONNECTED. Make | 535 // A notification will be received here for RESULT_INTERNET_CONNECTED. Make |
532 // sure we don't clear the captive portal flag, since the interstitial was | 536 // sure we don't clear the captive portal flag, since the interstitial was |
533 // potentially caused by the captive portal. | 537 // potentially caused by the captive portal. |
534 captive_portal_detected_ = captive_portal_detected_ || | 538 captive_portal_detected_ = captive_portal_detected_ || |
535 (results->result == captive_portal::RESULT_BEHIND_CAPTIVE_PORTAL); | 539 (results->result == captive_portal::RESULT_BEHIND_CAPTIVE_PORTAL); |
536 // Also keep track of non-HTTP portals and error cases. | 540 // Also keep track of non-HTTP portals and error cases. |
537 captive_portal_no_response_ = captive_portal_no_response_ || | 541 captive_portal_no_response_ = captive_portal_no_response_ || |
538 (results->result == captive_portal::RESULT_NO_RESPONSE); | 542 (results->result == captive_portal::RESULT_NO_RESPONSE); |
539 } | 543 } |
540 #endif | 544 #endif |
541 } | 545 } |
OLD | NEW |