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

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: Moved DONT_PROCEED call 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 // Don't record the user action here because there are other ways of
331 // triggering DontProceed, like clicking the back button.
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); 485 if (!IsPrefEnabled(prefs::kSafeBrowsingProceedAnywayDisabled))
486 RecordUserDecision(DONT_PROCEED);
487
516 // Send the malware details, if we opted to. 488 // Send the malware details, if we opted to.
517 FinishMalwareDetails(0); // No delay 489 FinishMalwareDetails(0); // No delay
518 490
519 NotifySafeBrowsingUIManager(ui_manager_, unsafe_resources_, false); 491 NotifySafeBrowsingUIManager(ui_manager_, unsafe_resources_, false);
520 492
521 // The user does not want to proceed, clear the queued unsafe resources 493 // The user does not want to proceed, clear the queued unsafe resources
522 // notifications we received while the interstitial was showing. 494 // notifications we received while the interstitial was showing.
523 UnsafeResourceMap* unsafe_resource_map = GetUnsafeResourcesMap(); 495 UnsafeResourceMap* unsafe_resource_map = GetUnsafeResourcesMap();
524 UnsafeResourceMap::iterator iter = unsafe_resource_map->find(web_contents_); 496 UnsafeResourceMap::iterator iter = unsafe_resource_map->find(web_contents_);
525 if (iter != unsafe_resource_map->end() && !iter->second.empty()) { 497 if (iter != unsafe_resource_map->end() && !iter->second.empty()) {
526 NotifySafeBrowsingUIManager(ui_manager_, iter->second, false); 498 NotifySafeBrowsingUIManager(ui_manager_, iter->second, false);
527 unsafe_resource_map->erase(iter); 499 unsafe_resource_map->erase(iter);
528 } 500 }
529 501
530 // We don't remove the navigation entry if the tab is being destroyed as this 502 // 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 503 // 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 504 // 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 505 // current entry if it has been committed again, which is possible on a page
534 // that had a subresource warning. 506 // that had a subresource warning.
535 int last_committed_index = 507 int last_committed_index =
536 web_contents_->GetController().GetLastCommittedEntryIndex(); 508 web_contents_->GetController().GetLastCommittedEntryIndex();
537 if (navigation_entry_index_to_remove_ != -1 && 509 if (navigation_entry_index_to_remove_ != -1 &&
538 navigation_entry_index_to_remove_ != last_committed_index && 510 navigation_entry_index_to_remove_ != last_committed_index &&
539 !web_contents_->IsBeingDestroyed()) { 511 !web_contents_->IsBeingDestroyed()) {
540 CHECK(web_contents_->GetController().RemoveEntryAtIndex( 512 CHECK(web_contents_->GetController().RemoveEntryAtIndex(
541 navigation_entry_index_to_remove_)); 513 navigation_entry_index_to_remove_));
542 navigation_entry_index_to_remove_ = -1; 514 navigation_entry_index_to_remove_ = -1;
543 } 515 }
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 } 516 }
552 517
553 void SafeBrowsingBlockingPage::OnGotHistoryCount(bool success, 518 void SafeBrowsingBlockingPage::OnGotHistoryCount(bool success,
554 int num_visits, 519 int num_visits,
555 base::Time first_visit) { 520 base::Time first_visit) {
556 if (success) 521 if (success)
557 num_visits_ = num_visits; 522 num_visits_ = num_visits;
558 } 523 }
559 524
560 void SafeBrowsingBlockingPage::RecordUserAction(BlockingPageEvent event) { 525 void SafeBrowsingBlockingPage::RecordUserDecision(Decision decision) {
561 // This enum is used for a histogram. Don't reorder, delete, or insert 526 switch (interstitial_type_) {
562 // elements. New elements should be added before MAX_ACTION only. 527 case TYPE_MALWARE:
563 enum { 528 UMA_HISTOGRAM_ENUMERATION("interstitial.malware.decision",
564 MALWARE_SHOW = 0, 529 decision,
565 MALWARE_DONT_PROCEED, 530 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; 531 break;
596 case PROCEED: 532 case TYPE_PHISHING:
597 switch (interstitial_type_) { 533 UMA_HISTOGRAM_ENUMERATION("interstitial.phishing.decision",
598 case TYPE_MALWARE_AND_PHISHING: 534 decision,
599 histogram_action = MULTIPLE_PROCEED; 535 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; 536 break;
649 default: 537 default:
650 NOTREACHED() << "Unexpected event: " << event; 538 NOTREACHED();
651 }
652 if (histogram_action == MAX_ACTION) {
653 NOTREACHED();
654 } else {
655 UMA_HISTOGRAM_ENUMERATION("SB2.InterstitialAction", histogram_action,
656 MAX_ACTION);
657 } 539 }
658 540
659 if (event == PROCEED || event == DONT_PROCEED) { 541 #if defined(ENABLE_EXTENSIONS)
660 if (num_visits_ == 0 && interstitial_type_ != TYPE_MALWARE_AND_PHISHING) { 542 if (sampling_event_.get()) {
661 RecordDetailedUserAction((interstitial_type_ == TYPE_MALWARE) ? 543 switch (decision) {
662 MALWARE_SHOW_NEW_SITE : PHISHING_SHOW_NEW_SITE); 544 case PROCEED:
663 if (event == PROCEED) { 545 sampling_event_->CreateUserDecisionEvent(
664 RecordDetailedUserAction((interstitial_type_ == TYPE_MALWARE) ? 546 ExperienceSamplingEvent::kProceed);
665 MALWARE_PROCEED_NEW_SITE : PHISHING_PROCEED_NEW_SITE); 547 break;
666 } 548 case DONT_PROCEED:
549 sampling_event_->CreateUserDecisionEvent(
550 ExperienceSamplingEvent::kDeny);
551 break;
552 case SHOW:
553 case PROCEEDING_DISABLED:
554 case MAX_DECISION:
555 break;
667 } 556 }
668 if (unsafe_resources_[0].is_subresource && 557 }
669 interstitial_type_ != TYPE_MALWARE_AND_PHISHING) { 558 #endif
670 RecordDetailedUserAction((interstitial_type_ == TYPE_MALWARE) ? 559
671 MALWARE_SHOW_CROSS_SITE : PHISHING_SHOW_CROSS_SITE); 560 // Record additional information about malware sites that users have
672 if (event == PROCEED) { 561 // visited before.
673 RecordDetailedUserAction((interstitial_type_ == TYPE_MALWARE) ? 562 if (num_visits_ < 1 || interstitial_type_ != TYPE_MALWARE)
674 MALWARE_PROCEED_CROSS_SITE : PHISHING_PROCEED_CROSS_SITE); 563 return;
675 } 564 if (decision == PROCEED || decision == DONT_PROCEED) {
676 } 565 UMA_HISTOGRAM_ENUMERATION("interstitial.malware.repeat_visit_decision",
566 SHOW,
567 MAX_DECISION);
568 UMA_HISTOGRAM_ENUMERATION("interstitial.malware.repeat_visit_decision",
569 decision,
570 MAX_DECISION);
677 } 571 }
678 } 572 }
679 573
574 void SafeBrowsingBlockingPage::RecordUserInteraction(Interaction interaction) {
575 switch (interstitial_type_) {
576 case TYPE_MALWARE:
577 UMA_HISTOGRAM_ENUMERATION("interstitial.malware.interaction",
578 interaction,
579 MAX_INTERACTION);
580 break;
581 case TYPE_PHISHING:
582 UMA_HISTOGRAM_ENUMERATION("interstitial.phishing.interaction",
583 interaction,
584 MAX_INTERACTION);
585 break;
586 default:
587 NOTREACHED();
588 }
589
590 #if defined(ENABLE_EXTENSIONS)
591 if (!sampling_event_.get())
592 return;
593 switch (interaction) {
594 case SHOW_LEARN_MORE:
595 sampling_event_->set_has_viewed_learn_more(true);
596 break;
597 case SHOW_ADVANCED:
598 sampling_event_->set_has_viewed_details(true);
599 break;
600 case SHOW_PRIVACY_POLICY:
601 case SHOW_DIAGNOSTIC:
602 case MAX_INTERACTION:
603 break;
604 }
605 #endif
606 }
607
680 void SafeBrowsingBlockingPage::RecordUserReactionTime( 608 void SafeBrowsingBlockingPage::RecordUserReactionTime(
681 const std::string& command) { 609 const std::string& command) {
682 if (interstitial_show_time_.is_null()) 610 if (interstitial_show_time_.is_null())
683 return; // We already reported the user reaction time. 611 return; // We already reported the user reaction time.
684 base::TimeDelta dt = base::TimeTicks::Now() - interstitial_show_time_; 612 base::TimeDelta dt = base::TimeTicks::Now() - interstitial_show_time_;
685 DVLOG(1) << "User reaction time for command:" << command 613 DVLOG(1) << "User reaction time for command:" << command
686 << " on interstitial_type_:" << interstitial_type_ 614 << " on interstitial_type_:" << interstitial_type_
687 << " warning took " << dt.InMilliseconds() << "ms"; 615 << " warning took " << dt.InMilliseconds() << "ms";
688 bool recorded = true; 616 bool recorded = true;
689 if (interstitial_type_ == TYPE_MALWARE || 617 if (interstitial_type_ == TYPE_MALWARE ||
(...skipping 14 matching lines...) Expand all
704 } else if (command == kLearnMoreCommand) { 632 } else if (command == kLearnMoreCommand) {
705 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.MalwareInterstitialLearnMore", 633 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.MalwareInterstitialLearnMore",
706 dt); 634 dt);
707 } else if (command == kNavigatedAwayMetaCommand) { 635 } else if (command == kNavigatedAwayMetaCommand) {
708 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.MalwareInterstitialTimeClosed", dt); 636 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.MalwareInterstitialTimeClosed", dt);
709 } else if (command == kExpandedSeeMoreCommand) { 637 } else if (command == kExpandedSeeMoreCommand) {
710 // Only record the expanded histogram once per display of the 638 // Only record the expanded histogram once per display of the
711 // interstitial. 639 // interstitial.
712 if (has_expanded_see_more_section_) 640 if (has_expanded_see_more_section_)
713 return; 641 return;
714 RecordUserAction(SHOW_ADVANCED);
715 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.MalwareInterstitialTimeExpandedSeeMore", 642 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.MalwareInterstitialTimeExpandedSeeMore",
716 dt); 643 dt);
717 has_expanded_see_more_section_ = true; 644 has_expanded_see_more_section_ = true;
718 // Expanding the "See More" section doesn't finish the interstitial, so 645 // Expanding the "See More" section doesn't finish the interstitial, so
719 // don't mark the reaction time as recorded. 646 // don't mark the reaction time as recorded.
720 recorded = false; 647 recorded = false;
721 } else { 648 } else {
722 recorded = false; 649 recorded = false;
723 } 650 }
724 } else { 651 } else {
725 // Same as above but for phishing warnings. 652 // Same as above but for phishing warnings.
726 if (command == kProceedCommand) { 653 if (command == kProceedCommand) {
727 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.PhishingInterstitialTimeProceed", dt); 654 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.PhishingInterstitialTimeProceed", dt);
728 } else if (command == kTakeMeBackCommand) { 655 } else if (command == kTakeMeBackCommand) {
729 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.PhishingInterstitialTimeTakeMeBack", dt); 656 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.PhishingInterstitialTimeTakeMeBack", dt);
730 } else if (command == kShowDiagnosticCommand) { 657 } else if (command == kShowDiagnosticCommand) {
731 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.PhishingInterstitialTimeReportError", dt); 658 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.PhishingInterstitialTimeReportError", dt);
732 } else if (command == kLearnMoreCommand) { 659 } else if (command == kLearnMoreCommand) {
733 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.PhishingInterstitialTimeLearnMore", dt); 660 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.PhishingInterstitialTimeLearnMore", dt);
734 } else if (command == kNavigatedAwayMetaCommand) { 661 } else if (command == kNavigatedAwayMetaCommand) {
735 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.PhishingInterstitialTimeClosed", dt); 662 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.PhishingInterstitialTimeClosed", dt);
736 } else if (command == kExpandedSeeMoreCommand) { 663 } else if (command == kExpandedSeeMoreCommand) {
737 // Only record the expanded histogram once per display of the 664 // Only record the expanded histogram once per display of the
738 // interstitial. 665 // interstitial.
739 if (has_expanded_see_more_section_) 666 if (has_expanded_see_more_section_)
740 return; 667 return;
741 RecordUserAction(SHOW_ADVANCED);
742 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.PhishingInterstitialTimeExpandedSeeMore", 668 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.PhishingInterstitialTimeExpandedSeeMore",
743 dt); 669 dt);
744 has_expanded_see_more_section_ = true; 670 has_expanded_see_more_section_ = true;
745 // Expanding the "See More" section doesn't finish the interstitial, so 671 // Expanding the "See More" section doesn't finish the interstitial, so
746 // don't mark the reaction time as recorded. 672 // don't mark the reaction time as recorded.
747 recorded = false; 673 recorded = false;
748 } else { 674 } else {
749 recorded = false; 675 recorded = false;
750 } 676 }
751 } 677 }
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
940 IDS_PHISHING_V3_PRIMARY_PARAGRAPH, 866 IDS_PHISHING_V3_PRIMARY_PARAGRAPH,
941 base::UTF8ToUTF16(url_.host()))); 867 base::UTF8ToUTF16(url_.host())));
942 load_time_data->SetString( 868 load_time_data->SetString(
943 "explanationParagraph", 869 "explanationParagraph",
944 l10n_util::GetStringFUTF16(IDS_PHISHING_V3_EXPLANATION_PARAGRAPH, 870 l10n_util::GetStringFUTF16(IDS_PHISHING_V3_EXPLANATION_PARAGRAPH,
945 base::UTF8ToUTF16(url_.host()))); 871 base::UTF8ToUTF16(url_.host())));
946 load_time_data->SetString( 872 load_time_data->SetString(
947 "finalParagraph", 873 "finalParagraph",
948 l10n_util::GetStringUTF16(IDS_PHISHING_V3_PROCEED_PARAGRAPH)); 874 l10n_util::GetStringUTF16(IDS_PHISHING_V3_PROCEED_PARAGRAPH));
949 } 875 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698