Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/ssl_blocking_page.h" | 5 #include "chrome/browser/ssl/ssl_blocking_page.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/build_time.h" | 9 #include "base/build_time.h" |
| 10 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
| 11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| 12 #include "base/i18n/rtl.h" | 12 #include "base/i18n/rtl.h" |
| 13 #include "base/i18n/time_formatting.h" | 13 #include "base/i18n/time_formatting.h" |
| 14 #include "base/metrics/field_trial.h" | 14 #include "base/metrics/field_trial.h" |
| 15 #include "base/metrics/histogram.h" | 15 #include "base/metrics/histogram.h" |
| 16 #include "base/prefs/pref_service.h" | 16 #include "base/prefs/pref_service.h" |
| 17 #include "base/process/launch.h" | 17 #include "base/process/launch.h" |
| 18 #include "base/rand_util.h" | |
| 18 #include "base/strings/string_number_conversions.h" | 19 #include "base/strings/string_number_conversions.h" |
| 19 #include "base/strings/string_piece.h" | 20 #include "base/strings/string_piece.h" |
| 20 #include "base/strings/string_util.h" | 21 #include "base/strings/string_util.h" |
| 21 #include "base/strings/stringprintf.h" | 22 #include "base/strings/stringprintf.h" |
| 22 #include "base/strings/utf_string_conversions.h" | 23 #include "base/strings/utf_string_conversions.h" |
| 23 #include "base/time/time.h" | 24 #include "base/time/time.h" |
| 24 #include "base/values.h" | 25 #include "base/values.h" |
| 25 #include "chrome/browser/browser_process.h" | 26 #include "chrome/browser/browser_process.h" |
| 26 #include "chrome/browser/chrome_notification_types.h" | 27 #include "chrome/browser/chrome_notification_types.h" |
| 27 #include "chrome/browser/interstitials/security_interstitial_metrics_helper.h" | 28 #include "chrome/browser/interstitials/security_interstitial_metrics_helper.h" |
| 28 #include "chrome/browser/profiles/profile.h" | 29 #include "chrome/browser/profiles/profile.h" |
| 29 #include "chrome/browser/renderer_preferences_util.h" | 30 #include "chrome/browser/renderer_preferences_util.h" |
| 30 #include "chrome/browser/safe_browsing/ui_manager.h" | 31 #include "chrome/browser/safe_browsing/ui_manager.h" |
| 31 #include "chrome/browser/ssl/ssl_error_classification.h" | 32 #include "chrome/browser/ssl/ssl_error_classification.h" |
| 32 #include "chrome/browser/ssl/ssl_error_info.h" | 33 #include "chrome/browser/ssl/ssl_error_info.h" |
| 33 #include "chrome/common/chrome_switches.h" | 34 #include "chrome/common/chrome_switches.h" |
| 34 #include "chrome/common/pref_names.h" | 35 #include "chrome/common/pref_names.h" |
| 35 #include "chrome/grit/chromium_strings.h" | 36 #include "chrome/grit/chromium_strings.h" |
| 36 #include "chrome/grit/generated_resources.h" | 37 #include "chrome/grit/generated_resources.h" |
| 37 #include "components/google/core/browser/google_util.h" | 38 #include "components/google/core/browser/google_util.h" |
| 39 #include "components/variations/variations_associated_data.h" | |
| 38 #include "content/public/browser/browser_thread.h" | 40 #include "content/public/browser/browser_thread.h" |
| 39 #include "content/public/browser/cert_store.h" | 41 #include "content/public/browser/cert_store.h" |
| 40 #include "content/public/browser/interstitial_page.h" | 42 #include "content/public/browser/interstitial_page.h" |
| 41 #include "content/public/browser/interstitial_page_delegate.h" | 43 #include "content/public/browser/interstitial_page_delegate.h" |
| 42 #include "content/public/browser/navigation_controller.h" | 44 #include "content/public/browser/navigation_controller.h" |
| 43 #include "content/public/browser/navigation_entry.h" | 45 #include "content/public/browser/navigation_entry.h" |
| 44 #include "content/public/browser/notification_service.h" | 46 #include "content/public/browser/notification_service.h" |
| 45 #include "content/public/browser/notification_types.h" | 47 #include "content/public/browser/notification_types.h" |
| 46 #include "content/public/browser/render_process_host.h" | 48 #include "content/public/browser/render_process_host.h" |
| 47 #include "content/public/browser/render_view_host.h" | 49 #include "content/public/browser/render_view_host.h" |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 93 EXPIRED_AND_PROCEED, | 95 EXPIRED_AND_PROCEED, |
| 94 EXPIRED_AND_DO_NOT_PROCEED, | 96 EXPIRED_AND_DO_NOT_PROCEED, |
| 95 NOT_EXPIRED_AND_PROCEED, | 97 NOT_EXPIRED_AND_PROCEED, |
| 96 NOT_EXPIRED_AND_DO_NOT_PROCEED, | 98 NOT_EXPIRED_AND_DO_NOT_PROCEED, |
| 97 END_OF_SSL_EXPIRATION_AND_DECISION, | 99 END_OF_SSL_EXPIRATION_AND_DECISION, |
| 98 }; | 100 }; |
| 99 | 101 |
| 100 // Rappor prefix | 102 // Rappor prefix |
| 101 const char kSSLRapporPrefix[] = "ssl"; | 103 const char kSSLRapporPrefix[] = "ssl"; |
| 102 | 104 |
| 105 // Check whether to report certificate verification errors to Google | |
| 106 bool ReportCertificateErrors(bool in_incognito) { | |
| 107 // Check Finch parameters | |
| 108 const std::string show = | |
| 109 base::FieldTrialList::FindFullName("ReportCertificateErrors"); | |
| 110 if (show.compare("ShowAndPossiblySend") == 0) { | |
| 111 const std::string param = variations::GetVariationParamValue( | |
| 112 "ReportCertificateErrors", "possibly_send"); | |
| 113 if (param.compare("") != 0) { | |
| 114 double possiblySend; | |
| 115 LOG(ERROR) << "RandValue: " << base::RandDouble(); | |
|
estark
2015/04/02 18:33:34
any reason to leave this in?
fahl
2015/04/02 19:24:58
Done.
| |
| 116 if (base::StringToDouble(param, &possiblySend)) | |
|
estark
2015/04/02 18:33:34
This logic looks funny to me... |ReportCertificate
fahl
2015/04/02 19:24:58
Done.
| |
| 117 return base::RandDouble() <= possiblySend; | |
| 118 } | |
| 119 } | |
| 120 return !in_incognito; | |
| 121 } | |
| 122 | |
| 123 // Check whether to show the certificate reporter checkbox | |
| 124 bool ShowCertificateReporterCheckbox(bool in_incognito) { | |
| 125 // Check Finch parameters | |
| 126 return base::FieldTrialList::FindFullName("ReportCertificateErrors") | |
| 127 .compare("ShowAndPossiblySend") == 0 && | |
| 128 !in_incognito; | |
| 129 } | |
| 130 | |
| 103 void RecordSSLExpirationPageEventState(bool expired_but_previously_allowed, | 131 void RecordSSLExpirationPageEventState(bool expired_but_previously_allowed, |
| 104 bool proceed, | 132 bool proceed, |
| 105 bool overridable) { | 133 bool overridable) { |
| 106 SSLExpirationAndDecision event; | 134 SSLExpirationAndDecision event; |
| 107 if (expired_but_previously_allowed && proceed) | 135 if (expired_but_previously_allowed && proceed) |
| 108 event = EXPIRED_AND_PROCEED; | 136 event = EXPIRED_AND_PROCEED; |
| 109 else if (expired_but_previously_allowed && !proceed) | 137 else if (expired_but_previously_allowed && !proceed) |
| 110 event = EXPIRED_AND_DO_NOT_PROCEED; | 138 event = EXPIRED_AND_DO_NOT_PROCEED; |
| 111 else if (!expired_but_previously_allowed && proceed) | 139 else if (!expired_but_previously_allowed && proceed) |
| 112 event = NOT_EXPIRED_AND_PROCEED; | 140 event = NOT_EXPIRED_AND_PROCEED; |
| (...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 450 load_time_data->SetString( | 478 load_time_data->SetString( |
| 451 "pem", JoinString(encoded_chain, std::string())); | 479 "pem", JoinString(encoded_chain, std::string())); |
| 452 | 480 |
| 453 PopulateExtendedReportingOption(load_time_data); | 481 PopulateExtendedReportingOption(load_time_data); |
| 454 } | 482 } |
| 455 | 483 |
| 456 void SSLBlockingPage::PopulateExtendedReportingOption( | 484 void SSLBlockingPage::PopulateExtendedReportingOption( |
| 457 base::DictionaryValue* load_time_data) { | 485 base::DictionaryValue* load_time_data) { |
| 458 // Only show the checkbox if not off-the-record and if the | 486 // Only show the checkbox if not off-the-record and if the |
| 459 // command-line option is set. | 487 // command-line option is set. |
| 460 const bool show = !web_contents()->GetBrowserContext()->IsOffTheRecord() && | 488 const bool show = ShowCertificateReporterCheckbox( |
| 461 base::CommandLine::ForCurrentProcess()->HasSwitch( | 489 web_contents()->GetBrowserContext()->IsOffTheRecord()); |
| 462 switches::kEnableInvalidCertCollection); | |
| 463 | 490 |
| 464 load_time_data->SetBoolean(interstitials::kDisplayCheckBox, show); | 491 load_time_data->SetBoolean(interstitials::kDisplayCheckBox, show); |
| 465 if (!show) | 492 if (!show) |
| 466 return; | 493 return; |
| 467 | 494 |
| 468 load_time_data->SetBoolean( | 495 load_time_data->SetBoolean( |
| 469 interstitials::kBoxChecked, | 496 interstitials::kBoxChecked, |
| 470 IsPrefEnabled(prefs::kSafeBrowsingExtendedReportingEnabled)); | 497 IsPrefEnabled(prefs::kSafeBrowsingExtendedReportingEnabled)); |
| 471 | 498 |
| 472 const std::string privacy_link = base::StringPrintf( | 499 const std::string privacy_link = base::StringPrintf( |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 638 else | 665 else |
| 639 event_name.append(kEventNotOverridable); | 666 event_name.append(kEventNotOverridable); |
| 640 event_name.append(net::ErrorToString(cert_error_)); | 667 event_name.append(net::ErrorToString(cert_error_)); |
| 641 return event_name; | 668 return event_name; |
| 642 } | 669 } |
| 643 | 670 |
| 644 void SSLBlockingPage::FinishCertCollection() { | 671 void SSLBlockingPage::FinishCertCollection() { |
| 645 base::ScopedClosureRunner scoped_callback( | 672 base::ScopedClosureRunner scoped_callback( |
| 646 certificate_report_callback_for_testing_); | 673 certificate_report_callback_for_testing_); |
| 647 | 674 |
| 648 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( | 675 if (!ShowCertificateReporterCheckbox( |
| 649 switches::kEnableInvalidCertCollection) || | 676 web_contents()->GetBrowserContext()->IsOffTheRecord())) |
| 650 web_contents()->GetBrowserContext()->IsOffTheRecord()) { | |
| 651 return; | 677 return; |
| 652 } | |
| 653 | 678 |
| 654 const bool enabled = | 679 const bool enabled = |
| 655 IsPrefEnabled(prefs::kSafeBrowsingExtendedReportingEnabled); | 680 IsPrefEnabled(prefs::kSafeBrowsingExtendedReportingEnabled); |
| 656 | 681 |
| 657 if (!enabled) | 682 if (!enabled) |
| 658 return; | 683 return; |
| 659 | 684 |
| 660 metrics_helper()->RecordUserInteraction( | 685 metrics_helper()->RecordUserInteraction( |
| 661 SecurityInterstitialMetricsHelper::EXTENDED_REPORTING_IS_ENABLED); | 686 SecurityInterstitialMetricsHelper::EXTENDED_REPORTING_IS_ENABLED); |
| 662 | 687 |
| 663 if (certificate_report_callback_for_testing_.is_null()) | 688 if (ReportCertificateErrors( |
| 664 scoped_callback.Reset(base::Bind(&base::DoNothing)); | 689 web_contents()->GetBrowserContext()->IsOffTheRecord())) { |
| 665 | 690 if (certificate_report_callback_for_testing_.is_null()) |
| 666 safe_browsing_ui_manager_->ReportInvalidCertificateChain( | 691 scoped_callback.Reset(base::Bind(&base::DoNothing)); |
| 667 request_url().host(), ssl_info_, scoped_callback.Release()); | 692 safe_browsing_ui_manager_->ReportInvalidCertificateChain( |
| 693 request_url().host(), ssl_info_, scoped_callback.Release()); | |
| 694 } | |
| 668 } | 695 } |
| 669 | 696 |
| 670 // static | 697 // static |
| 671 bool SSLBlockingPage::IsOptionsOverridable(int options_mask) { | 698 bool SSLBlockingPage::IsOptionsOverridable(int options_mask) { |
| 672 return (options_mask & SSLBlockingPage::OVERRIDABLE) && | 699 return (options_mask & SSLBlockingPage::OVERRIDABLE) && |
| 673 !(options_mask & SSLBlockingPage::STRICT_ENFORCEMENT); | 700 !(options_mask & SSLBlockingPage::STRICT_ENFORCEMENT); |
| 674 } | 701 } |
| OLD | NEW |