| 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 #include "chrome/browser/captive_portal/captive_portal_service.h" | 42 #include "chrome/browser/captive_portal/captive_portal_service.h" |
| 43 #include "chrome/browser/captive_portal/captive_portal_service_factory.h" | 43 #include "chrome/browser/captive_portal/captive_portal_service_factory.h" |
| 44 #endif | 44 #endif |
| 45 | 45 |
| 46 #if defined(OS_WIN) | 46 #if defined(OS_WIN) |
| 47 #include "base/win/windows_version.h" | 47 #include "base/win/windows_version.h" |
| 48 #endif | 48 #endif |
| 49 | 49 |
| 50 using base::ASCIIToUTF16; | 50 using base::ASCIIToUTF16; |
| 51 using base::TimeTicks; | 51 using base::TimeTicks; |
| 52 using captive_portal::CaptivePortalDetector; |
| 52 using content::InterstitialPage; | 53 using content::InterstitialPage; |
| 53 using content::NavigationController; | 54 using content::NavigationController; |
| 54 using content::NavigationEntry; | 55 using content::NavigationEntry; |
| 55 | 56 |
| 56 namespace { | 57 namespace { |
| 57 | 58 |
| 58 // These represent the commands sent by ssl_roadblock.html. | 59 // These represent the commands sent by ssl_roadblock.html. |
| 59 enum SSLBlockingPageCommands { | 60 enum SSLBlockingPageCommands { |
| 60 CMD_DONT_PROCEED, | 61 CMD_DONT_PROCEED, |
| 61 CMD_PROCEED, | 62 CMD_PROCEED, |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 if (history_service) { | 223 if (history_service) { |
| 223 history_service->GetVisibleVisitCountToHost( | 224 history_service->GetVisibleVisitCountToHost( |
| 224 request_url_, | 225 request_url_, |
| 225 &request_consumer_, | 226 &request_consumer_, |
| 226 base::Bind(&SSLBlockingPage::OnGotHistoryCount, | 227 base::Bind(&SSLBlockingPage::OnGotHistoryCount, |
| 227 base::Unretained(this))); | 228 base::Unretained(this))); |
| 228 } | 229 } |
| 229 } | 230 } |
| 230 | 231 |
| 231 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION) | 232 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION) |
| 232 captive_portal::CaptivePortalService* captive_portal_service = | 233 CaptivePortalService* captive_portal_service = |
| 233 captive_portal::CaptivePortalServiceFactory::GetForProfile(profile); | 234 CaptivePortalServiceFactory::GetForProfile(profile); |
| 234 captive_portal_detection_enabled_ = captive_portal_service ->enabled(); | 235 captive_portal_detection_enabled_ = captive_portal_service ->enabled(); |
| 235 captive_portal_service ->DetectCaptivePortal(); | 236 captive_portal_service ->DetectCaptivePortal(); |
| 236 registrar_.Add(this, | 237 registrar_.Add(this, |
| 237 chrome::NOTIFICATION_CAPTIVE_PORTAL_CHECK_RESULT, | 238 chrome::NOTIFICATION_CAPTIVE_PORTAL_CHECK_RESULT, |
| 238 content::Source<Profile>(profile)); | 239 content::Source<Profile>(profile)); |
| 239 #endif | 240 #endif |
| 240 | 241 |
| 241 interstitial_page_ = InterstitialPage::Create( | 242 interstitial_page_ = InterstitialPage::Create( |
| 242 web_contents_, true, request_url, this); | 243 web_contents_, true, request_url, this); |
| 243 interstitial_page_->Show(); | 244 interstitial_page_->Show(); |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 516 int type, | 517 int type, |
| 517 const content::NotificationSource& source, | 518 const content::NotificationSource& source, |
| 518 const content::NotificationDetails& details) { | 519 const content::NotificationDetails& details) { |
| 519 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION) | 520 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION) |
| 520 // When detection is disabled, captive portal service always sends | 521 // When detection is disabled, captive portal service always sends |
| 521 // RESULT_INTERNET_CONNECTED. Ignore any probe results in that case. | 522 // RESULT_INTERNET_CONNECTED. Ignore any probe results in that case. |
| 522 if (!captive_portal_detection_enabled_) | 523 if (!captive_portal_detection_enabled_) |
| 523 return; | 524 return; |
| 524 if (type == chrome::NOTIFICATION_CAPTIVE_PORTAL_CHECK_RESULT) { | 525 if (type == chrome::NOTIFICATION_CAPTIVE_PORTAL_CHECK_RESULT) { |
| 525 captive_portal_probe_completed_ = true; | 526 captive_portal_probe_completed_ = true; |
| 526 captive_portal::CaptivePortalService::Results* results = | 527 CaptivePortalService::Results* results = |
| 527 content::Details<captive_portal::CaptivePortalService::Results>( | 528 content::Details<CaptivePortalService::Results>( |
| 528 details).ptr(); | 529 details).ptr(); |
| 529 // If a captive portal was detected at any point when the interstitial was | 530 // 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. | 531 // displayed, assume that the interstitial was caused by a captive portal. |
| 531 // Example scenario: | 532 // Example scenario: |
| 532 // 1- Interstitial displayed and captive portal detected, setting the flag. | 533 // 1- Interstitial displayed and captive portal detected, setting the flag. |
| 533 // 2- Captive portal detection automatically opens portal login page. | 534 // 2- Captive portal detection automatically opens portal login page. |
| 534 // 3- User logs in on the portal login page. | 535 // 3- User logs in on the portal login page. |
| 535 // A notification will be received here for RESULT_INTERNET_CONNECTED. Make | 536 // 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 | 537 // sure we don't clear the captive portal flag, since the interstitial was |
| 537 // potentially caused by the captive portal. | 538 // potentially caused by the captive portal. |
| 538 captive_portal_detected_ = captive_portal_detected_ || | 539 captive_portal_detected_ = captive_portal_detected_ || |
| 539 (results->result == captive_portal::RESULT_BEHIND_CAPTIVE_PORTAL); | 540 (results->result == captive_portal::RESULT_BEHIND_CAPTIVE_PORTAL); |
| 540 // Also keep track of non-HTTP portals and error cases. | 541 // Also keep track of non-HTTP portals and error cases. |
| 541 captive_portal_no_response_ = captive_portal_no_response_ || | 542 captive_portal_no_response_ = captive_portal_no_response_ || |
| 542 (results->result == captive_portal::RESULT_NO_RESPONSE); | 543 (results->result == captive_portal::RESULT_NO_RESPONSE); |
| 543 } | 544 } |
| 544 #endif | 545 #endif |
| 545 } | 546 } |
| OLD | NEW |