Chromium Code Reviews| 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 "chrome/browser/ssl/ssl_error_handler.h" | 5 #include "chrome/browser/ssl/ssl_error_handler.h" |
| 6 | 6 |
| 7 #include "base/callback_helpers.h" | 7 #include "base/callback_helpers.h" |
| 8 #include "base/metrics/field_trial.h" | 8 #include "base/metrics/field_trial.h" |
| 9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
| 10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
| 11 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
| 12 #include "chrome/browser/ssl/ssl_blocking_page.h" | 12 #include "chrome/browser/ssl/ssl_blocking_page.h" |
| 13 #include "chrome/browser/ssl/ssl_cert_reporter.h" | 13 #include "chrome/browser/ssl/ssl_cert_reporter.h" |
| 14 #include "chrome/browser/ssl/ssl_error_classification.h" | 14 #include "chrome/browser/ssl/ssl_error_classification.h" |
| 15 #include "content/public/browser/notification_service.h" | 15 #include "content/public/browser/notification_service.h" |
| 16 #include "content/public/browser/notification_source.h" | 16 #include "content/public/browser/notification_source.h" |
| 17 #include "content/public/browser/web_contents.h" | 17 #include "content/public/browser/web_contents.h" |
| 18 #include "net/base/net_errors.h" | |
| 18 | 19 |
| 19 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION) | 20 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION) |
| 20 #include "chrome/browser/captive_portal/captive_portal_service.h" | 21 #include "chrome/browser/captive_portal/captive_portal_service.h" |
| 21 #include "chrome/browser/captive_portal/captive_portal_service_factory.h" | 22 #include "chrome/browser/captive_portal/captive_portal_service_factory.h" |
| 22 #include "chrome/browser/captive_portal/captive_portal_tab_helper.h" | 23 #include "chrome/browser/captive_portal/captive_portal_tab_helper.h" |
| 23 #include "chrome/browser/ssl/captive_portal_blocking_page.h" | 24 #include "chrome/browser/ssl/captive_portal_blocking_page.h" |
| 24 #endif | 25 #endif |
| 25 | 26 |
| 26 namespace { | 27 namespace { |
| 27 | 28 |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 147 } | 148 } |
| 148 | 149 |
| 149 void SSLErrorHandler::StartHandlingError() { | 150 void SSLErrorHandler::StartHandlingError() { |
| 150 RecordUMA(HANDLE_ALL); | 151 RecordUMA(HANDLE_ALL); |
| 151 | 152 |
| 152 std::vector<std::string> dns_names; | 153 std::vector<std::string> dns_names; |
| 153 ssl_info_.cert->GetDNSNames(&dns_names); | 154 ssl_info_.cert->GetDNSNames(&dns_names); |
| 154 DCHECK(!dns_names.empty()); | 155 DCHECK(!dns_names.empty()); |
| 155 GURL suggested_url; | 156 GURL suggested_url; |
| 156 if (IsSSLCommonNameMismatchHandlingEnabled() && | 157 if (IsSSLCommonNameMismatchHandlingEnabled() && |
| 157 ssl_info_.cert_status == net::CERT_STATUS_COMMON_NAME_INVALID && | 158 cert_error_ == net::ERR_CERT_COMMON_NAME_INVALID && |
| 159 SSLBlockingPage::IsOverridable(options_mask_, profile_) && | |
|
meacer
2015/08/20 20:51:39
Can you add a unit test for this?
Bhanu Dev
2015/08/20 22:45:06
Done.
| |
| 158 GetSuggestedUrl(dns_names, &suggested_url)) { | 160 GetSuggestedUrl(dns_names, &suggested_url)) { |
| 159 RecordUMA(WWW_MISMATCH_FOUND); | 161 RecordUMA(WWW_MISMATCH_FOUND); |
| 160 net::CertStatus extra_cert_errors = | 162 net::CertStatus extra_cert_errors = |
| 161 ssl_info_.cert_status ^ net::CERT_STATUS_COMMON_NAME_INVALID; | 163 ssl_info_.cert_status ^ net::CERT_STATUS_COMMON_NAME_INVALID; |
| 162 | 164 |
| 163 // Show the SSL intersitial if |CERT_STATUS_COMMON_NAME_INVALID| is not | 165 // Show the SSL intersitial if |CERT_STATUS_COMMON_NAME_INVALID| is not |
| 164 // the only error. Need not check for captive portal in this case. | 166 // the only error. Need not check for captive portal in this case. |
| 165 // (See the comment below). | 167 // (See the comment below). |
| 166 if (net::IsCertStatusError(extra_cert_errors) && | 168 if (net::IsCertStatusError(extra_cert_errors) && |
| 167 !net::IsCertStatusMinorError(ssl_info_.cert_status)) { | 169 !net::IsCertStatusMinorError(ssl_info_.cert_status)) { |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 325 timer_.Stop(); | 327 timer_.Stop(); |
| 326 if (result == CommonNameMismatchHandler::SuggestedUrlCheckResult:: | 328 if (result == CommonNameMismatchHandler::SuggestedUrlCheckResult:: |
| 327 SUGGESTED_URL_AVAILABLE) { | 329 SUGGESTED_URL_AVAILABLE) { |
| 328 RecordUMA(WWW_MISMATCH_URL_AVAILABLE); | 330 RecordUMA(WWW_MISMATCH_URL_AVAILABLE); |
| 329 NavigateToSuggestedURL(suggested_url); | 331 NavigateToSuggestedURL(suggested_url); |
| 330 } else { | 332 } else { |
| 331 RecordUMA(WWW_MISMATCH_URL_NOT_AVAILABLE); | 333 RecordUMA(WWW_MISMATCH_URL_NOT_AVAILABLE); |
| 332 ShowSSLInterstitial(); | 334 ShowSSLInterstitial(); |
| 333 } | 335 } |
| 334 } | 336 } |
| OLD | NEW |