| 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> |
| 8 |
| 7 #include "base/logging.h" | 9 #include "base/logging.h" |
| 8 #include "base/metrics/field_trial.h" | 10 #include "base/metrics/field_trial.h" |
| 9 #include "base/prefs/pref_service.h" | 11 #include "base/prefs/pref_service.h" |
| 10 #include "base/rand_util.h" | 12 #include "base/rand_util.h" |
| 11 #include "base/strings/string_number_conversions.h" | 13 #include "base/strings/string_number_conversions.h" |
| 12 #include "base/strings/stringprintf.h" | 14 #include "base/strings/stringprintf.h" |
| 13 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
| 14 #include "build/build_config.h" | 16 #include "build/build_config.h" |
| 15 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
| 16 #include "chrome/browser/ssl/ssl_cert_reporter.h" | 18 #include "chrome/browser/ssl/ssl_cert_reporter.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 32 const char CertReportHelper::kFinchParamName[] = "sendingThreshold"; | 34 const char CertReportHelper::kFinchParamName[] = "sendingThreshold"; |
| 33 | 35 |
| 34 CertReportHelper::CertReportHelper( | 36 CertReportHelper::CertReportHelper( |
| 35 scoped_ptr<SSLCertReporter> ssl_cert_reporter, | 37 scoped_ptr<SSLCertReporter> ssl_cert_reporter, |
| 36 content::WebContents* web_contents, | 38 content::WebContents* web_contents, |
| 37 const GURL& request_url, | 39 const GURL& request_url, |
| 38 const net::SSLInfo& ssl_info, | 40 const net::SSLInfo& ssl_info, |
| 39 certificate_reporting::ErrorReport::InterstitialReason interstitial_reason, | 41 certificate_reporting::ErrorReport::InterstitialReason interstitial_reason, |
| 40 bool overridable, | 42 bool overridable, |
| 41 security_interstitials::MetricsHelper* metrics_helper) | 43 security_interstitials::MetricsHelper* metrics_helper) |
| 42 : ssl_cert_reporter_(ssl_cert_reporter.Pass()), | 44 : ssl_cert_reporter_(std::move(ssl_cert_reporter)), |
| 43 web_contents_(web_contents), | 45 web_contents_(web_contents), |
| 44 request_url_(request_url), | 46 request_url_(request_url), |
| 45 ssl_info_(ssl_info), | 47 ssl_info_(ssl_info), |
| 46 interstitial_reason_(interstitial_reason), | 48 interstitial_reason_(interstitial_reason), |
| 47 overridable_(overridable), | 49 overridable_(overridable), |
| 48 metrics_helper_(metrics_helper) {} | 50 metrics_helper_(metrics_helper) {} |
| 49 | 51 |
| 50 CertReportHelper::~CertReportHelper() { | 52 CertReportHelper::~CertReportHelper() { |
| 51 } | 53 } |
| 52 | 54 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 if (!report.Serialize(&serialized_report)) { | 106 if (!report.Serialize(&serialized_report)) { |
| 105 LOG(ERROR) << "Failed to serialize certificate report."; | 107 LOG(ERROR) << "Failed to serialize certificate report."; |
| 106 return; | 108 return; |
| 107 } | 109 } |
| 108 | 110 |
| 109 ssl_cert_reporter_->ReportInvalidCertificateChain(serialized_report); | 111 ssl_cert_reporter_->ReportInvalidCertificateChain(serialized_report); |
| 110 } | 112 } |
| 111 | 113 |
| 112 void CertReportHelper::SetSSLCertReporterForTesting( | 114 void CertReportHelper::SetSSLCertReporterForTesting( |
| 113 scoped_ptr<SSLCertReporter> ssl_cert_reporter) { | 115 scoped_ptr<SSLCertReporter> ssl_cert_reporter) { |
| 114 ssl_cert_reporter_ = ssl_cert_reporter.Pass(); | 116 ssl_cert_reporter_ = std::move(ssl_cert_reporter); |
| 115 } | 117 } |
| 116 | 118 |
| 117 bool CertReportHelper::ShouldShowCertificateReporterCheckbox() { | 119 bool CertReportHelper::ShouldShowCertificateReporterCheckbox() { |
| 118 #if defined(OS_IOS) | 120 #if defined(OS_IOS) |
| 119 return false; | 121 return false; |
| 120 #else | 122 #else |
| 121 // Only show the checkbox iff the user is part of the respective Finch group | 123 // Only show the checkbox iff the user is part of the respective Finch group |
| 122 // and the window is not incognito and the feature is not disabled by policy. | 124 // and the window is not incognito and the feature is not disabled by policy. |
| 123 const bool in_incognito = | 125 const bool in_incognito = |
| 124 web_contents_->GetBrowserContext()->IsOffTheRecord(); | 126 web_contents_->GetBrowserContext()->IsOffTheRecord(); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 146 } | 148 } |
| 147 #endif | 149 #endif |
| 148 return false; | 150 return false; |
| 149 } | 151 } |
| 150 | 152 |
| 151 bool CertReportHelper::IsPrefEnabled(const char* pref) { | 153 bool CertReportHelper::IsPrefEnabled(const char* pref) { |
| 152 Profile* profile = | 154 Profile* profile = |
| 153 Profile::FromBrowserContext(web_contents_->GetBrowserContext()); | 155 Profile::FromBrowserContext(web_contents_->GetBrowserContext()); |
| 154 return profile->GetPrefs()->GetBoolean(pref); | 156 return profile->GetPrefs()->GetBoolean(pref); |
| 155 } | 157 } |
| OLD | NEW |