Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(433)

Side by Side Diff: chrome/browser/ssl/ssl_blocking_page.cc

Issue 839183002: Remove redundancy in security interstitial UMA logic (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: ... Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/ssl/ssl_blocking_page.h ('k') | chrome/browser/ssl/ssl_error_classification.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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)
87 const char kEventNameBase[] = "ssl_interstitial_"; 77 const char kEventNameBase[] = "ssl_interstitial_";
88 const char kEventNotOverridable[] = "notoverridable_"; 78 const char kEventNotOverridable[] = "notoverridable_";
89 const char kEventOverridable[] = "overridable_"; 79 const char kEventOverridable[] = "overridable_";
90 #endif
91
92 // 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 80
124 // Events for UMA. Do not reorder or change! 81 // Events for UMA. Do not reorder or change!
125 enum SSLExpirationAndDecision { 82 enum SSLExpirationAndDecision {
126 EXPIRED_AND_PROCEED, 83 EXPIRED_AND_PROCEED,
127 EXPIRED_AND_DO_NOT_PROCEED, 84 EXPIRED_AND_DO_NOT_PROCEED,
128 NOT_EXPIRED_AND_PROCEED, 85 NOT_EXPIRED_AND_PROCEED,
129 NOT_EXPIRED_AND_DO_NOT_PROCEED, 86 NOT_EXPIRED_AND_DO_NOT_PROCEED,
130 END_OF_SSL_EXPIRATION_AND_DECISION, 87 END_OF_SSL_EXPIRATION_AND_DECISION,
131 }; 88 };
132 89
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, 90 void RecordSSLExpirationPageEventState(bool expired_but_previously_allowed,
140 bool proceed, 91 bool proceed,
141 bool overridable) { 92 bool overridable) {
142 SSLExpirationAndDecision event; 93 SSLExpirationAndDecision event;
143 if (expired_but_previously_allowed && proceed) 94 if (expired_but_previously_allowed && proceed)
144 event = EXPIRED_AND_PROCEED; 95 event = EXPIRED_AND_PROCEED;
145 else if (expired_but_previously_allowed && !proceed) 96 else if (expired_but_previously_allowed && !proceed)
146 event = EXPIRED_AND_DO_NOT_PROCEED; 97 event = EXPIRED_AND_DO_NOT_PROCEED;
147 else if (!expired_but_previously_allowed && proceed) 98 else if (!expired_but_previously_allowed && proceed)
148 event = NOT_EXPIRED_AND_PROCEED; 99 event = NOT_EXPIRED_AND_PROCEED;
149 else 100 else
150 event = NOT_EXPIRED_AND_DO_NOT_PROCEED; 101 event = NOT_EXPIRED_AND_DO_NOT_PROCEED;
151 102
152 if (overridable) { 103 if (overridable) {
153 UMA_HISTOGRAM_ENUMERATION( 104 UMA_HISTOGRAM_ENUMERATION(
154 "interstitial.ssl.expiration_and_decision.overridable", 105 "interstitial.ssl.expiration_and_decision.overridable",
155 event, 106 event,
156 END_OF_SSL_EXPIRATION_AND_DECISION); 107 END_OF_SSL_EXPIRATION_AND_DECISION);
157 } else { 108 } else {
158 UMA_HISTOGRAM_ENUMERATION( 109 UMA_HISTOGRAM_ENUMERATION(
159 "interstitial.ssl.expiration_and_decision.nonoverridable", 110 "interstitial.ssl.expiration_and_decision.nonoverridable",
160 event, 111 event,
161 END_OF_SSL_EXPIRATION_AND_DECISION); 112 END_OF_SSL_EXPIRATION_AND_DECISION);
162 } 113 }
163 } 114 }
164 115
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",
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() { 116 void LaunchDateAndTimeSettings() {
224 // The code for each OS is completely separate, in order to avoid bugs like 117 // The code for each OS is completely separate, in order to avoid bugs like
225 // https://crbug.com/430877 . 118 // https://crbug.com/430877 .
226 #if defined(OS_ANDROID) 119 #if defined(OS_ANDROID)
227 chrome::android::OpenDateAndTimeSettings(); 120 chrome::android::OpenDateAndTimeSettings();
228 121
229 #elif defined(OS_CHROMEOS) 122 #elif defined(OS_CHROMEOS)
230 std::string sub_page = std::string(chrome::kSearchSubPage) + "#" + 123 std::string sub_page = std::string(chrome::kSearchSubPage) + "#" +
231 l10n_util::GetStringUTF8(IDS_OPTIONS_SETTINGS_SECTION_TITLE_DATETIME); 124 l10n_util::GetStringUTF8(IDS_OPTIONS_SETTINGS_SECTION_TITLE_DATETIME);
232 chrome::ShowSettingsSubPageForProfile( 125 chrome::ShowSettingsSubPageForProfile(
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 const GURL& request_url, 220 const GURL& request_url,
328 int options_mask, 221 int options_mask,
329 const base::Callback<void(bool)>& callback) 222 const base::Callback<void(bool)>& callback)
330 : SecurityInterstitialPage(web_contents, request_url), 223 : SecurityInterstitialPage(web_contents, request_url),
331 callback_(callback), 224 callback_(callback),
332 cert_error_(cert_error), 225 cert_error_(cert_error),
333 ssl_info_(ssl_info), 226 ssl_info_(ssl_info),
334 overridable_(IsOptionsOverridable(options_mask)), 227 overridable_(IsOptionsOverridable(options_mask)),
335 danger_overridable_(true), 228 danger_overridable_(true),
336 strict_enforcement_((options_mask & STRICT_ENFORCEMENT) != 0), 229 strict_enforcement_((options_mask & STRICT_ENFORCEMENT) != 0),
337 internal_(false),
338 num_visits_(-1),
339 expired_but_previously_allowed_( 230 expired_but_previously_allowed_(
340 (options_mask & EXPIRED_BUT_PREVIOUSLY_ALLOWED) != 0) { 231 (options_mask & EXPIRED_BUT_PREVIOUSLY_ALLOWED) != 0) {
341 Profile* profile = Profile::FromBrowserContext( 232 interstitial_reason_ =
342 web_contents->GetBrowserContext()); 233 IsErrorDueToBadClock(base::Time::NowFromSystemTime(), cert_error_) ?
343 // For UMA stats. 234 SSL_REASON_BAD_CLOCK : SSL_REASON_SSL;
344 if (SSLErrorClassification::IsHostnameNonUniqueOrDotless( 235
345 request_url.HostNoBrackets())) 236 // This must be done after calculating |interstitial_reason_| above.
346 internal_ = true; 237 uma_helper_.reset(new SecurityInterstitialUmaHelper(
347 RecordSSLBlockingPageEventStats(SHOW_ALL); 238 web_contents, request_url, GetHistogramPrefix(), GetSamplingEventName()));
348 if (overridable_) { 239 uma_helper_->RecordUserDecision(SecurityInterstitialUmaHelper::SHOW);
349 RecordSSLBlockingPageEventStats(SHOW_OVERRIDABLE); 240 uma_helper_->RecordUserInteraction(
350 if (internal_) 241 SecurityInterstitialUmaHelper::TOTAL_VISITS);
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 242
363 ssl_error_classification_.reset(new SSLErrorClassification( 243 ssl_error_classification_.reset(new SSLErrorClassification(
364 web_contents, 244 web_contents,
365 base::Time::NowFromSystemTime(), 245 base::Time::NowFromSystemTime(),
366 request_url, 246 request_url,
367 cert_error_, 247 cert_error_,
368 *ssl_info_.cert.get())); 248 *ssl_info_.cert.get()));
369 ssl_error_classification_->RecordUMAStatistics(overridable_); 249 ssl_error_classification_->RecordUMAStatistics(overridable_);
370
371 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION) 250 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION)
372 ssl_error_classification_->RecordCaptivePortalUMAStatistics(overridable_); 251 ssl_error_classification_->RecordCaptivePortalUMAStatistics(overridable_);
373 #endif 252 #endif
374 253
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) 254 // Creating an interstitial without showing (e.g. from chrome://interstitials)
391 // it leaks memory, so don't create it here. 255 // it leaks memory, so don't create it here.
392 } 256 }
393 257
394 bool SSLBlockingPage::ShouldCreateNewNavigation() const { 258 bool SSLBlockingPage::ShouldCreateNewNavigation() const {
395 return true; 259 return true;
396 } 260 }
397 261
398 const void* SSLBlockingPage::GetTypeForTesting() const { 262 const void* SSLBlockingPage::GetTypeForTesting() const {
399 return SSLBlockingPage::kTypeForTesting; 263 return SSLBlockingPage::kTypeForTesting;
(...skipping 12 matching lines...) Expand all
412 case SSLErrorInfo::CERT_COMMON_NAME_INVALID: 276 case SSLErrorInfo::CERT_COMMON_NAME_INVALID:
413 ssl_error_classification_->InvalidCommonNameSeverityScore(); 277 ssl_error_classification_->InvalidCommonNameSeverityScore();
414 break; 278 break;
415 case SSLErrorInfo::CERT_AUTHORITY_INVALID: 279 case SSLErrorInfo::CERT_AUTHORITY_INVALID:
416 ssl_error_classification_->InvalidAuthoritySeverityScore(); 280 ssl_error_classification_->InvalidAuthoritySeverityScore();
417 break; 281 break;
418 default: 282 default:
419 break; 283 break;
420 } 284 }
421 if (!callback_.is_null()) { 285 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 286 // The page is closed without the user having chosen what to do, default to
429 // deny. 287 // deny.
288 uma_helper_->RecordUserDecision(
289 SecurityInterstitialUmaHelper::DONT_PROCEED);
290 RecordSSLExpirationPageEventState(
291 expired_but_previously_allowed_, false, overridable_);
430 NotifyDenyCertificate(); 292 NotifyDenyCertificate();
431 } 293 }
432 } 294 }
433 295
434 void SSLBlockingPage::PopulateInterstitialStrings( 296 void SSLBlockingPage::PopulateInterstitialStrings(
435 base::DictionaryValue* load_time_data) { 297 base::DictionaryValue* load_time_data) {
436 CHECK(load_time_data); 298 CHECK(load_time_data);
437 base::string16 url(GetFormattedHostName()); 299 base::string16 url(GetFormattedHostName());
438 // Shared values for both the overridable and non-overridable versions. 300 // Shared values for both the overridable and non-overridable versions.
439 load_time_data->SetString("type", "SSL"); 301 load_time_data->SetString("type", "SSL");
440 302
441 // Shared UI configuration for all SSL interstitials. 303 // Shared UI configuration for all SSL interstitials.
442 base::Time now = base::Time::NowFromSystemTime(); 304 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_)); 305 load_time_data->SetString("errorCode", net::ErrorToString(cert_error_));
446 load_time_data->SetString( 306 load_time_data->SetString(
447 "openDetails", 307 "openDetails",
448 l10n_util::GetStringUTF16(IDS_SSL_V2_OPEN_DETAILS_BUTTON)); 308 l10n_util::GetStringUTF16(IDS_SSL_V2_OPEN_DETAILS_BUTTON));
449 load_time_data->SetString( 309 load_time_data->SetString(
450 "closeDetails", 310 "closeDetails",
451 l10n_util::GetStringUTF16(IDS_SSL_V2_CLOSE_DETAILS_BUTTON)); 311 l10n_util::GetStringUTF16(IDS_SSL_V2_CLOSE_DETAILS_BUTTON));
452 312
453 // Conditional UI configuration. 313 // Conditional UI configuration.
454 if (bad_clock) { 314 if (interstitial_reason_ == SSL_REASON_BAD_CLOCK) {
455 RecordSSLBlockingPageEventStats(DISPLAYED_CLOCK_INTERSTITIAL);
456
457 load_time_data->SetBoolean("bad_clock", true); 315 load_time_data->SetBoolean("bad_clock", true);
458 load_time_data->SetBoolean("overridable", false); 316 load_time_data->SetBoolean("overridable", false);
459 317
460 #if defined(OS_IOS) 318 #if defined(OS_IOS)
461 load_time_data->SetBoolean("hide_primary_button", true); 319 load_time_data->SetBoolean("hide_primary_button", true);
462 #else 320 #else
463 load_time_data->SetBoolean("hide_primary_button", false); 321 load_time_data->SetBoolean("hide_primary_button", false);
464 #endif 322 #endif
465 323
466 // We're showing the SSL clock warning to be helpful, but we haven't warned 324 // 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
604 interstitial_page()->DontProceed(); 462 interstitial_page()->DontProceed();
605 break; 463 break;
606 } 464 }
607 case CMD_PROCEED: { 465 case CMD_PROCEED: {
608 if (danger_overridable_) { 466 if (danger_overridable_) {
609 interstitial_page()->Proceed(); 467 interstitial_page()->Proceed();
610 } 468 }
611 break; 469 break;
612 } 470 }
613 case CMD_MORE: { 471 case CMD_MORE: {
614 RecordSSLBlockingPageEventStats(MORE); 472 uma_helper_->RecordUserInteraction(
615 #if defined(ENABLE_EXTENSIONS) 473 SecurityInterstitialUmaHelper::SHOW_ADVANCED);
616 if (sampling_event_.get())
617 sampling_event_->set_has_viewed_details(true);
618 #endif
619 break; 474 break;
620 } 475 }
621 case CMD_RELOAD: { 476 case CMD_RELOAD: {
477 uma_helper_->RecordUserInteraction(
478 SecurityInterstitialUmaHelper::RELOAD);
622 // The interstitial can't refresh itself. 479 // The interstitial can't refresh itself.
623 web_contents()->GetController().Reload(true); 480 web_contents()->GetController().Reload(true);
624 break; 481 break;
625 } 482 }
626 case CMD_HELP: { 483 case CMD_HELP: {
484 uma_helper_->RecordUserInteraction(
485 SecurityInterstitialUmaHelper::SHOW_LEARN_MORE);
627 content::NavigationController::LoadURLParams help_page_params( 486 content::NavigationController::LoadURLParams help_page_params(
628 google_util::AppendGoogleLocaleParam( 487 google_util::AppendGoogleLocaleParam(
629 GURL(kHelpURL), g_browser_process->GetApplicationLocale())); 488 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); 489 web_contents()->GetController().LoadURLWithParams(help_page_params);
635 break; 490 break;
636 } 491 }
637 case CMD_CLOCK: { 492 case CMD_CLOCK: {
493 uma_helper_->RecordUserInteraction(
494 SecurityInterstitialUmaHelper::OPEN_TIME_SETTINGS);
638 LaunchDateAndTimeSettings(); 495 LaunchDateAndTimeSettings();
639 break; 496 break;
640 } 497 }
641 default: { 498 default: {
642 NOTREACHED(); 499 NOTREACHED();
643 } 500 }
644 } 501 }
645 } 502 }
646 503
647 void SSLBlockingPage::OverrideRendererPrefs( 504 void SSLBlockingPage::OverrideRendererPrefs(
648 content::RendererPreferences* prefs) { 505 content::RendererPreferences* prefs) {
649 Profile* profile = Profile::FromBrowserContext( 506 Profile* profile = Profile::FromBrowserContext(
650 web_contents()->GetBrowserContext()); 507 web_contents()->GetBrowserContext());
651 renderer_preferences_util::UpdateFromSystemSettings( 508 renderer_preferences_util::UpdateFromSystemSettings(
652 prefs, profile, web_contents()); 509 prefs, profile, web_contents());
653 } 510 }
654 511
655 void SSLBlockingPage::OnProceed() { 512 void SSLBlockingPage::OnProceed() {
656 RecordSSLBlockingPageDetailedStats(true, 513 uma_helper_->RecordUserDecision(SecurityInterstitialUmaHelper::PROCEED);
657 cert_error_, 514 RecordSSLExpirationPageEventState(
658 overridable_, 515 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. 516 // Accepting the certificate resumes the loading of the page.
669 NotifyAllowCertificate(); 517 NotifyAllowCertificate();
670 } 518 }
671 519
672 void SSLBlockingPage::OnDontProceed() { 520 void SSLBlockingPage::OnDontProceed() {
673 RecordSSLBlockingPageDetailedStats(false, 521 uma_helper_->RecordUserDecision(SecurityInterstitialUmaHelper::DONT_PROCEED);
674 cert_error_, 522 RecordSSLExpirationPageEventState(
675 overridable_, 523 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(); 524 NotifyDenyCertificate();
686 } 525 }
687 526
688 void SSLBlockingPage::NotifyDenyCertificate() { 527 void SSLBlockingPage::NotifyDenyCertificate() {
689 // It's possible that callback_ may not exist if the user clicks "Proceed" 528 // 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. 529 // followed by pressing the back button before the interstitial is hidden.
691 // In that case the certificate will still be treated as allowed. 530 // In that case the certificate will still be treated as allowed.
692 if (callback_.is_null()) 531 if (callback_.is_null())
693 return; 532 return;
694 533
695 callback_.Run(false); 534 callback_.Run(false);
696 callback_.Reset(); 535 callback_.Reset();
697 } 536 }
698 537
699 void SSLBlockingPage::NotifyAllowCertificate() { 538 void SSLBlockingPage::NotifyAllowCertificate() {
700 DCHECK(!callback_.is_null()); 539 DCHECK(!callback_.is_null());
701 540
702 callback_.Run(true); 541 callback_.Run(true);
703 callback_.Reset(); 542 callback_.Reset();
704 } 543 }
705 544
706 // static 545 std::string SSLBlockingPage::GetHistogramPrefix() const {
707 void SSLBlockingPage::SetExtraInfo( 546 switch (interstitial_reason_) {
708 base::DictionaryValue* strings, 547 case SSL_REASON_SSL:
709 const std::vector<base::string16>& extra_info) { 548 if (overridable_)
710 DCHECK_LT(extra_info.size(), 5U); // We allow 5 paragraphs max. 549 return "ssl_overridable";
711 const char* keys[5] = { 550 else
712 "moreInfo1", "moreInfo2", "moreInfo3", "moreInfo4", "moreInfo5" 551 return "ssl_nonoverridable";
713 }; 552 case SSL_REASON_BAD_CLOCK:
714 int i; 553 return "bad_clock";
715 for (i = 0; i < static_cast<int>(extra_info.size()); i++) {
716 strings->SetString(keys[i], extra_info[i]);
717 } 554 }
718 for (; i < 5; i++) { 555 NOTREACHED();
719 strings->SetString(keys[i], std::string()); 556 return std::string();
720 } 557 }
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 }
OLDNEW
« no previous file with comments | « chrome/browser/ssl/ssl_blocking_page.h ('k') | chrome/browser/ssl/ssl_error_classification.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698