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/build_time.h" | 7 #include "base/build_time.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/i18n/rtl.h" | 9 #include "base/i18n/rtl.h" |
10 #include "base/i18n/time_formatting.h" | 10 #include "base/i18n/time_formatting.h" |
11 #include "base/metrics/field_trial.h" | 11 #include "base/metrics/field_trial.h" |
12 #include "base/metrics/histogram.h" | 12 #include "base/metrics/histogram.h" |
13 #include "base/process/launch.h" | 13 #include "base/process/launch.h" |
14 #include "base/strings/string_number_conversions.h" | 14 #include "base/strings/string_number_conversions.h" |
15 #include "base/strings/string_piece.h" | 15 #include "base/strings/string_piece.h" |
16 #include "base/strings/string_util.h" | 16 #include "base/strings/string_util.h" |
17 #include "base/strings/stringprintf.h" | 17 #include "base/strings/stringprintf.h" |
18 #include "base/strings/utf_string_conversions.h" | 18 #include "base/strings/utf_string_conversions.h" |
19 #include "base/time/time.h" | 19 #include "base/time/time.h" |
20 #include "base/values.h" | 20 #include "base/values.h" |
21 #include "chrome/browser/browser_process.h" | 21 #include "chrome/browser/browser_process.h" |
22 #include "chrome/browser/chrome_notification_types.h" | 22 #include "chrome/browser/chrome_notification_types.h" |
23 #include "chrome/browser/history/history_service_factory.h" | |
24 #include "chrome/browser/profiles/profile.h" | 23 #include "chrome/browser/profiles/profile.h" |
25 #include "chrome/browser/renderer_preferences_util.h" | 24 #include "chrome/browser/renderer_preferences_util.h" |
26 #include "chrome/browser/ssl/ssl_error_classification.h" | 25 #include "chrome/browser/ssl/ssl_error_classification.h" |
27 #include "chrome/browser/ssl/ssl_error_info.h" | 26 #include "chrome/browser/ssl/ssl_error_info.h" |
28 #include "chrome/common/chrome_switches.h" | 27 #include "chrome/common/chrome_switches.h" |
29 #include "chrome/grit/chromium_strings.h" | 28 #include "chrome/grit/chromium_strings.h" |
30 #include "chrome/grit/generated_resources.h" | 29 #include "chrome/grit/generated_resources.h" |
31 #include "components/google/core/browser/google_util.h" | 30 #include "components/google/core/browser/google_util.h" |
32 #include "content/public/browser/cert_store.h" | 31 #include "content/public/browser/cert_store.h" |
33 #include "content/public/browser/interstitial_page.h" | 32 #include "content/public/browser/interstitial_page.h" |
34 #include "content/public/browser/navigation_controller.h" | 33 #include "content/public/browser/navigation_controller.h" |
35 #include "content/public/browser/navigation_entry.h" | 34 #include "content/public/browser/navigation_entry.h" |
36 #include "content/public/browser/notification_service.h" | 35 #include "content/public/browser/notification_service.h" |
37 #include "content/public/browser/notification_types.h" | 36 #include "content/public/browser/notification_types.h" |
38 #include "content/public/browser/render_process_host.h" | 37 #include "content/public/browser/render_process_host.h" |
39 #include "content/public/browser/render_view_host.h" | 38 #include "content/public/browser/render_view_host.h" |
40 #include "content/public/browser/web_contents.h" | 39 #include "content/public/browser/web_contents.h" |
41 #include "content/public/common/renderer_preferences.h" | 40 #include "content/public/common/renderer_preferences.h" |
42 #include "content/public/common/ssl_status.h" | 41 #include "content/public/common/ssl_status.h" |
43 #include "grit/browser_resources.h" | 42 #include "grit/browser_resources.h" |
44 #include "net/base/hash_value.h" | 43 #include "net/base/hash_value.h" |
45 #include "net/base/net_errors.h" | 44 #include "net/base/net_errors.h" |
46 #include "net/base/net_util.h" | 45 #include "net/base/net_util.h" |
47 #include "ui/base/l10n/l10n_util.h" | 46 #include "ui/base/l10n/l10n_util.h" |
48 | 47 |
49 #if defined(ENABLE_EXTENSIONS) | |
50 #include "chrome/browser/extensions/api/experience_sampling_private/experience_s ampling.h" | |
51 #endif | |
52 | |
53 #if defined(OS_WIN) | 48 #if defined(OS_WIN) |
54 #include "base/base_paths_win.h" | 49 #include "base/base_paths_win.h" |
55 #include "base/path_service.h" | 50 #include "base/path_service.h" |
56 #include "base/strings/string16.h" | 51 #include "base/strings/string16.h" |
57 #include "base/win/windows_version.h" | 52 #include "base/win/windows_version.h" |
58 #endif | 53 #endif |
59 | 54 |
60 #if defined(OS_ANDROID) | 55 #if defined(OS_ANDROID) |
61 #include "chrome/browser/android/intent_helper.h" | 56 #include "chrome/browser/android/intent_helper.h" |
62 #endif | 57 #endif |
63 | 58 |
64 #if defined(OS_CHROMEOS) | 59 #if defined(OS_CHROMEOS) |
65 #include "chrome/browser/profiles/profile_manager.h" | 60 #include "chrome/browser/profiles/profile_manager.h" |
66 #include "chrome/browser/ui/chrome_pages.h" | 61 #include "chrome/browser/ui/chrome_pages.h" |
67 #include "chrome/common/url_constants.h" | 62 #include "chrome/common/url_constants.h" |
68 #endif | 63 #endif |
69 | 64 |
70 using base::ASCIIToUTF16; | 65 using base::ASCIIToUTF16; |
71 using base::TimeTicks; | 66 using base::TimeTicks; |
72 using content::InterstitialPage; | 67 using content::InterstitialPage; |
73 using content::NavigationController; | 68 using content::NavigationController; |
74 using content::NavigationEntry; | 69 using content::NavigationEntry; |
75 | 70 |
76 #if defined(ENABLE_EXTENSIONS) | |
77 using extensions::ExperienceSamplingEvent; | |
78 #endif | |
79 | |
80 namespace { | 71 namespace { |
81 | 72 |
82 // URL for help page. | 73 // URL for help page. |
83 const char kHelpURL[] = "https://support.google.com/chrome/answer/4454607"; | 74 const char kHelpURL[] = "https://support.google.com/chrome/answer/4454607"; |
84 | 75 |
85 // Constants for the Experience Sampling instrumentation. | 76 // Constants for the Experience Sampling instrumentation. |
86 #if defined(ENABLE_EXTENSIONS) | 77 #if defined(ENABLE_EXTENSIONS) |
87 const char kEventNameBase[] = "ssl_interstitial_"; | 78 const char kEventNameBase[] = "ssl_interstitial_"; |
88 const char kEventNotOverridable[] = "notoverridable_"; | 79 const char kEventNotOverridable[] = "notoverridable_"; |
89 const char kEventOverridable[] = "overridable_"; | 80 const char kEventOverridable[] = "overridable_"; |
90 #endif | 81 #endif |
91 | 82 |
92 // Events for UMA. Do not reorder or change! | 83 // Events for UMA. Do not reorder or change! |
93 enum SSLBlockingPageEvent { | |
94 SHOW_ALL, | |
95 SHOW_OVERRIDABLE, | |
96 PROCEED_OVERRIDABLE, | |
97 PROCEED_NAME, | |
98 PROCEED_DATE, | |
99 PROCEED_AUTHORITY, | |
100 DONT_PROCEED_OVERRIDABLE, | |
101 DONT_PROCEED_NAME, | |
102 DONT_PROCEED_DATE, | |
103 DONT_PROCEED_AUTHORITY, | |
104 MORE, | |
105 SHOW_UNDERSTAND, // Used by the summer 2013 Finch trial. Deprecated. | |
106 SHOW_INTERNAL_HOSTNAME, | |
107 PROCEED_INTERNAL_HOSTNAME, | |
108 SHOW_NEW_SITE, | |
109 PROCEED_NEW_SITE, | |
110 PROCEED_MANUAL_NONOVERRIDABLE, | |
111 // Captive Portal errors moved to ssl_error_classification. | |
112 DEPRECATED_CAPTIVE_PORTAL_DETECTION_ENABLED, | |
113 DEPRECATED_CAPTIVE_PORTAL_DETECTION_ENABLED_OVERRIDABLE, | |
114 DEPRECATED_CAPTIVE_PORTAL_PROBE_COMPLETED, | |
115 DEPRECATED_CAPTIVE_PORTAL_PROBE_COMPLETED_OVERRIDABLE, | |
116 DEPRECATED_CAPTIVE_PORTAL_NO_RESPONSE, | |
117 DEPRECATED_CAPTIVE_PORTAL_NO_RESPONSE_OVERRIDABLE, | |
118 DEPRECATED_CAPTIVE_PORTAL_DETECTED, | |
119 DEPRECATED_CAPTIVE_PORTAL_DETECTED_OVERRIDABLE, | |
120 DISPLAYED_CLOCK_INTERSTITIAL, | |
121 UNUSED_BLOCKING_PAGE_EVENT, | |
122 }; | |
123 | |
124 // Events for UMA. Do not reorder or change! | |
125 enum SSLExpirationAndDecision { | 84 enum SSLExpirationAndDecision { |
126 EXPIRED_AND_PROCEED, | 85 EXPIRED_AND_PROCEED, |
127 EXPIRED_AND_DO_NOT_PROCEED, | 86 EXPIRED_AND_DO_NOT_PROCEED, |
128 NOT_EXPIRED_AND_PROCEED, | 87 NOT_EXPIRED_AND_PROCEED, |
129 NOT_EXPIRED_AND_DO_NOT_PROCEED, | 88 NOT_EXPIRED_AND_DO_NOT_PROCEED, |
130 END_OF_SSL_EXPIRATION_AND_DECISION, | 89 END_OF_SSL_EXPIRATION_AND_DECISION, |
131 }; | 90 }; |
132 | 91 |
133 void RecordSSLBlockingPageEventStats(SSLBlockingPageEvent event) { | |
134 UMA_HISTOGRAM_ENUMERATION("interstitial.ssl", | |
135 event, | |
136 UNUSED_BLOCKING_PAGE_EVENT); | |
137 } | |
138 | |
139 void RecordSSLExpirationPageEventState(bool expired_but_previously_allowed, | 92 void RecordSSLExpirationPageEventState(bool expired_but_previously_allowed, |
140 bool proceed, | 93 bool proceed, |
141 bool overridable) { | 94 bool overridable) { |
142 SSLExpirationAndDecision event; | 95 SSLExpirationAndDecision event; |
143 if (expired_but_previously_allowed && proceed) | 96 if (expired_but_previously_allowed && proceed) |
144 event = EXPIRED_AND_PROCEED; | 97 event = EXPIRED_AND_PROCEED; |
145 else if (expired_but_previously_allowed && !proceed) | 98 else if (expired_but_previously_allowed && !proceed) |
146 event = EXPIRED_AND_DO_NOT_PROCEED; | 99 event = EXPIRED_AND_DO_NOT_PROCEED; |
147 else if (!expired_but_previously_allowed && proceed) | 100 else if (!expired_but_previously_allowed && proceed) |
148 event = NOT_EXPIRED_AND_PROCEED; | 101 event = NOT_EXPIRED_AND_PROCEED; |
149 else | 102 else |
150 event = NOT_EXPIRED_AND_DO_NOT_PROCEED; | 103 event = NOT_EXPIRED_AND_DO_NOT_PROCEED; |
151 | 104 |
152 if (overridable) { | 105 if (overridable) { |
153 UMA_HISTOGRAM_ENUMERATION( | 106 UMA_HISTOGRAM_ENUMERATION( |
154 "interstitial.ssl.expiration_and_decision.overridable", | 107 "interstitial.ssl.expiration_and_decision.overridable", |
155 event, | 108 event, |
156 END_OF_SSL_EXPIRATION_AND_DECISION); | 109 END_OF_SSL_EXPIRATION_AND_DECISION); |
157 } else { | 110 } else { |
158 UMA_HISTOGRAM_ENUMERATION( | 111 UMA_HISTOGRAM_ENUMERATION( |
159 "interstitial.ssl.expiration_and_decision.nonoverridable", | 112 "interstitial.ssl.expiration_and_decision.nonoverridable", |
160 event, | 113 event, |
161 END_OF_SSL_EXPIRATION_AND_DECISION); | 114 END_OF_SSL_EXPIRATION_AND_DECISION); |
162 } | 115 } |
163 } | 116 } |
164 | 117 |
165 void RecordSSLBlockingPageDetailedStats(bool proceed, | |
166 int cert_error, | |
167 bool overridable, | |
168 bool internal, | |
169 int num_visits, | |
170 bool expired_but_previously_allowed) { | |
171 UMA_HISTOGRAM_ENUMERATION("interstitial.ssl_error_type", | |
mattm
2015/01/14 00:33:04
does this histogram need to be marked obsolete?
felt
2015/01/14 00:55:18
I'm moving it into SSLErrorClassification::RecordU
| |
172 SSLErrorInfo::NetErrorToErrorType(cert_error), SSLErrorInfo::END_OF_ENUM); | |
173 RecordSSLExpirationPageEventState( | |
174 expired_but_previously_allowed, proceed, overridable); | |
175 if (!overridable) { | |
176 if (proceed) { | |
177 RecordSSLBlockingPageEventStats(PROCEED_MANUAL_NONOVERRIDABLE); | |
178 } | |
179 // Overridable is false if the user didn't have any option except to turn | |
180 // back. If that's the case, don't record some of the metrics. | |
181 return; | |
182 } | |
183 if (num_visits == 0) | |
184 RecordSSLBlockingPageEventStats(SHOW_NEW_SITE); | |
185 if (proceed) { | |
186 RecordSSLBlockingPageEventStats(PROCEED_OVERRIDABLE); | |
187 if (internal) | |
188 RecordSSLBlockingPageEventStats(PROCEED_INTERNAL_HOSTNAME); | |
189 if (num_visits == 0) | |
190 RecordSSLBlockingPageEventStats(PROCEED_NEW_SITE); | |
191 } else if (!proceed) { | |
192 RecordSSLBlockingPageEventStats(DONT_PROCEED_OVERRIDABLE); | |
193 } | |
194 SSLErrorInfo::ErrorType type = SSLErrorInfo::NetErrorToErrorType(cert_error); | |
195 switch (type) { | |
196 case SSLErrorInfo::CERT_COMMON_NAME_INVALID: { | |
197 if (proceed) | |
198 RecordSSLBlockingPageEventStats(PROCEED_NAME); | |
199 else | |
200 RecordSSLBlockingPageEventStats(DONT_PROCEED_NAME); | |
201 break; | |
202 } | |
203 case SSLErrorInfo::CERT_DATE_INVALID: { | |
204 if (proceed) | |
205 RecordSSLBlockingPageEventStats(PROCEED_DATE); | |
206 else | |
207 RecordSSLBlockingPageEventStats(DONT_PROCEED_DATE); | |
208 break; | |
209 } | |
210 case SSLErrorInfo::CERT_AUTHORITY_INVALID: { | |
211 if (proceed) | |
212 RecordSSLBlockingPageEventStats(PROCEED_AUTHORITY); | |
213 else | |
214 RecordSSLBlockingPageEventStats(DONT_PROCEED_AUTHORITY); | |
215 break; | |
216 } | |
217 default: { | |
218 break; | |
219 } | |
220 } | |
221 } | |
222 | |
223 void LaunchDateAndTimeSettings() { | 118 void LaunchDateAndTimeSettings() { |
224 // The code for each OS is completely separate, in order to avoid bugs like | 119 // The code for each OS is completely separate, in order to avoid bugs like |
225 // https://crbug.com/430877 . | 120 // https://crbug.com/430877 . |
226 #if defined(OS_ANDROID) | 121 #if defined(OS_ANDROID) |
227 chrome::android::OpenDateAndTimeSettings(); | 122 chrome::android::OpenDateAndTimeSettings(); |
228 | 123 |
229 #elif defined(OS_CHROMEOS) | 124 #elif defined(OS_CHROMEOS) |
230 std::string sub_page = std::string(chrome::kSearchSubPage) + "#" + | 125 std::string sub_page = std::string(chrome::kSearchSubPage) + "#" + |
231 l10n_util::GetStringUTF8(IDS_OPTIONS_SETTINGS_SECTION_TITLE_DATETIME); | 126 l10n_util::GetStringUTF8(IDS_OPTIONS_SETTINGS_SECTION_TITLE_DATETIME); |
232 chrome::ShowSettingsSubPageForProfile( | 127 chrome::ShowSettingsSubPageForProfile( |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
327 const GURL& request_url, | 222 const GURL& request_url, |
328 int options_mask, | 223 int options_mask, |
329 const base::Callback<void(bool)>& callback) | 224 const base::Callback<void(bool)>& callback) |
330 : SecurityInterstitialPage(web_contents, request_url), | 225 : SecurityInterstitialPage(web_contents, request_url), |
331 callback_(callback), | 226 callback_(callback), |
332 cert_error_(cert_error), | 227 cert_error_(cert_error), |
333 ssl_info_(ssl_info), | 228 ssl_info_(ssl_info), |
334 overridable_(IsOptionsOverridable(options_mask)), | 229 overridable_(IsOptionsOverridable(options_mask)), |
335 danger_overridable_(true), | 230 danger_overridable_(true), |
336 strict_enforcement_((options_mask & STRICT_ENFORCEMENT) != 0), | 231 strict_enforcement_((options_mask & STRICT_ENFORCEMENT) != 0), |
337 internal_(false), | |
338 num_visits_(-1), | |
339 expired_but_previously_allowed_( | 232 expired_but_previously_allowed_( |
340 (options_mask & EXPIRED_BUT_PREVIOUSLY_ALLOWED) != 0) { | 233 (options_mask & EXPIRED_BUT_PREVIOUSLY_ALLOWED) != 0) { |
341 Profile* profile = Profile::FromBrowserContext( | 234 interstitial_reason_ = |
342 web_contents->GetBrowserContext()); | 235 IsErrorDueToBadClock(base::Time::NowFromSystemTime(), cert_error_) ? |
343 // For UMA stats. | 236 SSL_REASON_BAD_CLOCK : SSL_REASON_SSL; |
344 if (SSLErrorClassification::IsHostnameNonUniqueOrDotless( | 237 |
345 request_url.HostNoBrackets())) | 238 uma_helper_.reset(new SecurityInterstitialUmaHelper( |
346 internal_ = true; | 239 web_contents, request_url, GetHistogramPrefix(), GetSamplingEventName())); |
347 RecordSSLBlockingPageEventStats(SHOW_ALL); | 240 uma_helper_->RecordUserDecision(SecurityInterstitialUmaHelper::SHOW); |
348 if (overridable_) { | 241 uma_helper_->RecordUserInteraction( |
349 RecordSSLBlockingPageEventStats(SHOW_OVERRIDABLE); | 242 SecurityInterstitialUmaHelper::TOTAL_VISITS); |
350 if (internal_) | |
351 RecordSSLBlockingPageEventStats(SHOW_INTERNAL_HOSTNAME); | |
352 HistoryService* history_service = HistoryServiceFactory::GetForProfile( | |
353 profile, ServiceAccessType::EXPLICIT_ACCESS); | |
354 if (history_service) { | |
355 history_service->GetVisibleVisitCountToHost( | |
356 request_url, | |
357 base::Bind(&SSLBlockingPage::OnGotHistoryCount, | |
358 base::Unretained(this)), | |
359 &request_tracker_); | |
360 } | |
361 } | |
362 | 243 |
363 ssl_error_classification_.reset(new SSLErrorClassification( | 244 ssl_error_classification_.reset(new SSLErrorClassification( |
364 web_contents, | 245 web_contents, |
365 base::Time::NowFromSystemTime(), | 246 base::Time::NowFromSystemTime(), |
366 request_url, | 247 request_url, |
367 cert_error_, | 248 cert_error_, |
368 *ssl_info_.cert.get())); | 249 *ssl_info_.cert.get())); |
369 ssl_error_classification_->RecordUMAStatistics(overridable_); | 250 ssl_error_classification_->RecordUMAStatistics(overridable_); |
370 | |
371 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION) | 251 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION) |
372 ssl_error_classification_->RecordCaptivePortalUMAStatistics(overridable_); | 252 ssl_error_classification_->RecordCaptivePortalUMAStatistics(overridable_); |
373 #endif | 253 #endif |
374 | 254 |
375 #if defined(ENABLE_EXTENSIONS) | |
376 // ExperienceSampling: Set up new sampling event for this interstitial. | |
377 std::string event_name(kEventNameBase); | |
378 if (overridable_ && !strict_enforcement_) | |
379 event_name.append(kEventOverridable); | |
380 else | |
381 event_name.append(kEventNotOverridable); | |
382 event_name.append(net::ErrorToString(cert_error_)); | |
383 sampling_event_.reset(new ExperienceSamplingEvent( | |
384 event_name, | |
385 request_url, | |
386 web_contents->GetLastCommittedURL(), | |
387 web_contents->GetBrowserContext())); | |
388 #endif | |
389 | |
390 // Creating an interstitial without showing (e.g. from chrome://interstitials) | 255 // Creating an interstitial without showing (e.g. from chrome://interstitials) |
391 // it leaks memory, so don't create it here. | 256 // it leaks memory, so don't create it here. |
392 } | 257 } |
393 | 258 |
394 bool SSLBlockingPage::ShouldCreateNewNavigation() const { | 259 bool SSLBlockingPage::ShouldCreateNewNavigation() const { |
395 return true; | 260 return true; |
396 } | 261 } |
397 | 262 |
398 const void* SSLBlockingPage::GetTypeForTesting() const { | 263 const void* SSLBlockingPage::GetTypeForTesting() const { |
399 return SSLBlockingPage::kTypeForTesting; | 264 return SSLBlockingPage::kTypeForTesting; |
(...skipping 12 matching lines...) Expand all Loading... | |
412 case SSLErrorInfo::CERT_COMMON_NAME_INVALID: | 277 case SSLErrorInfo::CERT_COMMON_NAME_INVALID: |
413 ssl_error_classification_->InvalidCommonNameSeverityScore(); | 278 ssl_error_classification_->InvalidCommonNameSeverityScore(); |
414 break; | 279 break; |
415 case SSLErrorInfo::CERT_AUTHORITY_INVALID: | 280 case SSLErrorInfo::CERT_AUTHORITY_INVALID: |
416 ssl_error_classification_->InvalidAuthoritySeverityScore(); | 281 ssl_error_classification_->InvalidAuthoritySeverityScore(); |
417 break; | 282 break; |
418 default: | 283 default: |
419 break; | 284 break; |
420 } | 285 } |
421 if (!callback_.is_null()) { | 286 if (!callback_.is_null()) { |
422 RecordSSLBlockingPageDetailedStats(false, | |
423 cert_error_, | |
424 overridable_, | |
425 internal_, | |
426 num_visits_, | |
427 expired_but_previously_allowed_); | |
428 // The page is closed without the user having chosen what to do, default to | 287 // The page is closed without the user having chosen what to do, default to |
429 // deny. | 288 // deny. |
289 uma_helper_->RecordUserDecision( | |
290 SecurityInterstitialUmaHelper::DONT_PROCEED); | |
291 RecordSSLExpirationPageEventState( | |
292 expired_but_previously_allowed_, false, overridable_); | |
430 NotifyDenyCertificate(); | 293 NotifyDenyCertificate(); |
431 } | 294 } |
432 } | 295 } |
433 | 296 |
434 void SSLBlockingPage::PopulateInterstitialStrings( | 297 void SSLBlockingPage::PopulateInterstitialStrings( |
435 base::DictionaryValue* load_time_data) { | 298 base::DictionaryValue* load_time_data) { |
436 CHECK(load_time_data); | 299 CHECK(load_time_data); |
437 base::string16 url(GetFormattedHostName()); | 300 base::string16 url(GetFormattedHostName()); |
438 // Shared values for both the overridable and non-overridable versions. | 301 // Shared values for both the overridable and non-overridable versions. |
439 load_time_data->SetString("type", "SSL"); | 302 load_time_data->SetString("type", "SSL"); |
440 | 303 |
441 // Shared UI configuration for all SSL interstitials. | 304 // Shared UI configuration for all SSL interstitials. |
442 base::Time now = base::Time::NowFromSystemTime(); | 305 base::Time now = base::Time::NowFromSystemTime(); |
443 bool bad_clock = IsErrorDueToBadClock(now, cert_error_); | |
444 | |
445 load_time_data->SetString("errorCode", net::ErrorToString(cert_error_)); | 306 load_time_data->SetString("errorCode", net::ErrorToString(cert_error_)); |
446 load_time_data->SetString( | 307 load_time_data->SetString( |
447 "openDetails", | 308 "openDetails", |
448 l10n_util::GetStringUTF16(IDS_SSL_V2_OPEN_DETAILS_BUTTON)); | 309 l10n_util::GetStringUTF16(IDS_SSL_V2_OPEN_DETAILS_BUTTON)); |
449 load_time_data->SetString( | 310 load_time_data->SetString( |
450 "closeDetails", | 311 "closeDetails", |
451 l10n_util::GetStringUTF16(IDS_SSL_V2_CLOSE_DETAILS_BUTTON)); | 312 l10n_util::GetStringUTF16(IDS_SSL_V2_CLOSE_DETAILS_BUTTON)); |
452 | 313 |
453 // Conditional UI configuration. | 314 // Conditional UI configuration. |
454 if (bad_clock) { | 315 if (interstitial_reason_ == SSL_REASON_BAD_CLOCK) { |
455 RecordSSLBlockingPageEventStats(DISPLAYED_CLOCK_INTERSTITIAL); | |
456 | |
457 load_time_data->SetBoolean("bad_clock", true); | 316 load_time_data->SetBoolean("bad_clock", true); |
458 load_time_data->SetBoolean("overridable", false); | 317 load_time_data->SetBoolean("overridable", false); |
459 | 318 |
460 #if defined(OS_IOS) | 319 #if defined(OS_IOS) |
461 load_time_data->SetBoolean("hide_primary_button", true); | 320 load_time_data->SetBoolean("hide_primary_button", true); |
462 #else | 321 #else |
463 load_time_data->SetBoolean("hide_primary_button", false); | 322 load_time_data->SetBoolean("hide_primary_button", false); |
464 #endif | 323 #endif |
465 | 324 |
466 // We're showing the SSL clock warning to be helpful, but we haven't warned | 325 // We're showing the SSL clock warning to be helpful, but we haven't warned |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
604 interstitial_page()->DontProceed(); | 463 interstitial_page()->DontProceed(); |
605 break; | 464 break; |
606 } | 465 } |
607 case CMD_PROCEED: { | 466 case CMD_PROCEED: { |
608 if (danger_overridable_) { | 467 if (danger_overridable_) { |
609 interstitial_page()->Proceed(); | 468 interstitial_page()->Proceed(); |
610 } | 469 } |
611 break; | 470 break; |
612 } | 471 } |
613 case CMD_MORE: { | 472 case CMD_MORE: { |
614 RecordSSLBlockingPageEventStats(MORE); | 473 uma_helper_->RecordUserInteraction( |
615 #if defined(ENABLE_EXTENSIONS) | 474 SecurityInterstitialUmaHelper::SHOW_ADVANCED); |
616 if (sampling_event_.get()) | |
617 sampling_event_->set_has_viewed_details(true); | |
618 #endif | |
619 break; | 475 break; |
620 } | 476 } |
621 case CMD_RELOAD: { | 477 case CMD_RELOAD: { |
478 uma_helper_->RecordUserInteraction( | |
479 SecurityInterstitialUmaHelper::RELOAD); | |
622 // The interstitial can't refresh itself. | 480 // The interstitial can't refresh itself. |
623 web_contents()->GetController().Reload(true); | 481 web_contents()->GetController().Reload(true); |
624 break; | 482 break; |
625 } | 483 } |
626 case CMD_HELP: { | 484 case CMD_HELP: { |
485 uma_helper_->RecordUserInteraction( | |
486 SecurityInterstitialUmaHelper::SHOW_LEARN_MORE); | |
627 content::NavigationController::LoadURLParams help_page_params( | 487 content::NavigationController::LoadURLParams help_page_params( |
628 google_util::AppendGoogleLocaleParam( | 488 google_util::AppendGoogleLocaleParam( |
629 GURL(kHelpURL), g_browser_process->GetApplicationLocale())); | 489 GURL(kHelpURL), g_browser_process->GetApplicationLocale())); |
630 #if defined(ENABLE_EXTENSIONS) | |
631 if (sampling_event_.get()) | |
632 sampling_event_->set_has_viewed_learn_more(true); | |
633 #endif | |
634 web_contents()->GetController().LoadURLWithParams(help_page_params); | 490 web_contents()->GetController().LoadURLWithParams(help_page_params); |
635 break; | 491 break; |
636 } | 492 } |
637 case CMD_CLOCK: { | 493 case CMD_CLOCK: { |
494 uma_helper_->RecordUserInteraction( | |
495 SecurityInterstitialUmaHelper::OPEN_TIME_SETTINGS); | |
638 LaunchDateAndTimeSettings(); | 496 LaunchDateAndTimeSettings(); |
639 break; | 497 break; |
640 } | 498 } |
641 default: { | 499 default: { |
642 NOTREACHED(); | 500 NOTREACHED(); |
643 } | 501 } |
644 } | 502 } |
645 } | 503 } |
646 | 504 |
647 void SSLBlockingPage::OverrideRendererPrefs( | 505 void SSLBlockingPage::OverrideRendererPrefs( |
648 content::RendererPreferences* prefs) { | 506 content::RendererPreferences* prefs) { |
649 Profile* profile = Profile::FromBrowserContext( | 507 Profile* profile = Profile::FromBrowserContext( |
650 web_contents()->GetBrowserContext()); | 508 web_contents()->GetBrowserContext()); |
651 renderer_preferences_util::UpdateFromSystemSettings( | 509 renderer_preferences_util::UpdateFromSystemSettings( |
652 prefs, profile, web_contents()); | 510 prefs, profile, web_contents()); |
653 } | 511 } |
654 | 512 |
655 void SSLBlockingPage::OnProceed() { | 513 void SSLBlockingPage::OnProceed() { |
656 RecordSSLBlockingPageDetailedStats(true, | 514 uma_helper_->RecordUserDecision(SecurityInterstitialUmaHelper::PROCEED); |
657 cert_error_, | 515 RecordSSLExpirationPageEventState( |
658 overridable_, | 516 expired_but_previously_allowed_, true, overridable_); |
659 internal_, | |
660 num_visits_, | |
661 expired_but_previously_allowed_); | |
662 #if defined(ENABLE_EXTENSIONS) | |
663 // ExperienceSampling: Notify that user decided to proceed. | |
664 if (sampling_event_.get()) | |
665 sampling_event_->CreateUserDecisionEvent(ExperienceSamplingEvent::kProceed); | |
666 #endif | |
667 | |
668 // Accepting the certificate resumes the loading of the page. | 517 // Accepting the certificate resumes the loading of the page. |
669 NotifyAllowCertificate(); | 518 NotifyAllowCertificate(); |
670 } | 519 } |
671 | 520 |
672 void SSLBlockingPage::OnDontProceed() { | 521 void SSLBlockingPage::OnDontProceed() { |
673 RecordSSLBlockingPageDetailedStats(false, | 522 uma_helper_->RecordUserDecision(SecurityInterstitialUmaHelper::DONT_PROCEED); |
674 cert_error_, | 523 RecordSSLExpirationPageEventState( |
675 overridable_, | 524 expired_but_previously_allowed_, false, overridable_); |
676 internal_, | |
677 num_visits_, | |
678 expired_but_previously_allowed_); | |
679 #if defined(ENABLE_EXTENSIONS) | |
680 // ExperienceSampling: Notify that user decided to not proceed. | |
681 // This also occurs if the user navigates away or closes the tab. | |
682 if (sampling_event_.get()) | |
683 sampling_event_->CreateUserDecisionEvent(ExperienceSamplingEvent::kDeny); | |
684 #endif | |
685 NotifyDenyCertificate(); | 525 NotifyDenyCertificate(); |
686 } | 526 } |
687 | 527 |
688 void SSLBlockingPage::NotifyDenyCertificate() { | 528 void SSLBlockingPage::NotifyDenyCertificate() { |
689 // It's possible that callback_ may not exist if the user clicks "Proceed" | 529 // It's possible that callback_ may not exist if the user clicks "Proceed" |
690 // followed by pressing the back button before the interstitial is hidden. | 530 // followed by pressing the back button before the interstitial is hidden. |
691 // In that case the certificate will still be treated as allowed. | 531 // In that case the certificate will still be treated as allowed. |
692 if (callback_.is_null()) | 532 if (callback_.is_null()) |
693 return; | 533 return; |
694 | 534 |
695 callback_.Run(false); | 535 callback_.Run(false); |
696 callback_.Reset(); | 536 callback_.Reset(); |
697 } | 537 } |
698 | 538 |
699 void SSLBlockingPage::NotifyAllowCertificate() { | 539 void SSLBlockingPage::NotifyAllowCertificate() { |
700 DCHECK(!callback_.is_null()); | 540 DCHECK(!callback_.is_null()); |
701 | 541 |
702 callback_.Run(true); | 542 callback_.Run(true); |
703 callback_.Reset(); | 543 callback_.Reset(); |
704 } | 544 } |
705 | 545 |
706 // static | 546 std::string SSLBlockingPage::GetHistogramPrefix() const { |
707 void SSLBlockingPage::SetExtraInfo( | 547 switch (interstitial_reason_) { |
708 base::DictionaryValue* strings, | 548 case SSL_REASON_SSL: |
709 const std::vector<base::string16>& extra_info) { | 549 if (overridable_) |
710 DCHECK_LT(extra_info.size(), 5U); // We allow 5 paragraphs max. | 550 return "ssl_overridable"; |
711 const char* keys[5] = { | 551 else |
712 "moreInfo1", "moreInfo2", "moreInfo3", "moreInfo4", "moreInfo5" | 552 return "ssl_nonoverridable"; |
mattm
2015/01/14 00:33:04
Is there a reason for the difference here vs how t
felt
2015/01/14 00:55:18
ssl_overridable and ssl_nonoverridable are differe
| |
713 }; | 553 case SSL_REASON_BAD_CLOCK: |
714 int i; | 554 return "bad_clock"; |
715 for (i = 0; i < static_cast<int>(extra_info.size()); i++) { | |
716 strings->SetString(keys[i], extra_info[i]); | |
717 } | 555 } |
718 for (; i < 5; i++) { | 556 NOTREACHED(); |
719 strings->SetString(keys[i], std::string()); | 557 } |
720 } | 558 |
559 std::string SSLBlockingPage::GetSamplingEventName() const { | |
560 std::string event_name(kEventNameBase); | |
561 if (overridable_) | |
562 event_name.append(kEventOverridable); | |
563 else | |
564 event_name.append(kEventNotOverridable); | |
565 event_name.append(net::ErrorToString(cert_error_)); | |
566 return event_name; | |
721 } | 567 } |
722 | 568 |
723 // static | 569 // static |
724 bool SSLBlockingPage::IsOptionsOverridable(int options_mask) { | 570 bool SSLBlockingPage::IsOptionsOverridable(int options_mask) { |
725 return (options_mask & SSLBlockingPage::OVERRIDABLE) && | 571 return (options_mask & SSLBlockingPage::OVERRIDABLE) && |
726 !(options_mask & SSLBlockingPage::STRICT_ENFORCEMENT); | 572 !(options_mask & SSLBlockingPage::STRICT_ENFORCEMENT); |
727 } | 573 } |
728 | |
729 void SSLBlockingPage::OnGotHistoryCount(bool success, | |
730 int num_visits, | |
731 base::Time first_visit) { | |
732 num_visits_ = num_visits; | |
733 } | |
OLD | NEW |