| 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 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 if (history_service) { | 222 if (history_service) { |
| 223 history_service->GetVisibleVisitCountToHost( | 223 history_service->GetVisibleVisitCountToHost( |
| 224 request_url_, | 224 request_url_, |
| 225 &request_consumer_, | 225 &request_consumer_, |
| 226 base::Bind(&SSLBlockingPage::OnGotHistoryCount, | 226 base::Bind(&SSLBlockingPage::OnGotHistoryCount, |
| 227 base::Unretained(this))); | 227 base::Unretained(this))); |
| 228 } | 228 } |
| 229 } | 229 } |
| 230 | 230 |
| 231 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION) | 231 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION) |
| 232 captive_portal::CaptivePortalService* captive_portal_service = | 232 CaptivePortalService* captive_portal_service = |
| 233 captive_portal::CaptivePortalServiceFactory::GetForProfile(profile); | 233 CaptivePortalServiceFactory::GetForProfile(profile); |
| 234 captive_portal_detection_enabled_ = captive_portal_service ->enabled(); | 234 captive_portal_detection_enabled_ = captive_portal_service ->enabled(); |
| 235 captive_portal_service ->DetectCaptivePortal(); | 235 captive_portal_service ->DetectCaptivePortal(); |
| 236 registrar_.Add(this, | 236 registrar_.Add(this, |
| 237 chrome::NOTIFICATION_CAPTIVE_PORTAL_CHECK_RESULT, | 237 chrome::NOTIFICATION_CAPTIVE_PORTAL_CHECK_RESULT, |
| 238 content::Source<Profile>(profile)); | 238 content::Source<Profile>(profile)); |
| 239 #endif | 239 #endif |
| 240 | 240 |
| 241 interstitial_page_ = InterstitialPage::Create( | 241 interstitial_page_ = InterstitialPage::Create( |
| 242 web_contents_, true, request_url, this); | 242 web_contents_, true, request_url, this); |
| 243 interstitial_page_->Show(); | 243 interstitial_page_->Show(); |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 | 520 // When detection is disabled, captive portal service always sends |
| 521 // RESULT_INTERNET_CONNECTED. Ignore any probe results in that case. | 521 // RESULT_INTERNET_CONNECTED. Ignore any probe results in that case. |
| 522 if (!captive_portal_detection_enabled_) | 522 if (!captive_portal_detection_enabled_) |
| 523 return; | 523 return; |
| 524 if (type == chrome::NOTIFICATION_CAPTIVE_PORTAL_CHECK_RESULT) { | 524 if (type == chrome::NOTIFICATION_CAPTIVE_PORTAL_CHECK_RESULT) { |
| 525 captive_portal_probe_completed_ = true; | 525 captive_portal_probe_completed_ = true; |
| 526 captive_portal::CaptivePortalService::Results* results = | 526 CaptivePortalService::Results* results = |
| 527 content::Details<captive_portal::CaptivePortalService::Results>( | 527 content::Details<CaptivePortalService::Results>( |
| 528 details).ptr(); | 528 details).ptr(); |
| 529 // 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 |
| 530 // displayed, assume that the interstitial was caused by a captive portal. | 530 // displayed, assume that the interstitial was caused by a captive portal. |
| 531 // Example scenario: | 531 // Example scenario: |
| 532 // 1- Interstitial displayed and captive portal detected, setting the flag. | 532 // 1- Interstitial displayed and captive portal detected, setting the flag. |
| 533 // 2- Captive portal detection automatically opens portal login page. | 533 // 2- Captive portal detection automatically opens portal login page. |
| 534 // 3- User logs in on the portal login page. | 534 // 3- User logs in on the portal login page. |
| 535 // A notification will be received here for RESULT_INTERNET_CONNECTED. Make | 535 // A notification will be received here for RESULT_INTERNET_CONNECTED. Make |
| 536 // 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 |
| 537 // potentially caused by the captive portal. | 537 // potentially caused by the captive portal. |
| 538 captive_portal_detected_ = captive_portal_detected_ || | 538 captive_portal_detected_ = captive_portal_detected_ || |
| 539 (results->result == captive_portal::RESULT_BEHIND_CAPTIVE_PORTAL); | 539 (results->result == captive_portal::RESULT_BEHIND_CAPTIVE_PORTAL); |
| 540 // Also keep track of non-HTTP portals and error cases. | 540 // Also keep track of non-HTTP portals and error cases. |
| 541 captive_portal_no_response_ = captive_portal_no_response_ || | 541 captive_portal_no_response_ = captive_portal_no_response_ || |
| 542 (results->result == captive_portal::RESULT_NO_RESPONSE); | 542 (results->result == captive_portal::RESULT_NO_RESPONSE); |
| 543 } | 543 } |
| 544 #endif | 544 #endif |
| 545 } | 545 } |
| OLD | NEW |