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

Side by Side Diff: chrome/browser/safe_browsing/safe_browsing_blocking_page.cc

Issue 576653002: Update the Safe Browsing interstitial histograms (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Histograms.xml Created 6 years, 3 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
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 // Implementation of the SafeBrowsingBlockingPage class. 5 // Implementation of the SafeBrowsingBlockingPage class.
6 6
7 #include "chrome/browser/safe_browsing/safe_browsing_blocking_page.h" 7 #include "chrome/browser/safe_browsing/safe_browsing_blocking_page.h"
8 8
9 #include <string> 9 #include <string>
10 10
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 const char kEventNameMalware[] = "safebrowsing_interstitial_"; 116 const char kEventNameMalware[] = "safebrowsing_interstitial_";
117 const char kEventNamePhishing[] = "phishing_interstitial_"; 117 const char kEventNamePhishing[] = "phishing_interstitial_";
118 const char kEventNameMalwareAndPhishing[] = 118 const char kEventNameMalwareAndPhishing[] =
119 "malware_and_phishing_interstitial_"; 119 "malware_and_phishing_interstitial_";
120 const char kEventNameOther[] = "safebrowsing_other_interstitial_"; 120 const char kEventNameOther[] = "safebrowsing_other_interstitial_";
121 #endif 121 #endif
122 122
123 base::LazyInstance<SafeBrowsingBlockingPage::UnsafeResourceMap> 123 base::LazyInstance<SafeBrowsingBlockingPage::UnsafeResourceMap>
124 g_unsafe_resource_map = LAZY_INSTANCE_INITIALIZER; 124 g_unsafe_resource_map = LAZY_INSTANCE_INITIALIZER;
125 125
126 // This enum is used for a histogram. Don't reorder, delete, or insert
127 // elements. New elements should be added before MAX_ACTION only.
128 enum DetailedDecision {
129 MALWARE_SHOW_NEW_SITE = 0,
130 MALWARE_PROCEED_NEW_SITE,
131 MALWARE_SHOW_CROSS_SITE,
132 MALWARE_PROCEED_CROSS_SITE,
133 PHISHING_SHOW_NEW_SITE,
134 PHISHING_PROCEED_NEW_SITE,
135 PHISHING_SHOW_CROSS_SITE,
136 PHISHING_PROCEED_CROSS_SITE,
137 MAX_DETAILED_ACTION
138 };
139
140 void RecordDetailedUserAction(DetailedDecision decision) {
141 UMA_HISTOGRAM_ENUMERATION("SB2.InterstitialActionDetails",
142 decision,
143 MAX_DETAILED_ACTION);
144 }
145
146 } // namespace 126 } // namespace
147 127
148 // static 128 // static
149 SafeBrowsingBlockingPageFactory* SafeBrowsingBlockingPage::factory_ = NULL; 129 SafeBrowsingBlockingPageFactory* SafeBrowsingBlockingPage::factory_ = NULL;
150 130
151 // The default SafeBrowsingBlockingPageFactory. Global, made a singleton so we 131 // The default SafeBrowsingBlockingPageFactory. Global, made a singleton so we
152 // don't leak it. 132 // don't leak it.
153 class SafeBrowsingBlockingPageFactoryImpl 133 class SafeBrowsingBlockingPageFactoryImpl
154 : public SafeBrowsingBlockingPageFactory { 134 : public SafeBrowsingBlockingPageFactory {
155 public: 135 public:
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 } 187 }
208 } 188 }
209 DCHECK(phishing || malware); 189 DCHECK(phishing || malware);
210 if (malware && phishing) 190 if (malware && phishing)
211 interstitial_type_ = TYPE_MALWARE_AND_PHISHING; 191 interstitial_type_ = TYPE_MALWARE_AND_PHISHING;
212 else if (malware) 192 else if (malware)
213 interstitial_type_ = TYPE_MALWARE; 193 interstitial_type_ = TYPE_MALWARE;
214 else 194 else
215 interstitial_type_ = TYPE_PHISHING; 195 interstitial_type_ = TYPE_PHISHING;
216 196
217 RecordUserAction(SHOW); 197 RecordUserDecision(SHOW);
198 if (IsPrefEnabled(prefs::kSafeBrowsingProceedAnywayDisabled))
199 RecordUserDecision(PROCEEDING_DISABLED);
200
218 HistoryService* history_service = HistoryServiceFactory::GetForProfile( 201 HistoryService* history_service = HistoryServiceFactory::GetForProfile(
219 Profile::FromBrowserContext(web_contents->GetBrowserContext()), 202 Profile::FromBrowserContext(web_contents->GetBrowserContext()),
220 Profile::EXPLICIT_ACCESS); 203 Profile::EXPLICIT_ACCESS);
221 if (history_service) { 204 if (history_service) {
222 history_service->GetVisibleVisitCountToHost( 205 history_service->GetVisibleVisitCountToHost(
223 url_, 206 url_,
224 base::Bind(&SafeBrowsingBlockingPage::OnGotHistoryCount, 207 base::Bind(&SafeBrowsingBlockingPage::OnGotHistoryCount,
225 base::Unretained(this)), 208 base::Unretained(this)),
226 &request_tracker_); 209 &request_tracker_);
227 } 210 }
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 return; 277 return;
295 } 278 }
296 279
297 if (command == kDontReportCommand) { 280 if (command == kDontReportCommand) {
298 SetReportingPreference(false); 281 SetReportingPreference(false);
299 return; 282 return;
300 } 283 }
301 284
302 if (command == kLearnMoreCommand) { 285 if (command == kLearnMoreCommand) {
303 // User pressed "Learn more". 286 // User pressed "Learn more".
304 #if defined(ENABLE_EXTENSIONS) 287 RecordUserInteraction(SHOW_LEARN_MORE);
305 if (sampling_event_.get())
306 sampling_event_->set_has_viewed_learn_more(true);
307 #endif
308 GURL learn_more_url(interstitial_type_ == TYPE_PHISHING ? 288 GURL learn_more_url(interstitial_type_ == TYPE_PHISHING ?
309 kLearnMorePhishingUrlV2 : kLearnMoreMalwareUrlV2); 289 kLearnMorePhishingUrlV2 : kLearnMoreMalwareUrlV2);
310 learn_more_url = google_util::AppendGoogleLocaleParam( 290 learn_more_url = google_util::AppendGoogleLocaleParam(
311 learn_more_url, g_browser_process->GetApplicationLocale()); 291 learn_more_url, g_browser_process->GetApplicationLocale());
312 OpenURLParams params(learn_more_url, 292 OpenURLParams params(learn_more_url,
313 Referrer(), 293 Referrer(),
314 CURRENT_TAB, 294 CURRENT_TAB,
315 content::PAGE_TRANSITION_LINK, 295 content::PAGE_TRANSITION_LINK,
316 false); 296 false);
317 web_contents_->OpenURL(params); 297 web_contents_->OpenURL(params);
318 return; 298 return;
319 } 299 }
320 300
321 if (command == kShowPrivacyCommand) { 301 if (command == kShowPrivacyCommand) {
322 // User pressed "Safe Browsing privacy policy". 302 // User pressed "Safe Browsing privacy policy".
303 RecordUserInteraction(SHOW_PRIVACY_POLICY);
323 GURL privacy_url( 304 GURL privacy_url(
324 l10n_util::GetStringUTF8(IDS_SAFE_BROWSING_PRIVACY_POLICY_URL)); 305 l10n_util::GetStringUTF8(IDS_SAFE_BROWSING_PRIVACY_POLICY_URL));
325 privacy_url = google_util::AppendGoogleLocaleParam( 306 privacy_url = google_util::AppendGoogleLocaleParam(
326 privacy_url, g_browser_process->GetApplicationLocale()); 307 privacy_url, g_browser_process->GetApplicationLocale());
327 OpenURLParams params(privacy_url, 308 OpenURLParams params(privacy_url,
328 Referrer(), 309 Referrer(),
329 CURRENT_TAB, 310 CURRENT_TAB,
330 content::PAGE_TRANSITION_LINK, 311 content::PAGE_TRANSITION_LINK,
331 false); 312 false);
332 web_contents_->OpenURL(params); 313 web_contents_->OpenURL(params);
333 return; 314 return;
334 } 315 }
335 316
336 bool proceed_blocked = false; 317 bool proceed_blocked = false;
337 if (command == kProceedCommand) { 318 if (command == kProceedCommand) {
338 if (IsPrefEnabled(prefs::kSafeBrowsingProceedAnywayDisabled)) { 319 if (IsPrefEnabled(prefs::kSafeBrowsingProceedAnywayDisabled)) {
339 proceed_blocked = true; 320 proceed_blocked = true;
340 } else { 321 } else {
322 RecordUserDecision(PROCEED);
341 interstitial_page_->Proceed(); 323 interstitial_page_->Proceed();
342 // |this| has been deleted after Proceed() returns. 324 // |this| has been deleted after Proceed() returns.
343 return; 325 return;
344 } 326 }
345 } 327 }
346 328
347 if (command == kTakeMeBackCommand || proceed_blocked) { 329 if (command == kTakeMeBackCommand || proceed_blocked) {
330 if (!proceed_blocked)
331 RecordUserDecision(DONT_PROCEED);
mattm 2014/09/16 07:48:20 I still don't think this will be recorded if the u
felt 2014/09/16 15:03:32 Oh, hmm, good point. Fixed.
348 if (is_main_frame_load_blocked_) { 332 if (is_main_frame_load_blocked_) {
349 // If the load is blocked, we want to close the interstitial and discard 333 // If the load is blocked, we want to close the interstitial and discard
350 // the pending entry. 334 // the pending entry.
351 interstitial_page_->DontProceed(); 335 interstitial_page_->DontProceed();
352 // |this| has been deleted after DontProceed() returns. 336 // |this| has been deleted after DontProceed() returns.
353 return; 337 return;
354 } 338 }
355 339
356 // Otherwise the offending entry has committed, and we need to go back or 340 // Otherwise the offending entry has committed, and we need to go back or
357 // to a safe page. We will close the interstitial when that page commits. 341 // to a safe page. We will close the interstitial when that page commits.
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 threat_type == SB_THREAT_TYPE_CLIENT_SIDE_PHISHING_URL); 387 threat_type == SB_THREAT_TYPE_CLIENT_SIDE_PHISHING_URL);
404 OpenURLParams params( 388 OpenURLParams params(
405 report_url, Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_LINK, 389 report_url, Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_LINK,
406 false); 390 false);
407 web_contents_->OpenURL(params); 391 web_contents_->OpenURL(params);
408 return; 392 return;
409 } 393 }
410 394
411 if (command == kShowDiagnosticCommand) { 395 if (command == kShowDiagnosticCommand) {
412 // We're going to take the user to Google's SafeBrowsing diagnostic page. 396 // We're going to take the user to Google's SafeBrowsing diagnostic page.
397 RecordUserInteraction(SHOW_DIAGNOSTIC);
413 std::string diagnostic = 398 std::string diagnostic =
414 base::StringPrintf(kSbDiagnosticUrl, 399 base::StringPrintf(kSbDiagnosticUrl,
415 net::EscapeQueryParamValue(bad_url_spec, true).c_str()); 400 net::EscapeQueryParamValue(bad_url_spec, true).c_str());
416 GURL diagnostic_url(diagnostic); 401 GURL diagnostic_url(diagnostic);
417 diagnostic_url = google_util::AppendGoogleLocaleParam( 402 diagnostic_url = google_util::AppendGoogleLocaleParam(
418 diagnostic_url, g_browser_process->GetApplicationLocale()); 403 diagnostic_url, g_browser_process->GetApplicationLocale());
419 DCHECK(unsafe_resources_[element_index].threat_type == 404 DCHECK(unsafe_resources_[element_index].threat_type ==
420 SB_THREAT_TYPE_URL_MALWARE || 405 SB_THREAT_TYPE_URL_MALWARE ||
421 unsafe_resources_[element_index].threat_type == 406 unsafe_resources_[element_index].threat_type ==
422 SB_THREAT_TYPE_CLIENT_SIDE_MALWARE_URL); 407 SB_THREAT_TYPE_CLIENT_SIDE_MALWARE_URL);
423 OpenURLParams params( 408 OpenURLParams params(
424 diagnostic_url, Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_LINK, 409 diagnostic_url, Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_LINK,
425 false); 410 false);
426 web_contents_->OpenURL(params); 411 web_contents_->OpenURL(params);
427 return; 412 return;
428 } 413 }
429 414
430 if (command == kExpandedSeeMoreCommand) { 415 if (command == kExpandedSeeMoreCommand) {
431 // User expanded the "see more info" section of the page. We don't actually 416 RecordUserInteraction(SHOW_ADVANCED);
432 // do any action based on this, it's just so that RecordUserReactionTime can
433 // track it.
434
435 #if defined(ENABLE_EXTENSIONS)
436 // ExperienceSampling: We track that the user expanded the details.
437 if (sampling_event_.get())
438 sampling_event_->set_has_viewed_details(true);
439 #endif
440 return; 417 return;
441 } 418 }
442 419
443 NOTREACHED() << "Unexpected command: " << command; 420 NOTREACHED() << "Unexpected command: " << command;
444 } 421 }
445 422
446 void SafeBrowsingBlockingPage::OverrideRendererPrefs( 423 void SafeBrowsingBlockingPage::OverrideRendererPrefs(
447 content::RendererPreferences* prefs) { 424 content::RendererPreferences* prefs) {
448 Profile* profile = Profile::FromBrowserContext( 425 Profile* profile = Profile::FromBrowserContext(
449 web_contents_->GetBrowserContext()); 426 web_contents_->GetBrowserContext());
450 renderer_preferences_util::UpdateFromSystemSettings(prefs, profile); 427 renderer_preferences_util::UpdateFromSystemSettings(prefs, profile);
451 } 428 }
452 429
453 void SafeBrowsingBlockingPage::SetReportingPreference(bool report) { 430 void SafeBrowsingBlockingPage::SetReportingPreference(bool report) {
454 Profile* profile = Profile::FromBrowserContext( 431 Profile* profile = Profile::FromBrowserContext(
455 web_contents_->GetBrowserContext()); 432 web_contents_->GetBrowserContext());
456 PrefService* pref = profile->GetPrefs(); 433 PrefService* pref = profile->GetPrefs();
457 pref->SetBoolean(prefs::kSafeBrowsingExtendedReportingEnabled, report); 434 pref->SetBoolean(prefs::kSafeBrowsingExtendedReportingEnabled, report);
458 UMA_HISTOGRAM_BOOLEAN("SB2.SetExtendedReportingEnabled", report); 435 UMA_HISTOGRAM_BOOLEAN("SB2.SetExtendedReportingEnabled", report);
459 } 436 }
460 437
461 void SafeBrowsingBlockingPage::OnProceed() { 438 void SafeBrowsingBlockingPage::OnProceed() {
462 proceeded_ = true; 439 proceeded_ = true;
463 RecordUserAction(PROCEED);
464 // Send the malware details, if we opted to. 440 // Send the malware details, if we opted to.
465 FinishMalwareDetails(malware_details_proceed_delay_ms_); 441 FinishMalwareDetails(malware_details_proceed_delay_ms_);
466 442
467 NotifySafeBrowsingUIManager(ui_manager_, unsafe_resources_, true); 443 NotifySafeBrowsingUIManager(ui_manager_, unsafe_resources_, true);
468 444
469 // Check to see if some new notifications of unsafe resources have been 445 // Check to see if some new notifications of unsafe resources have been
470 // received while we were showing the interstitial. 446 // received while we were showing the interstitial.
471 UnsafeResourceMap* unsafe_resource_map = GetUnsafeResourcesMap(); 447 UnsafeResourceMap* unsafe_resource_map = GetUnsafeResourcesMap();
472 UnsafeResourceMap::iterator iter = unsafe_resource_map->find(web_contents_); 448 UnsafeResourceMap::iterator iter = unsafe_resource_map->find(web_contents_);
473 SafeBrowsingBlockingPage* blocking_page = NULL; 449 SafeBrowsingBlockingPage* blocking_page = NULL;
474 if (iter != unsafe_resource_map->end() && !iter->second.empty()) { 450 if (iter != unsafe_resource_map->end() && !iter->second.empty()) {
475 // Build an interstitial for all the unsafe resources notifications. 451 // Build an interstitial for all the unsafe resources notifications.
476 // Don't show it now as showing an interstitial while an interstitial is 452 // Don't show it now as showing an interstitial while an interstitial is
477 // already showing would cause DontProceed() to be invoked. 453 // already showing would cause DontProceed() to be invoked.
478 blocking_page = factory_->CreateSafeBrowsingPage(ui_manager_, web_contents_, 454 blocking_page = factory_->CreateSafeBrowsingPage(ui_manager_, web_contents_,
479 iter->second); 455 iter->second);
480 unsafe_resource_map->erase(iter); 456 unsafe_resource_map->erase(iter);
481 } 457 }
482 458
483 #if defined(ENABLE_EXTENSIONS)
484 // ExperienceSampling: Notify that user decided to proceed.
485 if (sampling_event_.get())
486 sampling_event_->CreateUserDecisionEvent(ExperienceSamplingEvent::kProceed);
487 #endif
488
489 // Now that this interstitial is gone, we can show the new one. 459 // Now that this interstitial is gone, we can show the new one.
490 if (blocking_page) 460 if (blocking_page)
491 blocking_page->Show(); 461 blocking_page->Show();
492 } 462 }
493 463
494 void SafeBrowsingBlockingPage::DontCreateViewForTesting() { 464 void SafeBrowsingBlockingPage::DontCreateViewForTesting() {
495 create_view_ = false; 465 create_view_ = false;
496 } 466 }
497 467
498 void SafeBrowsingBlockingPage::Show() { 468 void SafeBrowsingBlockingPage::Show() {
499 DCHECK(!interstitial_page_); 469 DCHECK(!interstitial_page_);
500 interstitial_page_ = InterstitialPage::Create( 470 interstitial_page_ = InterstitialPage::Create(
501 web_contents_, is_main_frame_load_blocked_, url_, this); 471 web_contents_, is_main_frame_load_blocked_, url_, this);
502 if (!create_view_) 472 if (!create_view_)
503 interstitial_page_->DontCreateViewForTesting(); 473 interstitial_page_->DontCreateViewForTesting();
504 interstitial_page_->Show(); 474 interstitial_page_->Show();
505 } 475 }
506 476
507 void SafeBrowsingBlockingPage::OnDontProceed() { 477 void SafeBrowsingBlockingPage::OnDontProceed() {
508 // Calling this method twice will not double-count. 478 // Calling this method twice will not double-count.
509 RecordUserReactionTime(kNavigatedAwayMetaCommand); 479 RecordUserReactionTime(kNavigatedAwayMetaCommand);
510 // We could have already called Proceed(), in which case we must not notify 480 // We could have already called Proceed(), in which case we must not notify
511 // the SafeBrowsingUIManager again, as the client has been deleted. 481 // the SafeBrowsingUIManager again, as the client has been deleted.
512 if (proceeded_) 482 if (proceeded_)
513 return; 483 return;
514 484
515 RecordUserAction(DONT_PROCEED);
516 // Send the malware details, if we opted to. 485 // Send the malware details, if we opted to.
517 FinishMalwareDetails(0); // No delay 486 FinishMalwareDetails(0); // No delay
518 487
519 NotifySafeBrowsingUIManager(ui_manager_, unsafe_resources_, false); 488 NotifySafeBrowsingUIManager(ui_manager_, unsafe_resources_, false);
520 489
521 // The user does not want to proceed, clear the queued unsafe resources 490 // The user does not want to proceed, clear the queued unsafe resources
522 // notifications we received while the interstitial was showing. 491 // notifications we received while the interstitial was showing.
523 UnsafeResourceMap* unsafe_resource_map = GetUnsafeResourcesMap(); 492 UnsafeResourceMap* unsafe_resource_map = GetUnsafeResourcesMap();
524 UnsafeResourceMap::iterator iter = unsafe_resource_map->find(web_contents_); 493 UnsafeResourceMap::iterator iter = unsafe_resource_map->find(web_contents_);
525 if (iter != unsafe_resource_map->end() && !iter->second.empty()) { 494 if (iter != unsafe_resource_map->end() && !iter->second.empty()) {
526 NotifySafeBrowsingUIManager(ui_manager_, iter->second, false); 495 NotifySafeBrowsingUIManager(ui_manager_, iter->second, false);
527 unsafe_resource_map->erase(iter); 496 unsafe_resource_map->erase(iter);
528 } 497 }
529 498
530 // We don't remove the navigation entry if the tab is being destroyed as this 499 // We don't remove the navigation entry if the tab is being destroyed as this
531 // would trigger a navigation that would cause trouble as the render view host 500 // would trigger a navigation that would cause trouble as the render view host
532 // for the tab has by then already been destroyed. We also don't delete the 501 // for the tab has by then already been destroyed. We also don't delete the
533 // current entry if it has been committed again, which is possible on a page 502 // current entry if it has been committed again, which is possible on a page
534 // that had a subresource warning. 503 // that had a subresource warning.
535 int last_committed_index = 504 int last_committed_index =
536 web_contents_->GetController().GetLastCommittedEntryIndex(); 505 web_contents_->GetController().GetLastCommittedEntryIndex();
537 if (navigation_entry_index_to_remove_ != -1 && 506 if (navigation_entry_index_to_remove_ != -1 &&
538 navigation_entry_index_to_remove_ != last_committed_index && 507 navigation_entry_index_to_remove_ != last_committed_index &&
539 !web_contents_->IsBeingDestroyed()) { 508 !web_contents_->IsBeingDestroyed()) {
540 CHECK(web_contents_->GetController().RemoveEntryAtIndex( 509 CHECK(web_contents_->GetController().RemoveEntryAtIndex(
541 navigation_entry_index_to_remove_)); 510 navigation_entry_index_to_remove_));
542 navigation_entry_index_to_remove_ = -1; 511 navigation_entry_index_to_remove_ = -1;
543 } 512 }
544
545 #if defined(ENABLE_EXTENSIONS)
546 // ExperienceSampling: Notify that user decided to go back.
547 // This also occurs if the user navigates away or closes the tab.
548 if (sampling_event_.get())
549 sampling_event_->CreateUserDecisionEvent(ExperienceSamplingEvent::kDeny);
550 #endif
551 } 513 }
552 514
553 void SafeBrowsingBlockingPage::OnGotHistoryCount(bool success, 515 void SafeBrowsingBlockingPage::OnGotHistoryCount(bool success,
554 int num_visits, 516 int num_visits,
555 base::Time first_visit) { 517 base::Time first_visit) {
556 if (success) 518 if (success)
557 num_visits_ = num_visits; 519 num_visits_ = num_visits;
558 } 520 }
559 521
560 void SafeBrowsingBlockingPage::RecordUserAction(BlockingPageEvent event) { 522 void SafeBrowsingBlockingPage::RecordUserDecision(Decision decision) {
561 // This enum is used for a histogram. Don't reorder, delete, or insert 523 switch (interstitial_type_) {
562 // elements. New elements should be added before MAX_ACTION only. 524 case TYPE_MALWARE:
563 enum { 525 UMA_HISTOGRAM_ENUMERATION("interstitial.malware.decision",
564 MALWARE_SHOW = 0, 526 decision,
565 MALWARE_DONT_PROCEED, 527 MAX_DECISION);
566 MALWARE_FORCED_DONT_PROCEED,
567 MALWARE_PROCEED,
568 MULTIPLE_SHOW,
569 MULTIPLE_DONT_PROCEED,
570 MULTIPLE_FORCED_DONT_PROCEED,
571 MULTIPLE_PROCEED,
572 PHISHING_SHOW,
573 PHISHING_DONT_PROCEED,
574 PHISHING_FORCED_DONT_PROCEED,
575 PHISHING_PROCEED,
576 MALWARE_SHOW_ADVANCED,
577 MULTIPLE_SHOW_ADVANCED,
578 PHISHING_SHOW_ADVANCED,
579 MAX_ACTION
580 } histogram_action = MAX_ACTION;
581
582 switch (event) {
583 case SHOW:
584 switch (interstitial_type_) {
585 case TYPE_MALWARE_AND_PHISHING:
586 histogram_action = MULTIPLE_SHOW;
587 break;
588 case TYPE_MALWARE:
589 histogram_action = MALWARE_SHOW;
590 break;
591 case TYPE_PHISHING:
592 histogram_action = PHISHING_SHOW;
593 break;
594 }
595 break; 528 break;
596 case PROCEED: 529 case TYPE_PHISHING:
597 switch (interstitial_type_) { 530 UMA_HISTOGRAM_ENUMERATION("interstitial.phishing.decision",
598 case TYPE_MALWARE_AND_PHISHING: 531 decision,
599 histogram_action = MULTIPLE_PROCEED; 532 MAX_DECISION);
600 break;
601 case TYPE_MALWARE:
602 histogram_action = MALWARE_PROCEED;
603 break;
604 case TYPE_PHISHING:
605 histogram_action = PHISHING_PROCEED;
606 break;
607 }
608 break;
609 case DONT_PROCEED:
610 if (IsPrefEnabled(prefs::kSafeBrowsingProceedAnywayDisabled)) {
611 switch (interstitial_type_) {
612 case TYPE_MALWARE_AND_PHISHING:
613 histogram_action = MULTIPLE_FORCED_DONT_PROCEED;
614 break;
615 case TYPE_MALWARE:
616 histogram_action = MALWARE_FORCED_DONT_PROCEED;
617 break;
618 case TYPE_PHISHING:
619 histogram_action = PHISHING_FORCED_DONT_PROCEED;
620 break;
621 }
622 } else {
623 switch (interstitial_type_) {
624 case TYPE_MALWARE_AND_PHISHING:
625 histogram_action = MULTIPLE_DONT_PROCEED;
626 break;
627 case TYPE_MALWARE:
628 histogram_action = MALWARE_DONT_PROCEED;
629 break;
630 case TYPE_PHISHING:
631 histogram_action = PHISHING_DONT_PROCEED;
632 break;
633 }
634 }
635 break;
636 case SHOW_ADVANCED:
637 switch (interstitial_type_) {
638 case TYPE_MALWARE_AND_PHISHING:
639 histogram_action = MULTIPLE_SHOW_ADVANCED;
640 break;
641 case TYPE_MALWARE:
642 histogram_action = MALWARE_SHOW_ADVANCED;
643 break;
644 case TYPE_PHISHING:
645 histogram_action = PHISHING_SHOW_ADVANCED;
646 break;
647 }
648 break; 533 break;
649 default: 534 default:
650 NOTREACHED() << "Unexpected event: " << event; 535 NOTREACHED();
651 }
652 if (histogram_action == MAX_ACTION) {
653 NOTREACHED();
654 } else {
655 UMA_HISTOGRAM_ENUMERATION("SB2.InterstitialAction", histogram_action,
656 MAX_ACTION);
657 } 536 }
658 537
659 if (event == PROCEED || event == DONT_PROCEED) { 538 #if defined(ENABLE_EXTENSIONS)
660 if (num_visits_ == 0 && interstitial_type_ != TYPE_MALWARE_AND_PHISHING) { 539 if (sampling_event_.get()) {
661 RecordDetailedUserAction((interstitial_type_ == TYPE_MALWARE) ? 540 switch (decision) {
662 MALWARE_SHOW_NEW_SITE : PHISHING_SHOW_NEW_SITE); 541 case PROCEED:
663 if (event == PROCEED) { 542 sampling_event_->CreateUserDecisionEvent(
664 RecordDetailedUserAction((interstitial_type_ == TYPE_MALWARE) ? 543 ExperienceSamplingEvent::kProceed);
665 MALWARE_PROCEED_NEW_SITE : PHISHING_PROCEED_NEW_SITE); 544 break;
666 } 545 case DONT_PROCEED:
546 sampling_event_->CreateUserDecisionEvent(
547 ExperienceSamplingEvent::kDeny);
548 break;
549 case SHOW:
550 case PROCEEDING_DISABLED:
551 case MAX_DECISION:
552 break;
667 } 553 }
668 if (unsafe_resources_[0].is_subresource && 554 }
669 interstitial_type_ != TYPE_MALWARE_AND_PHISHING) { 555 #endif
670 RecordDetailedUserAction((interstitial_type_ == TYPE_MALWARE) ? 556
671 MALWARE_SHOW_CROSS_SITE : PHISHING_SHOW_CROSS_SITE); 557 // Record additional information about malware sites that users have
672 if (event == PROCEED) { 558 // visited before.
673 RecordDetailedUserAction((interstitial_type_ == TYPE_MALWARE) ? 559 if (num_visits_ < 1 || interstitial_type_ != TYPE_MALWARE)
674 MALWARE_PROCEED_CROSS_SITE : PHISHING_PROCEED_CROSS_SITE); 560 return;
675 } 561 if (decision == PROCEED || decision == DONT_PROCEED) {
676 } 562 UMA_HISTOGRAM_ENUMERATION("interstitial.malware.repeat_visit_decision",
563 SHOW,
564 MAX_DECISION);
565 UMA_HISTOGRAM_ENUMERATION("interstitial.malware.repeat_visit_decision",
566 decision,
567 MAX_DECISION);
677 } 568 }
678 } 569 }
679 570
571 void SafeBrowsingBlockingPage::RecordUserInteraction(Interaction interaction) {
572 switch (interstitial_type_) {
573 case TYPE_MALWARE:
574 UMA_HISTOGRAM_ENUMERATION("interstitial.malware.interaction",
575 interaction,
576 MAX_INTERACTION);
577 break;
578 case TYPE_PHISHING:
579 UMA_HISTOGRAM_ENUMERATION("interstitial.phishing.interaction",
580 interaction,
581 MAX_INTERACTION);
582 break;
583 default:
584 NOTREACHED();
585 }
586
587 #if defined(ENABLE_EXTENSIONS)
588 if (!sampling_event_.get())
589 return;
590 switch (interaction) {
591 case SHOW_LEARN_MORE:
592 sampling_event_->set_has_viewed_learn_more(true);
593 break;
594 case SHOW_ADVANCED:
595 sampling_event_->set_has_viewed_details(true);
596 break;
597 case SHOW_PRIVACY_POLICY:
598 case SHOW_DIAGNOSTIC:
599 case MAX_INTERACTION:
600 break;
601 }
602 #endif
603 }
604
680 void SafeBrowsingBlockingPage::RecordUserReactionTime( 605 void SafeBrowsingBlockingPage::RecordUserReactionTime(
681 const std::string& command) { 606 const std::string& command) {
682 if (interstitial_show_time_.is_null()) 607 if (interstitial_show_time_.is_null())
683 return; // We already reported the user reaction time. 608 return; // We already reported the user reaction time.
684 base::TimeDelta dt = base::TimeTicks::Now() - interstitial_show_time_; 609 base::TimeDelta dt = base::TimeTicks::Now() - interstitial_show_time_;
685 DVLOG(1) << "User reaction time for command:" << command 610 DVLOG(1) << "User reaction time for command:" << command
686 << " on interstitial_type_:" << interstitial_type_ 611 << " on interstitial_type_:" << interstitial_type_
687 << " warning took " << dt.InMilliseconds() << "ms"; 612 << " warning took " << dt.InMilliseconds() << "ms";
688 bool recorded = true; 613 bool recorded = true;
689 if (interstitial_type_ == TYPE_MALWARE || 614 if (interstitial_type_ == TYPE_MALWARE ||
(...skipping 14 matching lines...) Expand all
704 } else if (command == kLearnMoreCommand) { 629 } else if (command == kLearnMoreCommand) {
705 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.MalwareInterstitialLearnMore", 630 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.MalwareInterstitialLearnMore",
706 dt); 631 dt);
707 } else if (command == kNavigatedAwayMetaCommand) { 632 } else if (command == kNavigatedAwayMetaCommand) {
708 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.MalwareInterstitialTimeClosed", dt); 633 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.MalwareInterstitialTimeClosed", dt);
709 } else if (command == kExpandedSeeMoreCommand) { 634 } else if (command == kExpandedSeeMoreCommand) {
710 // Only record the expanded histogram once per display of the 635 // Only record the expanded histogram once per display of the
711 // interstitial. 636 // interstitial.
712 if (has_expanded_see_more_section_) 637 if (has_expanded_see_more_section_)
713 return; 638 return;
714 RecordUserAction(SHOW_ADVANCED);
715 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.MalwareInterstitialTimeExpandedSeeMore", 639 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.MalwareInterstitialTimeExpandedSeeMore",
716 dt); 640 dt);
717 has_expanded_see_more_section_ = true; 641 has_expanded_see_more_section_ = true;
718 // Expanding the "See More" section doesn't finish the interstitial, so 642 // Expanding the "See More" section doesn't finish the interstitial, so
719 // don't mark the reaction time as recorded. 643 // don't mark the reaction time as recorded.
720 recorded = false; 644 recorded = false;
721 } else { 645 } else {
722 recorded = false; 646 recorded = false;
723 } 647 }
724 } else { 648 } else {
725 // Same as above but for phishing warnings. 649 // Same as above but for phishing warnings.
726 if (command == kProceedCommand) { 650 if (command == kProceedCommand) {
727 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.PhishingInterstitialTimeProceed", dt); 651 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.PhishingInterstitialTimeProceed", dt);
728 } else if (command == kTakeMeBackCommand) { 652 } else if (command == kTakeMeBackCommand) {
729 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.PhishingInterstitialTimeTakeMeBack", dt); 653 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.PhishingInterstitialTimeTakeMeBack", dt);
730 } else if (command == kShowDiagnosticCommand) { 654 } else if (command == kShowDiagnosticCommand) {
731 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.PhishingInterstitialTimeReportError", dt); 655 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.PhishingInterstitialTimeReportError", dt);
732 } else if (command == kLearnMoreCommand) { 656 } else if (command == kLearnMoreCommand) {
733 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.PhishingInterstitialTimeLearnMore", dt); 657 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.PhishingInterstitialTimeLearnMore", dt);
734 } else if (command == kNavigatedAwayMetaCommand) { 658 } else if (command == kNavigatedAwayMetaCommand) {
735 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.PhishingInterstitialTimeClosed", dt); 659 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.PhishingInterstitialTimeClosed", dt);
736 } else if (command == kExpandedSeeMoreCommand) { 660 } else if (command == kExpandedSeeMoreCommand) {
737 // Only record the expanded histogram once per display of the 661 // Only record the expanded histogram once per display of the
738 // interstitial. 662 // interstitial.
739 if (has_expanded_see_more_section_) 663 if (has_expanded_see_more_section_)
740 return; 664 return;
741 RecordUserAction(SHOW_ADVANCED);
742 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.PhishingInterstitialTimeExpandedSeeMore", 665 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.PhishingInterstitialTimeExpandedSeeMore",
743 dt); 666 dt);
744 has_expanded_see_more_section_ = true; 667 has_expanded_see_more_section_ = true;
745 // Expanding the "See More" section doesn't finish the interstitial, so 668 // Expanding the "See More" section doesn't finish the interstitial, so
746 // don't mark the reaction time as recorded. 669 // don't mark the reaction time as recorded.
747 recorded = false; 670 recorded = false;
748 } else { 671 } else {
749 recorded = false; 672 recorded = false;
750 } 673 }
751 } 674 }
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
940 IDS_PHISHING_V3_PRIMARY_PARAGRAPH, 863 IDS_PHISHING_V3_PRIMARY_PARAGRAPH,
941 base::UTF8ToUTF16(url_.host()))); 864 base::UTF8ToUTF16(url_.host())));
942 load_time_data->SetString( 865 load_time_data->SetString(
943 "explanationParagraph", 866 "explanationParagraph",
944 l10n_util::GetStringFUTF16(IDS_PHISHING_V3_EXPLANATION_PARAGRAPH, 867 l10n_util::GetStringFUTF16(IDS_PHISHING_V3_EXPLANATION_PARAGRAPH,
945 base::UTF8ToUTF16(url_.host()))); 868 base::UTF8ToUTF16(url_.host())));
946 load_time_data->SetString( 869 load_time_data->SetString(
947 "finalParagraph", 870 "finalParagraph",
948 l10n_util::GetStringUTF16(IDS_PHISHING_V3_PROCEED_PARAGRAPH)); 871 l10n_util::GetStringUTF16(IDS_PHISHING_V3_PROCEED_PARAGRAPH));
949 } 872 }
OLDNEW
« no previous file with comments | « chrome/browser/safe_browsing/safe_browsing_blocking_page.h ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698