| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/cert_report_helper.h" | 5 #include "chrome/browser/ssl/cert_report_helper.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/metrics/field_trial.h" | 10 #include "base/metrics/field_trial.h" |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 "DontShowAndDontSend"; | 44 "DontShowAndDontSend"; |
| 45 const char CertReportHelper::kFinchParamName[] = "sendingThreshold"; | 45 const char CertReportHelper::kFinchParamName[] = "sendingThreshold"; |
| 46 | 46 |
| 47 CertReportHelper::CertReportHelper( | 47 CertReportHelper::CertReportHelper( |
| 48 std::unique_ptr<SSLCertReporter> ssl_cert_reporter, | 48 std::unique_ptr<SSLCertReporter> ssl_cert_reporter, |
| 49 content::WebContents* web_contents, | 49 content::WebContents* web_contents, |
| 50 const GURL& request_url, | 50 const GURL& request_url, |
| 51 const net::SSLInfo& ssl_info, | 51 const net::SSLInfo& ssl_info, |
| 52 certificate_reporting::ErrorReport::InterstitialReason interstitial_reason, | 52 certificate_reporting::ErrorReport::InterstitialReason interstitial_reason, |
| 53 bool overridable, | 53 bool overridable, |
| 54 const base::Time& interstitial_time, |
| 54 security_interstitials::MetricsHelper* metrics_helper) | 55 security_interstitials::MetricsHelper* metrics_helper) |
| 55 : ssl_cert_reporter_(std::move(ssl_cert_reporter)), | 56 : ssl_cert_reporter_(std::move(ssl_cert_reporter)), |
| 56 web_contents_(web_contents), | 57 web_contents_(web_contents), |
| 57 request_url_(request_url), | 58 request_url_(request_url), |
| 58 ssl_info_(ssl_info), | 59 ssl_info_(ssl_info), |
| 59 interstitial_reason_(interstitial_reason), | 60 interstitial_reason_(interstitial_reason), |
| 60 overridable_(overridable), | 61 overridable_(overridable), |
| 62 interstitial_time_(interstitial_time), |
| 61 metrics_helper_(metrics_helper) {} | 63 metrics_helper_(metrics_helper) {} |
| 62 | 64 |
| 63 CertReportHelper::~CertReportHelper() { | 65 CertReportHelper::~CertReportHelper() { |
| 64 } | 66 } |
| 65 | 67 |
| 66 void CertReportHelper::PopulateExtendedReportingOption( | 68 void CertReportHelper::PopulateExtendedReportingOption( |
| 67 base::DictionaryValue* load_time_data) { | 69 base::DictionaryValue* load_time_data) { |
| 68 // Only show the checkbox if not off-the-record and if this client is | 70 // Only show the checkbox if not off-the-record and if this client is |
| 69 // part of the respective Finch group, and the feature is not disabled | 71 // part of the respective Finch group, and the feature is not disabled |
| 70 // by policy. | 72 // by policy. |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 | 113 |
| 112 std::string serialized_report; | 114 std::string serialized_report; |
| 113 certificate_reporting::ErrorReport report(request_url_.host(), ssl_info_); | 115 certificate_reporting::ErrorReport report(request_url_.host(), ssl_info_); |
| 114 | 116 |
| 115 report.AddNetworkTimeInfo(g_browser_process->network_time_tracker()); | 117 report.AddNetworkTimeInfo(g_browser_process->network_time_tracker()); |
| 116 | 118 |
| 117 report.SetInterstitialInfo( | 119 report.SetInterstitialInfo( |
| 118 interstitial_reason_, user_proceeded, | 120 interstitial_reason_, user_proceeded, |
| 119 overridable_ | 121 overridable_ |
| 120 ? certificate_reporting::ErrorReport::INTERSTITIAL_OVERRIDABLE | 122 ? certificate_reporting::ErrorReport::INTERSTITIAL_OVERRIDABLE |
| 121 : certificate_reporting::ErrorReport::INTERSTITIAL_NOT_OVERRIDABLE); | 123 : certificate_reporting::ErrorReport::INTERSTITIAL_NOT_OVERRIDABLE, |
| 124 interstitial_time_); |
| 122 | 125 |
| 123 if (!report.Serialize(&serialized_report)) { | 126 if (!report.Serialize(&serialized_report)) { |
| 124 LOG(ERROR) << "Failed to serialize certificate report."; | 127 LOG(ERROR) << "Failed to serialize certificate report."; |
| 125 return; | 128 return; |
| 126 } | 129 } |
| 127 | 130 |
| 128 ssl_cert_reporter_->ReportInvalidCertificateChain(serialized_report); | 131 ssl_cert_reporter_->ReportInvalidCertificateChain(serialized_report); |
| 129 } | 132 } |
| 130 | 133 |
| 131 void CertReportHelper::SetSSLCertReporterForTesting( | 134 void CertReportHelper::SetSSLCertReporterForTesting( |
| (...skipping 25 matching lines...) Expand all Loading... |
| 157 if (sendingThreshold >= 0.0 && sendingThreshold <= 1.0) | 160 if (sendingThreshold >= 0.0 && sendingThreshold <= 1.0) |
| 158 return base::RandDouble() <= sendingThreshold; | 161 return base::RandDouble() <= sendingThreshold; |
| 159 } | 162 } |
| 160 } | 163 } |
| 161 return false; | 164 return false; |
| 162 } | 165 } |
| 163 | 166 |
| 164 bool CertReportHelper::IsPrefEnabled(const char* pref) { | 167 bool CertReportHelper::IsPrefEnabled(const char* pref) { |
| 165 return GetProfile(web_contents_)->GetPrefs()->GetBoolean(pref); | 168 return GetProfile(web_contents_)->GetPrefs()->GetBoolean(pref); |
| 166 } | 169 } |
| OLD | NEW |