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

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

Issue 572163002: Deprecate Safe Browsing timing histograms (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 // The commands returned by the page when the user performs an action. 95 // The commands returned by the page when the user performs an action.
96 const char kDoReportCommand[] = "doReport"; 96 const char kDoReportCommand[] = "doReport";
97 const char kDontReportCommand[] = "dontReport"; 97 const char kDontReportCommand[] = "dontReport";
98 const char kExpandedSeeMoreCommand[] = "expandedSeeMore"; 98 const char kExpandedSeeMoreCommand[] = "expandedSeeMore";
99 const char kLearnMoreCommand[] = "learnMore2"; 99 const char kLearnMoreCommand[] = "learnMore2";
100 const char kProceedCommand[] = "proceed"; 100 const char kProceedCommand[] = "proceed";
101 const char kReportErrorCommand[] = "reportError"; 101 const char kReportErrorCommand[] = "reportError";
102 const char kShowDiagnosticCommand[] = "showDiagnostic"; 102 const char kShowDiagnosticCommand[] = "showDiagnostic";
103 const char kShowPrivacyCommand[] = "showPrivacy"; 103 const char kShowPrivacyCommand[] = "showPrivacy";
104 const char kTakeMeBackCommand[] = "takeMeBack"; 104 const char kTakeMeBackCommand[] = "takeMeBack";
105 // Special command that we use when the user navigated away from the
106 // page. E.g., closed the tab or the window. This is only used by
107 // RecordUserReactionTime.
108 const char kNavigatedAwayMetaCommand[] = "closed";
109 105
110 // Other constants used to communicate with the JavaScript. 106 // Other constants used to communicate with the JavaScript.
111 const char kBoxChecked[] = "boxchecked"; 107 const char kBoxChecked[] = "boxchecked";
112 const char kDisplayCheckBox[] = "displaycheckbox"; 108 const char kDisplayCheckBox[] = "displaycheckbox";
113 109
114 // Constants for the Experience Sampling instrumentation. 110 // Constants for the Experience Sampling instrumentation.
115 #if defined(ENABLE_EXTENSIONS) 111 #if defined(ENABLE_EXTENSIONS)
116 const char kEventNameMalware[] = "safebrowsing_interstitial_"; 112 const char kEventNameMalware[] = "safebrowsing_interstitial_";
117 const char kEventNamePhishing[] = "phishing_interstitial_"; 113 const char kEventNamePhishing[] = "phishing_interstitial_";
118 const char kEventNameMalwareAndPhishing[] = 114 const char kEventNameMalwareAndPhishing[] =
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 277
282 SafeBrowsingBlockingPage::~SafeBrowsingBlockingPage() { 278 SafeBrowsingBlockingPage::~SafeBrowsingBlockingPage() {
283 } 279 }
284 280
285 void SafeBrowsingBlockingPage::CommandReceived(const std::string& cmd) { 281 void SafeBrowsingBlockingPage::CommandReceived(const std::string& cmd) {
286 std::string command(cmd); // Make a local copy so we can modify it. 282 std::string command(cmd); // Make a local copy so we can modify it.
287 // The Jasonified response has quotes, remove them. 283 // The Jasonified response has quotes, remove them.
288 if (command.length() > 1 && command[0] == '"') { 284 if (command.length() > 1 && command[0] == '"') {
289 command = command.substr(1, command.length() - 2); 285 command = command.substr(1, command.length() - 2);
290 } 286 }
291 RecordUserReactionTime(command);
292 if (command == kDoReportCommand) { 287 if (command == kDoReportCommand) {
293 SetReportingPreference(true); 288 SetReportingPreference(true);
294 return; 289 return;
295 } 290 }
296 291
297 if (command == kDontReportCommand) { 292 if (command == kDontReportCommand) {
298 SetReportingPreference(false); 293 SetReportingPreference(false);
299 return; 294 return;
300 } 295 }
301 296
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 unsafe_resources_[element_index].threat_type == 416 unsafe_resources_[element_index].threat_type ==
422 SB_THREAT_TYPE_CLIENT_SIDE_MALWARE_URL); 417 SB_THREAT_TYPE_CLIENT_SIDE_MALWARE_URL);
423 OpenURLParams params( 418 OpenURLParams params(
424 diagnostic_url, Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_LINK, 419 diagnostic_url, Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_LINK,
425 false); 420 false);
426 web_contents_->OpenURL(params); 421 web_contents_->OpenURL(params);
427 return; 422 return;
428 } 423 }
429 424
430 if (command == kExpandedSeeMoreCommand) { 425 if (command == kExpandedSeeMoreCommand) {
431 // User expanded the "see more info" section of the page. We don't actually
432 // do any action based on this, it's just so that RecordUserReactionTime can
433 // track it.
434
435 #if defined(ENABLE_EXTENSIONS) 426 #if defined(ENABLE_EXTENSIONS)
436 // ExperienceSampling: We track that the user expanded the details. 427 // ExperienceSampling: We track that the user expanded the details.
437 if (sampling_event_.get()) 428 if (sampling_event_.get())
438 sampling_event_->set_has_viewed_details(true); 429 sampling_event_->set_has_viewed_details(true);
439 #endif 430 #endif
440 return; 431 return;
441 } 432 }
442 433
443 NOTREACHED() << "Unexpected command: " << command; 434 NOTREACHED() << "Unexpected command: " << command;
444 } 435 }
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 void SafeBrowsingBlockingPage::Show() { 489 void SafeBrowsingBlockingPage::Show() {
499 DCHECK(!interstitial_page_); 490 DCHECK(!interstitial_page_);
500 interstitial_page_ = InterstitialPage::Create( 491 interstitial_page_ = InterstitialPage::Create(
501 web_contents_, is_main_frame_load_blocked_, url_, this); 492 web_contents_, is_main_frame_load_blocked_, url_, this);
502 if (!create_view_) 493 if (!create_view_)
503 interstitial_page_->DontCreateViewForTesting(); 494 interstitial_page_->DontCreateViewForTesting();
504 interstitial_page_->Show(); 495 interstitial_page_->Show();
505 } 496 }
506 497
507 void SafeBrowsingBlockingPage::OnDontProceed() { 498 void SafeBrowsingBlockingPage::OnDontProceed() {
508 // Calling this method twice will not double-count.
509 RecordUserReactionTime(kNavigatedAwayMetaCommand);
510 // We could have already called Proceed(), in which case we must not notify 499 // We could have already called Proceed(), in which case we must not notify
511 // the SafeBrowsingUIManager again, as the client has been deleted. 500 // the SafeBrowsingUIManager again, as the client has been deleted.
512 if (proceeded_) 501 if (proceeded_)
513 return; 502 return;
514 503
515 RecordUserAction(DONT_PROCEED); 504 RecordUserAction(DONT_PROCEED);
516 // Send the malware details, if we opted to. 505 // Send the malware details, if we opted to.
517 FinishMalwareDetails(0); // No delay 506 FinishMalwareDetails(0); // No delay
518 507
519 NotifySafeBrowsingUIManager(ui_manager_, unsafe_resources_, false); 508 NotifySafeBrowsingUIManager(ui_manager_, unsafe_resources_, false);
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
670 RecordDetailedUserAction((interstitial_type_ == TYPE_MALWARE) ? 659 RecordDetailedUserAction((interstitial_type_ == TYPE_MALWARE) ?
671 MALWARE_SHOW_CROSS_SITE : PHISHING_SHOW_CROSS_SITE); 660 MALWARE_SHOW_CROSS_SITE : PHISHING_SHOW_CROSS_SITE);
672 if (event == PROCEED) { 661 if (event == PROCEED) {
673 RecordDetailedUserAction((interstitial_type_ == TYPE_MALWARE) ? 662 RecordDetailedUserAction((interstitial_type_ == TYPE_MALWARE) ?
674 MALWARE_PROCEED_CROSS_SITE : PHISHING_PROCEED_CROSS_SITE); 663 MALWARE_PROCEED_CROSS_SITE : PHISHING_PROCEED_CROSS_SITE);
675 } 664 }
676 } 665 }
677 } 666 }
678 } 667 }
679 668
680 void SafeBrowsingBlockingPage::RecordUserReactionTime(
681 const std::string& command) {
682 if (interstitial_show_time_.is_null())
683 return; // We already reported the user reaction time.
684 base::TimeDelta dt = base::TimeTicks::Now() - interstitial_show_time_;
685 DVLOG(1) << "User reaction time for command:" << command
686 << " on interstitial_type_:" << interstitial_type_
687 << " warning took " << dt.InMilliseconds() << "ms";
688 bool recorded = true;
689 if (interstitial_type_ == TYPE_MALWARE ||
690 interstitial_type_ == TYPE_MALWARE_AND_PHISHING) {
691 // There are six ways in which the malware interstitial can go
692 // away. We handle all of them here but we group two together: closing the
693 // tag / browser window and clicking on the back button in the browser (not
694 // the big green button) are considered the same action.
695 if (command == kProceedCommand) {
696 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.MalwareInterstitialTimeProceed", dt);
697 } else if (command == kTakeMeBackCommand) {
698 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.MalwareInterstitialTimeTakeMeBack", dt);
699 } else if (command == kShowDiagnosticCommand) {
700 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.MalwareInterstitialTimeDiagnostic", dt);
701 } else if (command == kShowPrivacyCommand) {
702 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.MalwareInterstitialTimePrivacyPolicy",
703 dt);
704 } else if (command == kLearnMoreCommand) {
705 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.MalwareInterstitialLearnMore",
706 dt);
707 } else if (command == kNavigatedAwayMetaCommand) {
708 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.MalwareInterstitialTimeClosed", dt);
709 } else if (command == kExpandedSeeMoreCommand) {
710 // Only record the expanded histogram once per display of the
711 // interstitial.
712 if (has_expanded_see_more_section_)
713 return;
714 RecordUserAction(SHOW_ADVANCED);
715 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.MalwareInterstitialTimeExpandedSeeMore",
716 dt);
717 has_expanded_see_more_section_ = true;
718 // Expanding the "See More" section doesn't finish the interstitial, so
719 // don't mark the reaction time as recorded.
720 recorded = false;
721 } else {
722 recorded = false;
723 }
724 } else {
725 // Same as above but for phishing warnings.
726 if (command == kProceedCommand) {
727 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.PhishingInterstitialTimeProceed", dt);
728 } else if (command == kTakeMeBackCommand) {
729 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.PhishingInterstitialTimeTakeMeBack", dt);
730 } else if (command == kShowDiagnosticCommand) {
731 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.PhishingInterstitialTimeReportError", dt);
732 } else if (command == kLearnMoreCommand) {
733 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.PhishingInterstitialTimeLearnMore", dt);
734 } else if (command == kNavigatedAwayMetaCommand) {
735 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.PhishingInterstitialTimeClosed", dt);
736 } else if (command == kExpandedSeeMoreCommand) {
737 // Only record the expanded histogram once per display of the
738 // interstitial.
739 if (has_expanded_see_more_section_)
740 return;
741 RecordUserAction(SHOW_ADVANCED);
742 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.PhishingInterstitialTimeExpandedSeeMore",
743 dt);
744 has_expanded_see_more_section_ = true;
745 // Expanding the "See More" section doesn't finish the interstitial, so
746 // don't mark the reaction time as recorded.
747 recorded = false;
748 } else {
749 recorded = false;
750 }
751 }
752 if (recorded) // Making sure we don't double-count reaction times.
753 interstitial_show_time_ = base::TimeTicks(); // Resets the show time.
754 }
755
756 void SafeBrowsingBlockingPage::FinishMalwareDetails(int64 delay_ms) { 669 void SafeBrowsingBlockingPage::FinishMalwareDetails(int64 delay_ms) {
757 if (malware_details_.get() == NULL) 670 if (malware_details_.get() == NULL)
758 return; // Not all interstitials have malware details (eg phishing). 671 return; // Not all interstitials have malware details (eg phishing).
759 672
760 const bool enabled = 673 const bool enabled =
761 IsPrefEnabled(prefs::kSafeBrowsingExtendedReportingEnabled); 674 IsPrefEnabled(prefs::kSafeBrowsingExtendedReportingEnabled);
762 UMA_HISTOGRAM_BOOLEAN("SB2.ExtendedReportingIsEnabled", enabled); 675 UMA_HISTOGRAM_BOOLEAN("SB2.ExtendedReportingIsEnabled", enabled);
763 if (enabled) { 676 if (enabled) {
764 // Finish the malware details collection, send it over. 677 // Finish the malware details collection, send it over.
765 BrowserThread::PostDelayedTask( 678 BrowserThread::PostDelayedTask(
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
872 l10n_util::GetStringUTF16(IDS_SAFEBROWSING_OVERRIDABLE_SAFETY_BUTTON)); 785 l10n_util::GetStringUTF16(IDS_SAFEBROWSING_OVERRIDABLE_SAFETY_BUTTON));
873 load_time_data.SetBoolean( 786 load_time_data.SetBoolean(
874 "overridable", 787 "overridable",
875 !IsPrefEnabled(prefs::kSafeBrowsingProceedAnywayDisabled)); 788 !IsPrefEnabled(prefs::kSafeBrowsingProceedAnywayDisabled));
876 789
877 if (interstitial_type_ == TYPE_PHISHING) 790 if (interstitial_type_ == TYPE_PHISHING)
878 PopulatePhishingLoadTimeData(&load_time_data); 791 PopulatePhishingLoadTimeData(&load_time_data);
879 else 792 else
880 PopulateMalwareLoadTimeData(&load_time_data); 793 PopulateMalwareLoadTimeData(&load_time_data);
881 794
882 interstitial_show_time_ = base::TimeTicks::Now();
883
884 base::StringPiece html( 795 base::StringPiece html(
885 ResourceBundle::GetSharedInstance().GetRawDataResource( 796 ResourceBundle::GetSharedInstance().GetRawDataResource(
886 IRD_SECURITY_INTERSTITIAL_HTML)); 797 IRD_SECURITY_INTERSTITIAL_HTML));
887 webui::UseVersion2 version; 798 webui::UseVersion2 version;
888 return webui::GetI18nTemplateHtml(html, &load_time_data); 799 return webui::GetI18nTemplateHtml(html, &load_time_data);
889 } 800 }
890 801
891 void SafeBrowsingBlockingPage::PopulateMalwareLoadTimeData( 802 void SafeBrowsingBlockingPage::PopulateMalwareLoadTimeData(
892 base::DictionaryValue* load_time_data) { 803 base::DictionaryValue* load_time_data) {
893 load_time_data->SetBoolean("phishing", false); 804 load_time_data->SetBoolean("phishing", false);
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
940 IDS_PHISHING_V3_PRIMARY_PARAGRAPH, 851 IDS_PHISHING_V3_PRIMARY_PARAGRAPH,
941 base::UTF8ToUTF16(url_.host()))); 852 base::UTF8ToUTF16(url_.host())));
942 load_time_data->SetString( 853 load_time_data->SetString(
943 "explanationParagraph", 854 "explanationParagraph",
944 l10n_util::GetStringFUTF16(IDS_PHISHING_V3_EXPLANATION_PARAGRAPH, 855 l10n_util::GetStringFUTF16(IDS_PHISHING_V3_EXPLANATION_PARAGRAPH,
945 base::UTF8ToUTF16(url_.host()))); 856 base::UTF8ToUTF16(url_.host())));
946 load_time_data->SetString( 857 load_time_data->SetString(
947 "finalParagraph", 858 "finalParagraph",
948 l10n_util::GetStringUTF16(IDS_PHISHING_V3_PROCEED_PARAGRAPH)); 859 l10n_util::GetStringUTF16(IDS_PHISHING_V3_PROCEED_PARAGRAPH));
949 } 860 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698