Chromium Code Reviews| 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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 89 security_interstitials::kOptInLink, | 89 security_interstitials::kOptInLink, |
| 90 l10n_util::GetStringFUTF16(safe_browsing::ChooseOptInTextResource( | 90 l10n_util::GetStringFUTF16(safe_browsing::ChooseOptInTextResource( |
| 91 *GetProfile(web_contents_)->GetPrefs(), | 91 *GetProfile(web_contents_)->GetPrefs(), |
| 92 IDS_SAFE_BROWSING_MALWARE_REPORTING_AGREE, | 92 IDS_SAFE_BROWSING_MALWARE_REPORTING_AGREE, |
| 93 IDS_SAFE_BROWSING_SCOUT_REPORTING_AGREE), | 93 IDS_SAFE_BROWSING_SCOUT_REPORTING_AGREE), |
| 94 base::UTF8ToUTF16(privacy_link))); | 94 base::UTF8ToUTF16(privacy_link))); |
| 95 } | 95 } |
| 96 | 96 |
| 97 void CertReportHelper::FinishCertCollection( | 97 void CertReportHelper::FinishCertCollection( |
| 98 certificate_reporting::ErrorReport::ProceedDecision user_proceeded) { | 98 certificate_reporting::ErrorReport::ProceedDecision user_proceeded) { |
| 99 if (!ShouldShowCertificateReporterCheckbox()) | 99 if (!ShouldShowCertificateReporterCheckbox()) { |
| 100 ssl_cert_reporter_->OnDidNotSendReport(); | |
| 100 return; | 101 return; |
| 102 } | |
| 101 | 103 |
| 102 if (!safe_browsing::IsExtendedReportingEnabled( | 104 if (!safe_browsing::IsExtendedReportingEnabled( |
| 103 *GetProfile(web_contents_)->GetPrefs())) | 105 *GetProfile(web_contents_)->GetPrefs())) { |
| 106 ssl_cert_reporter_->OnDidNotSendReport(); | |
| 104 return; | 107 return; |
| 108 } | |
| 105 | 109 |
| 106 if (metrics_helper_) { | 110 if (metrics_helper_) { |
| 107 metrics_helper_->RecordUserInteraction( | 111 metrics_helper_->RecordUserInteraction( |
| 108 security_interstitials::MetricsHelper::EXTENDED_REPORTING_IS_ENABLED); | 112 security_interstitials::MetricsHelper::EXTENDED_REPORTING_IS_ENABLED); |
| 109 } | 113 } |
| 110 | 114 |
| 111 if (!ShouldReportCertificateError()) | 115 if (!ShouldReportCertificateError()) { |
| 116 ssl_cert_reporter_->OnDidNotSendReport(); | |
| 112 return; | 117 return; |
| 118 } | |
| 113 | 119 |
| 114 std::string serialized_report; | 120 std::string serialized_report; |
| 115 certificate_reporting::ErrorReport report(request_url_.host(), ssl_info_); | 121 certificate_reporting::ErrorReport report(request_url_.host(), ssl_info_); |
| 116 | 122 |
| 117 report.AddNetworkTimeInfo(g_browser_process->network_time_tracker()); | 123 report.AddNetworkTimeInfo(g_browser_process->network_time_tracker()); |
| 118 | 124 |
| 119 report.SetInterstitialInfo( | 125 report.SetInterstitialInfo( |
| 120 interstitial_reason_, user_proceeded, | 126 interstitial_reason_, user_proceeded, |
| 121 overridable_ | 127 overridable_ |
| 122 ? certificate_reporting::ErrorReport::INTERSTITIAL_OVERRIDABLE | 128 ? certificate_reporting::ErrorReport::INTERSTITIAL_OVERRIDABLE |
| 123 : certificate_reporting::ErrorReport::INTERSTITIAL_NOT_OVERRIDABLE, | 129 : certificate_reporting::ErrorReport::INTERSTITIAL_NOT_OVERRIDABLE, |
| 124 interstitial_time_); | 130 interstitial_time_); |
| 125 | 131 |
| 126 if (!report.Serialize(&serialized_report)) { | 132 if (!report.Serialize(&serialized_report)) { |
| 127 LOG(ERROR) << "Failed to serialize certificate report."; | 133 LOG(ERROR) << "Failed to serialize certificate report."; |
|
Jialiu Lin
2016/11/30 22:18:07
maybe remove this LOG(ERROR)?
meacer
2016/11/30 23:39:40
estark: I think this is your LOG. Is it okay to re
| |
| 134 ssl_cert_reporter_->OnDidNotSendReport(); | |
| 128 return; | 135 return; |
| 129 } | 136 } |
| 130 | 137 |
| 131 ssl_cert_reporter_->ReportInvalidCertificateChain(serialized_report); | 138 ssl_cert_reporter_->ReportInvalidCertificateChain(serialized_report); |
| 132 } | 139 } |
| 133 | 140 |
| 134 void CertReportHelper::SetSSLCertReporterForTesting( | 141 void CertReportHelper::SetSSLCertReporterForTesting( |
| 135 std::unique_ptr<SSLCertReporter> ssl_cert_reporter) { | 142 std::unique_ptr<SSLCertReporter> ssl_cert_reporter) { |
| 136 ssl_cert_reporter_ = std::move(ssl_cert_reporter); | 143 ssl_cert_reporter_ = std::move(ssl_cert_reporter); |
| 137 } | 144 } |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 160 if (sendingThreshold >= 0.0 && sendingThreshold <= 1.0) | 167 if (sendingThreshold >= 0.0 && sendingThreshold <= 1.0) |
| 161 return base::RandDouble() <= sendingThreshold; | 168 return base::RandDouble() <= sendingThreshold; |
| 162 } | 169 } |
| 163 } | 170 } |
| 164 return false; | 171 return false; |
| 165 } | 172 } |
| 166 | 173 |
| 167 bool CertReportHelper::IsPrefEnabled(const char* pref) { | 174 bool CertReportHelper::IsPrefEnabled(const char* pref) { |
| 168 return GetProfile(web_contents_)->GetPrefs()->GetBoolean(pref); | 175 return GetProfile(web_contents_)->GetPrefs()->GetBoolean(pref); |
| 169 } | 176 } |
| OLD | NEW |