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

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

Issue 872813003: Add Rappor metrics for Safe Browsing and SSL interstitials. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Lowercase Rappor metrics, and add SSL metric. Created 5 years, 10 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/chrome_browser.gypi » ('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"
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 ssl_info_(ssl_info), 226 ssl_info_(ssl_info),
227 overridable_(IsOptionsOverridable(options_mask)), 227 overridable_(IsOptionsOverridable(options_mask)),
228 danger_overridable_(true), 228 danger_overridable_(true),
229 strict_enforcement_((options_mask & STRICT_ENFORCEMENT) != 0), 229 strict_enforcement_((options_mask & STRICT_ENFORCEMENT) != 0),
230 expired_but_previously_allowed_( 230 expired_but_previously_allowed_(
231 (options_mask & EXPIRED_BUT_PREVIOUSLY_ALLOWED) != 0) { 231 (options_mask & EXPIRED_BUT_PREVIOUSLY_ALLOWED) != 0) {
232 interstitial_reason_ = 232 interstitial_reason_ =
233 IsErrorDueToBadClock(base::Time::NowFromSystemTime(), cert_error_) ? 233 IsErrorDueToBadClock(base::Time::NowFromSystemTime(), cert_error_) ?
234 SSL_REASON_BAD_CLOCK : SSL_REASON_SSL; 234 SSL_REASON_BAD_CLOCK : SSL_REASON_SSL;
235 235
236 // We collapse the Rappor metric name to just "ssl" so we don't leak
237 // the "overridable" bit. We skip Rappor altogether for bad clocks.
236 // This must be done after calculating |interstitial_reason_| above. 238 // This must be done after calculating |interstitial_reason_| above.
237 uma_helper_.reset(new SecurityInterstitialUmaHelper( 239 const std::string rappor_prefix =
238 web_contents, request_url, GetHistogramPrefix(), GetSamplingEventName())); 240 (interstitial_reason_ == SSL_REASON_BAD_CLOCK ? "" : "ssl");
Alexei Svitkine (slow) 2015/02/02 20:31:25 Nit: "" -> std::string()
Nathan Parker 2015/02/02 21:51:18 Done.
239 uma_helper_->RecordUserDecision(SecurityInterstitialUmaHelper::SHOW); 241 metrics_helper_.reset(new SecurityInterstitialMetricsHelper(
240 uma_helper_->RecordUserInteraction( 242 web_contents, request_url, GetUmaHistogramPrefix(), rappor_prefix,
241 SecurityInterstitialUmaHelper::TOTAL_VISITS); 243 GetSamplingEventName()));
244 metrics_helper_->RecordUserDecision(SecurityInterstitialMetricsHelper::SHOW);
245 metrics_helper_->RecordUserInteraction(
246 SecurityInterstitialMetricsHelper::TOTAL_VISITS);
242 247
243 ssl_error_classification_.reset(new SSLErrorClassification( 248 ssl_error_classification_.reset(new SSLErrorClassification(
244 web_contents, 249 web_contents,
245 base::Time::NowFromSystemTime(), 250 base::Time::NowFromSystemTime(),
246 request_url, 251 request_url,
247 cert_error_, 252 cert_error_,
248 *ssl_info_.cert.get())); 253 *ssl_info_.cert.get()));
249 ssl_error_classification_->RecordUMAStatistics(overridable_); 254 ssl_error_classification_->RecordUMAStatistics(overridable_);
250 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION) 255 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION)
251 ssl_error_classification_->RecordCaptivePortalUMAStatistics(overridable_); 256 ssl_error_classification_->RecordCaptivePortalUMAStatistics(overridable_);
252 #endif 257 #endif
253 258
254 // Creating an interstitial without showing (e.g. from chrome://interstitials) 259 // Creating an interstitial without showing (e.g. from chrome://interstitials)
255 // it leaks memory, so don't create it here. 260 // it leaks memory, so don't create it here.
256 } 261 }
257 262
258 bool SSLBlockingPage::ShouldCreateNewNavigation() const { 263 bool SSLBlockingPage::ShouldCreateNewNavigation() const {
259 return true; 264 return true;
260 } 265 }
261 266
262 const void* SSLBlockingPage::GetTypeForTesting() const { 267 const void* SSLBlockingPage::GetTypeForTesting() const {
263 return SSLBlockingPage::kTypeForTesting; 268 return SSLBlockingPage::kTypeForTesting;
264 } 269 }
265 270
266 SSLBlockingPage::~SSLBlockingPage() { 271 SSLBlockingPage::~SSLBlockingPage() {
267 if (!callback_.is_null()) { 272 if (!callback_.is_null()) {
268 // The page is closed without the user having chosen what to do, default to 273 // The page is closed without the user having chosen what to do, default to
269 // deny. 274 // deny.
270 uma_helper_->RecordUserDecision( 275 metrics_helper_->RecordUserDecision(
271 SecurityInterstitialUmaHelper::DONT_PROCEED); 276 SecurityInterstitialMetricsHelper::DONT_PROCEED);
272 RecordSSLExpirationPageEventState( 277 RecordSSLExpirationPageEventState(
273 expired_but_previously_allowed_, false, overridable_); 278 expired_but_previously_allowed_, false, overridable_);
274 NotifyDenyCertificate(); 279 NotifyDenyCertificate();
275 } 280 }
276 } 281 }
277 282
278 void SSLBlockingPage::PopulateInterstitialStrings( 283 void SSLBlockingPage::PopulateInterstitialStrings(
279 base::DictionaryValue* load_time_data) { 284 base::DictionaryValue* load_time_data) {
280 CHECK(load_time_data); 285 CHECK(load_time_data);
281 base::string16 url(GetFormattedHostName()); 286 base::string16 url(GetFormattedHostName());
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
444 interstitial_page()->DontProceed(); 449 interstitial_page()->DontProceed();
445 break; 450 break;
446 } 451 }
447 case CMD_PROCEED: { 452 case CMD_PROCEED: {
448 if (danger_overridable_) { 453 if (danger_overridable_) {
449 interstitial_page()->Proceed(); 454 interstitial_page()->Proceed();
450 } 455 }
451 break; 456 break;
452 } 457 }
453 case CMD_MORE: { 458 case CMD_MORE: {
454 uma_helper_->RecordUserInteraction( 459 metrics_helper_->RecordUserInteraction(
455 SecurityInterstitialUmaHelper::SHOW_ADVANCED); 460 SecurityInterstitialMetricsHelper::SHOW_ADVANCED);
456 break; 461 break;
457 } 462 }
458 case CMD_RELOAD: { 463 case CMD_RELOAD: {
459 uma_helper_->RecordUserInteraction( 464 metrics_helper_->RecordUserInteraction(
460 SecurityInterstitialUmaHelper::RELOAD); 465 SecurityInterstitialMetricsHelper::RELOAD);
461 // The interstitial can't refresh itself. 466 // The interstitial can't refresh itself.
462 web_contents()->GetController().Reload(true); 467 web_contents()->GetController().Reload(true);
463 break; 468 break;
464 } 469 }
465 case CMD_HELP: { 470 case CMD_HELP: {
466 uma_helper_->RecordUserInteraction( 471 metrics_helper_->RecordUserInteraction(
467 SecurityInterstitialUmaHelper::SHOW_LEARN_MORE); 472 SecurityInterstitialMetricsHelper::SHOW_LEARN_MORE);
468 content::NavigationController::LoadURLParams help_page_params( 473 content::NavigationController::LoadURLParams help_page_params(
469 google_util::AppendGoogleLocaleParam( 474 google_util::AppendGoogleLocaleParam(
470 GURL(kHelpURL), g_browser_process->GetApplicationLocale())); 475 GURL(kHelpURL), g_browser_process->GetApplicationLocale()));
471 web_contents()->GetController().LoadURLWithParams(help_page_params); 476 web_contents()->GetController().LoadURLWithParams(help_page_params);
472 break; 477 break;
473 } 478 }
474 case CMD_CLOCK: { 479 case CMD_CLOCK: {
475 uma_helper_->RecordUserInteraction( 480 metrics_helper_->RecordUserInteraction(
476 SecurityInterstitialUmaHelper::OPEN_TIME_SETTINGS); 481 SecurityInterstitialMetricsHelper::OPEN_TIME_SETTINGS);
477 LaunchDateAndTimeSettings(); 482 LaunchDateAndTimeSettings();
478 break; 483 break;
479 } 484 }
480 default: { 485 default: {
481 NOTREACHED(); 486 NOTREACHED();
482 } 487 }
483 } 488 }
484 } 489 }
485 490
486 void SSLBlockingPage::OverrideRendererPrefs( 491 void SSLBlockingPage::OverrideRendererPrefs(
487 content::RendererPreferences* prefs) { 492 content::RendererPreferences* prefs) {
488 Profile* profile = Profile::FromBrowserContext( 493 Profile* profile = Profile::FromBrowserContext(
489 web_contents()->GetBrowserContext()); 494 web_contents()->GetBrowserContext());
490 renderer_preferences_util::UpdateFromSystemSettings( 495 renderer_preferences_util::UpdateFromSystemSettings(
491 prefs, profile, web_contents()); 496 prefs, profile, web_contents());
492 } 497 }
493 498
494 void SSLBlockingPage::OnProceed() { 499 void SSLBlockingPage::OnProceed() {
495 uma_helper_->RecordUserDecision(SecurityInterstitialUmaHelper::PROCEED); 500 metrics_helper_->RecordUserDecision(
501 SecurityInterstitialMetricsHelper::PROCEED);
496 RecordSSLExpirationPageEventState( 502 RecordSSLExpirationPageEventState(
497 expired_but_previously_allowed_, true, overridable_); 503 expired_but_previously_allowed_, true, overridable_);
498 // Accepting the certificate resumes the loading of the page. 504 // Accepting the certificate resumes the loading of the page.
499 NotifyAllowCertificate(); 505 NotifyAllowCertificate();
500 } 506 }
501 507
502 void SSLBlockingPage::OnDontProceed() { 508 void SSLBlockingPage::OnDontProceed() {
503 uma_helper_->RecordUserDecision(SecurityInterstitialUmaHelper::DONT_PROCEED); 509 metrics_helper_->RecordUserDecision(
510 SecurityInterstitialMetricsHelper::DONT_PROCEED);
504 RecordSSLExpirationPageEventState( 511 RecordSSLExpirationPageEventState(
505 expired_but_previously_allowed_, false, overridable_); 512 expired_but_previously_allowed_, false, overridable_);
506 NotifyDenyCertificate(); 513 NotifyDenyCertificate();
507 } 514 }
508 515
509 void SSLBlockingPage::NotifyDenyCertificate() { 516 void SSLBlockingPage::NotifyDenyCertificate() {
510 // It's possible that callback_ may not exist if the user clicks "Proceed" 517 // It's possible that callback_ may not exist if the user clicks "Proceed"
511 // followed by pressing the back button before the interstitial is hidden. 518 // followed by pressing the back button before the interstitial is hidden.
512 // In that case the certificate will still be treated as allowed. 519 // In that case the certificate will still be treated as allowed.
513 if (callback_.is_null()) 520 if (callback_.is_null())
514 return; 521 return;
515 522
516 callback_.Run(false); 523 callback_.Run(false);
517 callback_.Reset(); 524 callback_.Reset();
518 } 525 }
519 526
520 void SSLBlockingPage::NotifyAllowCertificate() { 527 void SSLBlockingPage::NotifyAllowCertificate() {
521 DCHECK(!callback_.is_null()); 528 DCHECK(!callback_.is_null());
522 529
523 callback_.Run(true); 530 callback_.Run(true);
524 callback_.Reset(); 531 callback_.Reset();
525 } 532 }
526 533
527 std::string SSLBlockingPage::GetHistogramPrefix() const { 534 std::string SSLBlockingPage::GetUmaHistogramPrefix() const {
528 switch (interstitial_reason_) { 535 switch (interstitial_reason_) {
529 case SSL_REASON_SSL: 536 case SSL_REASON_SSL:
530 if (overridable_) 537 if (overridable_)
531 return "ssl_overridable"; 538 return "ssl_overridable";
532 else 539 else
533 return "ssl_nonoverridable"; 540 return "ssl_nonoverridable";
534 case SSL_REASON_BAD_CLOCK: 541 case SSL_REASON_BAD_CLOCK:
535 return "bad_clock"; 542 return "bad_clock";
536 } 543 }
537 NOTREACHED(); 544 NOTREACHED();
538 return std::string(); 545 return std::string();
539 } 546 }
540 547
541 std::string SSLBlockingPage::GetSamplingEventName() const { 548 std::string SSLBlockingPage::GetSamplingEventName() const {
542 std::string event_name(kEventNameBase); 549 std::string event_name(kEventNameBase);
543 if (overridable_) 550 if (overridable_)
544 event_name.append(kEventOverridable); 551 event_name.append(kEventOverridable);
545 else 552 else
546 event_name.append(kEventNotOverridable); 553 event_name.append(kEventNotOverridable);
547 event_name.append(net::ErrorToString(cert_error_)); 554 event_name.append(net::ErrorToString(cert_error_));
548 return event_name; 555 return event_name;
549 } 556 }
550 557
551 // static 558 // static
552 bool SSLBlockingPage::IsOptionsOverridable(int options_mask) { 559 bool SSLBlockingPage::IsOptionsOverridable(int options_mask) {
553 return (options_mask & SSLBlockingPage::OVERRIDABLE) && 560 return (options_mask & SSLBlockingPage::OVERRIDABLE) &&
554 !(options_mask & SSLBlockingPage::STRICT_ENFORCEMENT); 561 !(options_mask & SSLBlockingPage::STRICT_ENFORCEMENT);
555 } 562 }
OLDNEW
« no previous file with comments | « chrome/browser/ssl/ssl_blocking_page.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698