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 23 matching lines...) Expand all Loading... | |
71 #include "chrome/common/url_constants.h" | 73 #include "chrome/common/url_constants.h" |
72 #endif | 74 #endif |
73 | 75 |
74 using base::ASCIIToUTF16; | 76 using base::ASCIIToUTF16; |
75 using base::TimeTicks; | 77 using base::TimeTicks; |
76 using content::InterstitialPage; | 78 using content::InterstitialPage; |
77 using content::InterstitialPageDelegate; | 79 using content::InterstitialPageDelegate; |
78 using content::NavigationController; | 80 using content::NavigationController; |
79 using content::NavigationEntry; | 81 using content::NavigationEntry; |
80 | 82 |
83 // Constants for the HTTPSErrorReporter Finch experiment | |
84 const char kHTTPSErrorReporterFinchExperimentName[] = "ReportCertificateErrors"; | |
85 const char kHTTPSErrorReporterFinchGroupShowPossiblySend[] = | |
86 "ShowAndPossiblySend"; | |
87 const char kHTTPSErrorReporterFinchParamName[] = "possibly_send"; | |
88 | |
81 namespace { | 89 namespace { |
82 | 90 |
83 // URL for help page. | 91 // URL for help page. |
84 const char kHelpURL[] = "https://support.google.com/chrome/answer/4454607"; | 92 const char kHelpURL[] = "https://support.google.com/chrome/answer/4454607"; |
85 | 93 |
86 // Constants for the Experience Sampling instrumentation. | 94 // Constants for the Experience Sampling instrumentation. |
87 const char kEventNameBase[] = "ssl_interstitial_"; | 95 const char kEventNameBase[] = "ssl_interstitial_"; |
88 const char kEventNotOverridable[] = "notoverridable_"; | 96 const char kEventNotOverridable[] = "notoverridable_"; |
89 const char kEventOverridable[] = "overridable_"; | 97 const char kEventOverridable[] = "overridable_"; |
90 | 98 |
91 // Events for UMA. Do not reorder or change! | 99 // Events for UMA. Do not reorder or change! |
92 enum SSLExpirationAndDecision { | 100 enum SSLExpirationAndDecision { |
93 EXPIRED_AND_PROCEED, | 101 EXPIRED_AND_PROCEED, |
94 EXPIRED_AND_DO_NOT_PROCEED, | 102 EXPIRED_AND_DO_NOT_PROCEED, |
95 NOT_EXPIRED_AND_PROCEED, | 103 NOT_EXPIRED_AND_PROCEED, |
96 NOT_EXPIRED_AND_DO_NOT_PROCEED, | 104 NOT_EXPIRED_AND_DO_NOT_PROCEED, |
97 END_OF_SSL_EXPIRATION_AND_DECISION, | 105 END_OF_SSL_EXPIRATION_AND_DECISION, |
98 }; | 106 }; |
99 | 107 |
100 // Rappor prefix | 108 // Rappor prefix |
101 const char kSSLRapporPrefix[] = "ssl"; | 109 const char kSSLRapporPrefix[] = "ssl"; |
102 | 110 |
111 // Check whether to show the certificate reporter checkbox | |
112 bool ShouldShowCertificateReporterCheckbox(bool in_incognito) { | |
113 // Only show the checkbox iff the user is part of the respective Finch group | |
114 // and the window is not incognito. | |
115 return base::FieldTrialList::FindFullName( | |
116 kHTTPSErrorReporterFinchExperimentName) == | |
117 kHTTPSErrorReporterFinchGroupShowPossiblySend && | |
118 !in_incognito; | |
119 } | |
120 | |
121 // Check whether to report certificate verification errors to Google | |
122 bool ShouldReportCertificateErrors(bool in_incognito) { | |
123 DCHECK(ShouldShowCertificateReporterCheckbox(in_incognito)); | |
124 // Even in case the checkbox was shown, we don't send error reports | |
125 // for all of these users. Check the Finch configuration for a sending | |
126 // threshold and only send reports in case the threshold isn't exceeded. | |
127 const std::string sendingThreshold = | |
128 variations::GetVariationParamValue(kHTTPSErrorReporterFinchExperimentName, | |
129 kHTTPSErrorReporterFinchParamName); | |
130 if (!sendingThreshold.empty()) { | |
felt
2015/04/03 22:38:09
err, I must have commented on the wrong line befor
fahl
2015/04/04 00:33:18
Done.
| |
131 double possiblySend; | |
132 if (base::StringToDouble(sendingThreshold, &possiblySend)) { | |
133 if (possiblySend >= 0.0 && possiblySend <= 1.0) | |
134 return base::RandDouble() <= possiblySend; | |
135 } | |
136 } | |
137 return false; | |
138 } | |
139 | |
103 void RecordSSLExpirationPageEventState(bool expired_but_previously_allowed, | 140 void RecordSSLExpirationPageEventState(bool expired_but_previously_allowed, |
104 bool proceed, | 141 bool proceed, |
105 bool overridable) { | 142 bool overridable) { |
106 SSLExpirationAndDecision event; | 143 SSLExpirationAndDecision event; |
107 if (expired_but_previously_allowed && proceed) | 144 if (expired_but_previously_allowed && proceed) |
108 event = EXPIRED_AND_PROCEED; | 145 event = EXPIRED_AND_PROCEED; |
109 else if (expired_but_previously_allowed && !proceed) | 146 else if (expired_but_previously_allowed && !proceed) |
110 event = EXPIRED_AND_DO_NOT_PROCEED; | 147 event = EXPIRED_AND_DO_NOT_PROCEED; |
111 else if (!expired_but_previously_allowed && proceed) | 148 else if (!expired_but_previously_allowed && proceed) |
112 event = NOT_EXPIRED_AND_PROCEED; | 149 event = NOT_EXPIRED_AND_PROCEED; |
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
448 ssl_info_.cert->GetPEMEncodedChain( | 485 ssl_info_.cert->GetPEMEncodedChain( |
449 &encoded_chain); | 486 &encoded_chain); |
450 load_time_data->SetString( | 487 load_time_data->SetString( |
451 "pem", JoinString(encoded_chain, std::string())); | 488 "pem", JoinString(encoded_chain, std::string())); |
452 | 489 |
453 PopulateExtendedReportingOption(load_time_data); | 490 PopulateExtendedReportingOption(load_time_data); |
454 } | 491 } |
455 | 492 |
456 void SSLBlockingPage::PopulateExtendedReportingOption( | 493 void SSLBlockingPage::PopulateExtendedReportingOption( |
457 base::DictionaryValue* load_time_data) { | 494 base::DictionaryValue* load_time_data) { |
458 // Only show the checkbox if not off-the-record and if the | 495 // Only show the checkbox if not off-the-record and if this client is |
459 // command-line option is set. | 496 // part of the respective Finch group. |
460 const bool show = !web_contents()->GetBrowserContext()->IsOffTheRecord() && | 497 const bool show = ShouldShowCertificateReporterCheckbox( |
461 base::CommandLine::ForCurrentProcess()->HasSwitch( | 498 web_contents()->GetBrowserContext()->IsOffTheRecord()); |
462 switches::kEnableInvalidCertCollection); | |
463 | 499 |
464 load_time_data->SetBoolean(interstitials::kDisplayCheckBox, show); | 500 load_time_data->SetBoolean(interstitials::kDisplayCheckBox, show); |
465 if (!show) | 501 if (!show) |
466 return; | 502 return; |
467 | 503 |
468 load_time_data->SetBoolean( | 504 load_time_data->SetBoolean( |
469 interstitials::kBoxChecked, | 505 interstitials::kBoxChecked, |
470 IsPrefEnabled(prefs::kSafeBrowsingExtendedReportingEnabled)); | 506 IsPrefEnabled(prefs::kSafeBrowsingExtendedReportingEnabled)); |
471 | 507 |
472 const std::string privacy_link = base::StringPrintf( | 508 const std::string privacy_link = base::StringPrintf( |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
638 else | 674 else |
639 event_name.append(kEventNotOverridable); | 675 event_name.append(kEventNotOverridable); |
640 event_name.append(net::ErrorToString(cert_error_)); | 676 event_name.append(net::ErrorToString(cert_error_)); |
641 return event_name; | 677 return event_name; |
642 } | 678 } |
643 | 679 |
644 void SSLBlockingPage::FinishCertCollection() { | 680 void SSLBlockingPage::FinishCertCollection() { |
645 base::ScopedClosureRunner scoped_callback( | 681 base::ScopedClosureRunner scoped_callback( |
646 certificate_report_callback_for_testing_); | 682 certificate_report_callback_for_testing_); |
647 | 683 |
648 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( | 684 if (!ShouldShowCertificateReporterCheckbox( |
649 switches::kEnableInvalidCertCollection) || | 685 web_contents()->GetBrowserContext()->IsOffTheRecord())) { |
650 web_contents()->GetBrowserContext()->IsOffTheRecord()) { | |
651 return; | 686 return; |
652 } | 687 } |
653 | 688 |
654 const bool enabled = | 689 const bool enabled = |
655 IsPrefEnabled(prefs::kSafeBrowsingExtendedReportingEnabled); | 690 IsPrefEnabled(prefs::kSafeBrowsingExtendedReportingEnabled); |
656 | 691 |
657 if (!enabled) | 692 if (!enabled) |
658 return; | 693 return; |
659 | 694 |
660 metrics_helper()->RecordUserInteraction( | 695 metrics_helper()->RecordUserInteraction( |
661 SecurityInterstitialMetricsHelper::EXTENDED_REPORTING_IS_ENABLED); | 696 SecurityInterstitialMetricsHelper::EXTENDED_REPORTING_IS_ENABLED); |
662 | 697 |
663 if (certificate_report_callback_for_testing_.is_null()) | 698 if (ShouldReportCertificateErrors( |
664 scoped_callback.Reset(base::Bind(&base::DoNothing)); | 699 web_contents()->GetBrowserContext()->IsOffTheRecord())) { |
665 | 700 if (certificate_report_callback_for_testing_.is_null()) |
666 safe_browsing_ui_manager_->ReportInvalidCertificateChain( | 701 scoped_callback.Reset(base::Bind(&base::DoNothing)); |
667 request_url().host(), ssl_info_, scoped_callback.Release()); | 702 safe_browsing_ui_manager_->ReportInvalidCertificateChain( |
703 request_url().host(), ssl_info_, scoped_callback.Release()); | |
704 } | |
668 } | 705 } |
669 | 706 |
670 // static | 707 // static |
671 bool SSLBlockingPage::IsOptionsOverridable(int options_mask) { | 708 bool SSLBlockingPage::IsOptionsOverridable(int options_mask) { |
672 return (options_mask & SSLBlockingPage::OVERRIDABLE) && | 709 return (options_mask & SSLBlockingPage::OVERRIDABLE) && |
673 !(options_mask & SSLBlockingPage::STRICT_ENFORCEMENT); | 710 !(options_mask & SSLBlockingPage::STRICT_ENFORCEMENT); |
674 } | 711 } |
OLD | NEW |