OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <vector> | 5 #include <vector> |
6 | 6 |
7 #include "chrome/browser/ssl/ssl_error_classification.h" | 7 #include "chrome/browser/ssl/ssl_error_classification.h" |
8 | 8 |
9 #include "base/build_time.h" | 9 #include "base/build_time.h" |
10 #include "base/metrics/field_trial.h" | 10 #include "base/metrics/field_trial.h" |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 request_url_(url), | 149 request_url_(url), |
150 cert_error_(cert_error), | 150 cert_error_(cert_error), |
151 cert_(cert), | 151 cert_(cert), |
152 captive_portal_detection_enabled_(false), | 152 captive_portal_detection_enabled_(false), |
153 captive_portal_probe_completed_(false), | 153 captive_portal_probe_completed_(false), |
154 captive_portal_no_response_(false), | 154 captive_portal_no_response_(false), |
155 captive_portal_detected_(false) { | 155 captive_portal_detected_(false) { |
156 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION) | 156 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION) |
157 Profile* profile = Profile::FromBrowserContext( | 157 Profile* profile = Profile::FromBrowserContext( |
158 web_contents_->GetBrowserContext()); | 158 web_contents_->GetBrowserContext()); |
159 CaptivePortalService* captive_portal_service = | 159 captive_portal_detection_enabled_ = |
160 CaptivePortalServiceFactory::GetForProfile(profile); | 160 CaptivePortalServiceFactory::GetForProfile(profile)->enabled(); |
161 captive_portal_detection_enabled_ = captive_portal_service->enabled(); | |
162 captive_portal_service->DetectCaptivePortal(); | |
163 registrar_.Add(this, | 161 registrar_.Add(this, |
164 chrome::NOTIFICATION_CAPTIVE_PORTAL_CHECK_RESULT, | 162 chrome::NOTIFICATION_CAPTIVE_PORTAL_CHECK_RESULT, |
165 content::Source<Profile>(profile)); | 163 content::Source<Profile>(profile)); |
166 #endif | 164 #endif |
167 } | 165 } |
168 | 166 |
169 SSLErrorClassification::~SSLErrorClassification() { } | 167 SSLErrorClassification::~SSLErrorClassification() { } |
170 | 168 |
171 void SSLErrorClassification::RecordCaptivePortalUMAStatistics( | 169 void SSLErrorClassification::RecordCaptivePortalUMAStatistics( |
172 bool overridable) const { | 170 bool overridable) const { |
(...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
627 const content::NotificationSource& source, | 625 const content::NotificationSource& source, |
628 const content::NotificationDetails& details) { | 626 const content::NotificationDetails& details) { |
629 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION) | 627 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION) |
630 // When detection is disabled, captive portal service always sends | 628 // When detection is disabled, captive portal service always sends |
631 // RESULT_INTERNET_CONNECTED. Ignore any probe results in that case. | 629 // RESULT_INTERNET_CONNECTED. Ignore any probe results in that case. |
632 if (!captive_portal_detection_enabled_) | 630 if (!captive_portal_detection_enabled_) |
633 return; | 631 return; |
634 if (type == chrome::NOTIFICATION_CAPTIVE_PORTAL_CHECK_RESULT) { | 632 if (type == chrome::NOTIFICATION_CAPTIVE_PORTAL_CHECK_RESULT) { |
635 captive_portal_probe_completed_ = true; | 633 captive_portal_probe_completed_ = true; |
636 CaptivePortalService::Results* results = | 634 CaptivePortalService::Results* results = |
637 content::Details<CaptivePortalService::Results>( | 635 content::Details<CaptivePortalService::Results>(details).ptr(); |
638 details).ptr(); | |
639 // If a captive portal was detected at any point when the interstitial was | 636 // If a captive portal was detected at any point when the interstitial was |
640 // displayed, assume that the interstitial was caused by a captive portal. | 637 // displayed, assume that the interstitial was caused by a captive portal. |
641 // Example scenario: | 638 // Example scenario: |
642 // 1- Interstitial displayed and captive portal detected, setting the flag. | 639 // 1- Interstitial displayed and captive portal detected, setting the flag. |
643 // 2- Captive portal detection automatically opens portal login page. | 640 // 2- Captive portal detection automatically opens portal login page. |
644 // 3- User logs in on the portal login page. | 641 // 3- User logs in on the portal login page. |
645 // A notification will be received here for RESULT_INTERNET_CONNECTED. Make | 642 // A notification will be received here for RESULT_INTERNET_CONNECTED. Make |
646 // sure we don't clear the captive protal flag, since the interstitial was | 643 // sure we don't clear the captive protal flag, since the interstitial was |
647 // potentially caused by the captive portal. | 644 // potentially caused by the captive portal. |
648 captive_portal_detected_ = captive_portal_detected_ || | 645 captive_portal_detected_ = captive_portal_detected_ || |
649 (results->result == captive_portal::RESULT_BEHIND_CAPTIVE_PORTAL); | 646 (results->result == captive_portal::RESULT_BEHIND_CAPTIVE_PORTAL); |
650 // Also keep track of non-HTTP portals and error cases. | 647 // Also keep track of non-HTTP portals and error cases. |
651 captive_portal_no_response_ = captive_portal_no_response_ || | 648 captive_portal_no_response_ = captive_portal_no_response_ || |
652 (results->result == captive_portal::RESULT_NO_RESPONSE); | 649 (results->result == captive_portal::RESULT_NO_RESPONSE); |
653 } | 650 } |
654 #endif | 651 #endif |
655 } | 652 } |
OLD | NEW |