| 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 "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/metrics/field_trial.h" | 8 #include "base/metrics/field_trial.h" |
| 9 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
| 10 #include "base/rand_util.h" | 10 #include "base/rand_util.h" |
| 11 #include "base/strings/string_number_conversions.h" | 11 #include "base/strings/string_number_conversions.h" |
| 12 #include "base/strings/stringprintf.h" | 12 #include "base/strings/stringprintf.h" |
| 13 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
| 14 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
| 15 #include "chrome/browser/ssl/ssl_cert_reporter.h" | 15 #include "chrome/browser/ssl/ssl_cert_reporter.h" |
| 16 #include "chrome/common/pref_names.h" | 16 #include "chrome/common/pref_names.h" |
| 17 #include "chrome/grit/generated_resources.h" | 17 #include "chrome/grit/generated_resources.h" |
| 18 #include "components/security_interstitials/core/controller_client.h" |
| 18 #include "components/security_interstitials/core/metrics_helper.h" | 19 #include "components/security_interstitials/core/metrics_helper.h" |
| 19 #include "components/variations/variations_associated_data.h" | 20 #include "components/variations/variations_associated_data.h" |
| 20 #include "content/public/browser/browser_context.h" | 21 #include "content/public/browser/browser_context.h" |
| 21 #include "content/public/browser/web_contents.h" | 22 #include "content/public/browser/web_contents.h" |
| 22 #include "ui/base/l10n/l10n_util.h" | 23 #include "ui/base/l10n/l10n_util.h" |
| 23 | 24 |
| 25 using security_interstitials::ControllerClient; |
| 26 |
| 24 // Constants for the HTTPSErrorReporter Finch experiment | 27 // Constants for the HTTPSErrorReporter Finch experiment |
| 25 const char CertReportHelper::kFinchExperimentName[] = "ReportCertificateErrors"; | 28 const char CertReportHelper::kFinchExperimentName[] = "ReportCertificateErrors"; |
| 26 const char CertReportHelper::kFinchGroupShowPossiblySend[] = | 29 const char CertReportHelper::kFinchGroupShowPossiblySend[] = |
| 27 "ShowAndPossiblySend"; | 30 "ShowAndPossiblySend"; |
| 28 const char CertReportHelper::kFinchGroupDontShowDontSend[] = | 31 const char CertReportHelper::kFinchGroupDontShowDontSend[] = |
| 29 "DontShowAndDontSend"; | 32 "DontShowAndDontSend"; |
| 30 const char CertReportHelper::kFinchParamName[] = "sendingThreshold"; | 33 const char CertReportHelper::kFinchParamName[] = "sendingThreshold"; |
| 31 | 34 |
| 32 CertReportHelper::CertReportHelper( | 35 CertReportHelper::CertReportHelper( |
| 33 scoped_ptr<SSLCertReporter> ssl_cert_reporter, | 36 scoped_ptr<SSLCertReporter> ssl_cert_reporter, |
| (...skipping 14 matching lines...) Expand all Loading... |
| 48 CertReportHelper::~CertReportHelper() { | 51 CertReportHelper::~CertReportHelper() { |
| 49 } | 52 } |
| 50 | 53 |
| 51 void CertReportHelper::PopulateExtendedReportingOption( | 54 void CertReportHelper::PopulateExtendedReportingOption( |
| 52 base::DictionaryValue* load_time_data) { | 55 base::DictionaryValue* load_time_data) { |
| 53 // Only show the checkbox if not off-the-record and if this client is | 56 // Only show the checkbox if not off-the-record and if this client is |
| 54 // part of the respective Finch group, and the feature is not disabled | 57 // part of the respective Finch group, and the feature is not disabled |
| 55 // by policy. | 58 // by policy. |
| 56 const bool show = ShouldShowCertificateReporterCheckbox(); | 59 const bool show = ShouldShowCertificateReporterCheckbox(); |
| 57 | 60 |
| 58 load_time_data->SetBoolean(interstitials::kDisplayCheckBox, show); | 61 load_time_data->SetBoolean(security_interstitials::kDisplayCheckBox, show); |
| 59 if (!show) | 62 if (!show) |
| 60 return; | 63 return; |
| 61 | 64 |
| 62 load_time_data->SetBoolean( | 65 load_time_data->SetBoolean( |
| 63 interstitials::kBoxChecked, | 66 security_interstitials::kBoxChecked, |
| 64 IsPrefEnabled(prefs::kSafeBrowsingExtendedReportingEnabled)); | 67 IsPrefEnabled(prefs::kSafeBrowsingExtendedReportingEnabled)); |
| 65 | 68 |
| 66 const std::string privacy_link = base::StringPrintf( | 69 const std::string privacy_link = base::StringPrintf( |
| 67 interstitials::kPrivacyLinkHtml, | 70 security_interstitials::kPrivacyLinkHtml, |
| 68 SecurityInterstitialPage::CMD_OPEN_REPORTING_PRIVACY, | 71 ControllerClient::CMD_OPEN_REPORTING_PRIVACY, |
| 69 l10n_util::GetStringUTF8(IDS_SAFE_BROWSING_PRIVACY_POLICY_PAGE).c_str()); | 72 l10n_util::GetStringUTF8(IDS_SAFE_BROWSING_PRIVACY_POLICY_PAGE).c_str()); |
| 70 | 73 |
| 71 load_time_data->SetString( | 74 load_time_data->SetString( |
| 72 interstitials::kOptInLink, | 75 security_interstitials::kOptInLink, |
| 73 l10n_util::GetStringFUTF16(IDS_SAFE_BROWSING_MALWARE_REPORTING_AGREE, | 76 l10n_util::GetStringFUTF16(IDS_SAFE_BROWSING_MALWARE_REPORTING_AGREE, |
| 74 base::UTF8ToUTF16(privacy_link))); | 77 base::UTF8ToUTF16(privacy_link))); |
| 75 } | 78 } |
| 76 | 79 |
| 77 void CertReportHelper::FinishCertCollection( | 80 void CertReportHelper::FinishCertCollection( |
| 78 certificate_reporting::ErrorReport::ProceedDecision user_proceeded) { | 81 certificate_reporting::ErrorReport::ProceedDecision user_proceeded) { |
| 79 if (!ShouldShowCertificateReporterCheckbox()) | 82 if (!ShouldShowCertificateReporterCheckbox()) |
| 80 return; | 83 return; |
| 81 | 84 |
| 82 if (!IsPrefEnabled(prefs::kSafeBrowsingExtendedReportingEnabled)) | 85 if (!IsPrefEnabled(prefs::kSafeBrowsingExtendedReportingEnabled)) |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 } | 147 } |
| 145 #endif | 148 #endif |
| 146 return false; | 149 return false; |
| 147 } | 150 } |
| 148 | 151 |
| 149 bool CertReportHelper::IsPrefEnabled(const char* pref) { | 152 bool CertReportHelper::IsPrefEnabled(const char* pref) { |
| 150 Profile* profile = | 153 Profile* profile = |
| 151 Profile::FromBrowserContext(web_contents_->GetBrowserContext()); | 154 Profile::FromBrowserContext(web_contents_->GetBrowserContext()); |
| 152 return profile->GetPrefs()->GetBoolean(pref); | 155 return profile->GetPrefs()->GetBoolean(pref); |
| 153 } | 156 } |
| OLD | NEW |