Chromium Code Reviews| Index: chrome/browser/ssl/ssl_blocking_page.cc |
| diff --git a/chrome/browser/ssl/ssl_blocking_page.cc b/chrome/browser/ssl/ssl_blocking_page.cc |
| index e6083f8768ecf1a12308fb8d693f8b38bc584562..8f5d9b38eb90728d3ae2e63117cda097bda4d4de 100644 |
| --- a/chrome/browser/ssl/ssl_blocking_page.cc |
| +++ b/chrome/browser/ssl/ssl_blocking_page.cc |
| @@ -15,6 +15,7 @@ |
| #include "base/metrics/histogram.h" |
| #include "base/prefs/pref_service.h" |
| #include "base/process/launch.h" |
| +#include "base/rand_util.h" |
| #include "base/strings/string_number_conversions.h" |
| #include "base/strings/string_piece.h" |
| #include "base/strings/string_util.h" |
| @@ -35,6 +36,7 @@ |
| #include "chrome/grit/chromium_strings.h" |
| #include "chrome/grit/generated_resources.h" |
| #include "components/google/core/browser/google_util.h" |
| +#include "components/variations/variations_associated_data.h" |
| #include "content/public/browser/browser_thread.h" |
| #include "content/public/browser/cert_store.h" |
| #include "content/public/browser/interstitial_page.h" |
| @@ -100,6 +102,31 @@ enum SSLExpirationAndDecision { |
| // Rappor prefix |
| const char kSSLRapporPrefix[] = "ssl"; |
| +// Check whether to report certificate verification errors to Google |
| +bool ReportCertificateErrors() { |
| + // Check Finch parameters |
| + const std::string show = |
| + base::FieldTrialList::FindFullName("ReportCertificateErrors"); |
| + if (show.compare("ShowAndPossiblySend") == 0) { |
| + const std::string param = variations::GetVariationParamValue( |
| + "ReportCertificateErrors", "possibly_send"); |
| + if (param.compare("") != 0) { |
| + double possiblySend; |
| + LOG(ERROR) << "RandValue: " << base::RandDouble(); |
| + if (base::StringToDouble(param, &possiblySend)) |
| + return base::RandDouble() <= possiblySend; |
| + } |
| + } |
| + return false; |
| +} |
| + |
| +// Check whether to show the certificate reporter checkbox |
| +bool ShowCertificateReporterCheckbox() { |
| + // Check Finch parameters |
| + return base::FieldTrialList::FindFullName("ReportCertificateErrors") |
|
estark
2015/04/02 01:19:51
How about doing the incognito check in here?
|
| + .compare("ShowAndPossiblySend") == 0; |
| +} |
| + |
| void RecordSSLExpirationPageEventState(bool expired_but_previously_allowed, |
| bool proceed, |
| bool overridable) { |
| @@ -458,8 +485,7 @@ void SSLBlockingPage::PopulateExtendedReportingOption( |
| // Only show the checkbox if not off-the-record and if the |
| // command-line option is set. |
| const bool show = !web_contents()->GetBrowserContext()->IsOffTheRecord() && |
| - base::CommandLine::ForCurrentProcess()->HasSwitch( |
| - switches::kEnableInvalidCertCollection); |
| + ShowCertificateReporterCheckbox(); |
|
estark
2015/04/02 01:19:51
If you do the incognito check in ShowCertificateRe
|
| load_time_data->SetBoolean(interstitials::kDisplayCheckBox, show); |
| if (!show) |
| @@ -645,11 +671,9 @@ void SSLBlockingPage::FinishCertCollection() { |
| base::ScopedClosureRunner scoped_callback( |
| certificate_report_callback_for_testing_); |
| - if (!base::CommandLine::ForCurrentProcess()->HasSwitch( |
| - switches::kEnableInvalidCertCollection) || |
| - web_contents()->GetBrowserContext()->IsOffTheRecord()) { |
| + if (!ReportCertificateErrors() || |
|
estark
2015/04/02 01:19:51
I think this should just be:
if (!ShowCertificate
fahl
2015/04/02 02:01:22
Done.
|
| + web_contents()->GetBrowserContext()->IsOffTheRecord()) |
| return; |
| - } |
| const bool enabled = |
| IsPrefEnabled(prefs::kSafeBrowsingExtendedReportingEnabled); |
| @@ -660,11 +684,12 @@ void SSLBlockingPage::FinishCertCollection() { |
| metrics_helper()->RecordUserInteraction( |
| SecurityInterstitialMetricsHelper::EXTENDED_REPORTING_IS_ENABLED); |
| - if (certificate_report_callback_for_testing_.is_null()) |
| - scoped_callback.Reset(base::Bind(&base::DoNothing)); |
| - |
| - safe_browsing_ui_manager_->ReportInvalidCertificateChain( |
| - request_url().host(), ssl_info_, scoped_callback.Release()); |
| + if (ReportCertificateErrors()) { |
| + if (certificate_report_callback_for_testing_.is_null()) |
| + scoped_callback.Reset(base::Bind(&base::DoNothing)); |
| + safe_browsing_ui_manager_->ReportInvalidCertificateChain( |
| + request_url().host(), ssl_info_, scoped_callback.Release()); |
| + } |
| } |
| // static |