OLD | NEW |
---|---|
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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
109 static const char* const kBoxChecked = "boxchecked"; | 109 static const char* const kBoxChecked = "boxchecked"; |
110 static const char* const kExpandedSeeMore = "expandedSeeMore"; | 110 static const char* const kExpandedSeeMore = "expandedSeeMore"; |
111 // Special command that we use when the user navigated away from the | 111 // Special command that we use when the user navigated away from the |
112 // page. E.g., closed the tab or the window. This is only used by | 112 // page. E.g., closed the tab or the window. This is only used by |
113 // RecordUserReactionTime. | 113 // RecordUserReactionTime. |
114 static const char* const kNavigatedAwayMetaCommand = "closed"; | 114 static const char* const kNavigatedAwayMetaCommand = "closed"; |
115 | 115 |
116 // static | 116 // static |
117 SafeBrowsingBlockingPageFactory* SafeBrowsingBlockingPage::factory_ = NULL; | 117 SafeBrowsingBlockingPageFactory* SafeBrowsingBlockingPage::factory_ = NULL; |
118 | 118 |
119 static base::LazyInstance<SafeBrowsingBlockingPage::UnsafeResourceMap> | 119 static base::LazyInstance<SafeBrowsingBlockingPage::UnsafeResourceMap> |
James Hawkins
2013/05/06 18:13:57
nit: All of these non-class statics should be adde
felt
2013/05/06 19:47:52
Done.
| |
120 g_unsafe_resource_map = LAZY_INSTANCE_INITIALIZER; | 120 g_unsafe_resource_map = LAZY_INSTANCE_INITIALIZER; |
121 | 121 |
122 namespace { | |
123 | |
124 // These are the conditions for the summer 2013 Finch experiment. | |
125 const char* kMalwareStudyName = "InterstitialMalware310"; | |
126 const char* kPhishingStudyName = "InterstitialPhishing564"; | |
127 const char* kCond1MalwareControl = "cond1MalwareControl"; | |
128 const char* kCond2MalwareNoBrand = "cond2MalwareNoBrand"; | |
129 const char* kCond3PhishingControl = "cond3PhishingControl"; | |
130 const char* kCond4PhishingNoBrand = "cond4PhishingNoBrand"; | |
131 const char* kCond5MalwareOneStep = "cond5MalwareOneStep"; | |
132 const char* kCond6PhishingOneStep = "cond6PhishingOneStep"; | |
133 const char* kCond7MalwareFearMsg = "cond7MalwareFearMsg"; | |
134 const char* kCond8PhishingFearMsg = "cond8PhishingFearMsg"; | |
135 const char* kCond9MalwareCollabMsg = "cond9MalwareCollabMsg"; | |
136 const char* kCond10PhishingCollabMsg = "cond10PhishingCollabMsg"; | |
137 const char* kCond11MalwareQuestion = "cond11MalwareQuestion"; | |
138 const char* kCond12PhishingQuestion = "cond12PhishingQuestion"; | |
139 const char* kCond13MalwareGoBack = "cond13MalwareGoBack"; | |
140 const char* kCond14PhishingGoBack = "cond14PhishingGoBack"; | |
141 | |
142 } // namespace | |
James Hawkins
2013/05/06 18:13:57
nit: Two spaces before start of comment.
felt
2013/05/06 19:47:52
Done.
| |
143 | |
144 | |
122 // The default SafeBrowsingBlockingPageFactory. Global, made a singleton so we | 145 // The default SafeBrowsingBlockingPageFactory. Global, made a singleton so we |
123 // don't leak it. | 146 // don't leak it. |
124 class SafeBrowsingBlockingPageFactoryImpl | 147 class SafeBrowsingBlockingPageFactoryImpl |
125 : public SafeBrowsingBlockingPageFactory { | 148 : public SafeBrowsingBlockingPageFactory { |
126 public: | 149 public: |
127 virtual SafeBrowsingBlockingPage* CreateSafeBrowsingPage( | 150 virtual SafeBrowsingBlockingPage* CreateSafeBrowsingPage( |
128 SafeBrowsingUIManager* ui_manager, | 151 SafeBrowsingUIManager* ui_manager, |
129 WebContents* web_contents, | 152 WebContents* web_contents, |
130 const SafeBrowsingBlockingPage::UnsafeResourceList& unsafe_resources) | 153 const SafeBrowsingBlockingPage::UnsafeResourceList& unsafe_resources) |
131 OVERRIDE { | 154 OVERRIDE { |
132 // Only do the trial if the interstitial is for a single malware or | 155 // Only use the V2 page if the interstitial is for a single malware or |
133 // phishing resource, the multi-threat interstitial has not been updated to | 156 // phishing resource, the multi-threat interstitial has not been updated to |
134 // V2 yet. | 157 // V2 yet. |
135 if (unsafe_resources.size() == 1 && | 158 if (unsafe_resources.size() == 1 && |
136 (unsafe_resources[0].threat_type == SB_THREAT_TYPE_URL_MALWARE || | 159 (unsafe_resources[0].threat_type == SB_THREAT_TYPE_URL_MALWARE || |
137 unsafe_resources[0].threat_type == SB_THREAT_TYPE_URL_PHISHING)) { | 160 unsafe_resources[0].threat_type == SB_THREAT_TYPE_URL_PHISHING)) { |
138 return new SafeBrowsingBlockingPageV2(ui_manager, web_contents, | 161 return new SafeBrowsingBlockingPageV2(ui_manager, web_contents, |
139 unsafe_resources); | 162 unsafe_resources); |
140 } | 163 } |
141 return new SafeBrowsingBlockingPageV1(ui_manager, web_contents, | 164 return new SafeBrowsingBlockingPageV1(ui_manager, web_contents, |
142 unsafe_resources); | 165 unsafe_resources); |
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
476 MALWARE_FORCED_DONT_PROCEED, | 499 MALWARE_FORCED_DONT_PROCEED, |
477 MALWARE_PROCEED, | 500 MALWARE_PROCEED, |
478 MULTIPLE_SHOW, | 501 MULTIPLE_SHOW, |
479 MULTIPLE_DONT_PROCEED, | 502 MULTIPLE_DONT_PROCEED, |
480 MULTIPLE_FORCED_DONT_PROCEED, | 503 MULTIPLE_FORCED_DONT_PROCEED, |
481 MULTIPLE_PROCEED, | 504 MULTIPLE_PROCEED, |
482 PHISHING_SHOW, | 505 PHISHING_SHOW, |
483 PHISHING_DONT_PROCEED, | 506 PHISHING_DONT_PROCEED, |
484 PHISHING_FORCED_DONT_PROCEED, | 507 PHISHING_FORCED_DONT_PROCEED, |
485 PHISHING_PROCEED, | 508 PHISHING_PROCEED, |
509 MALWARE_SHOW_ADVANCED, | |
510 MULTIPLE_SHOW_ADVANCED, | |
511 PHISHING_SHOW_ADVANCED, | |
486 MAX_ACTION | 512 MAX_ACTION |
487 } histogram_action = MAX_ACTION; | 513 } histogram_action = MAX_ACTION; |
488 | 514 |
489 switch (event) { | 515 switch (event) { |
490 case SHOW: | 516 case SHOW: |
491 switch (interstitial_type_) { | 517 switch (interstitial_type_) { |
492 case TYPE_MALWARE_AND_PHISHING: | 518 case TYPE_MALWARE_AND_PHISHING: |
493 histogram_action = MULTIPLE_SHOW; | 519 histogram_action = MULTIPLE_SHOW; |
494 break; | 520 break; |
495 case TYPE_MALWARE: | 521 case TYPE_MALWARE: |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
533 break; | 559 break; |
534 case TYPE_MALWARE: | 560 case TYPE_MALWARE: |
535 histogram_action = MALWARE_DONT_PROCEED; | 561 histogram_action = MALWARE_DONT_PROCEED; |
536 break; | 562 break; |
537 case TYPE_PHISHING: | 563 case TYPE_PHISHING: |
538 histogram_action = PHISHING_DONT_PROCEED; | 564 histogram_action = PHISHING_DONT_PROCEED; |
539 break; | 565 break; |
540 } | 566 } |
541 } | 567 } |
542 break; | 568 break; |
569 case SHOW_ADVANCED: | |
570 switch (interstitial_type_) { | |
571 case TYPE_MALWARE_AND_PHISHING: | |
572 histogram_action = MULTIPLE_SHOW_ADVANCED; | |
573 break; | |
574 case TYPE_MALWARE: | |
575 histogram_action = MALWARE_SHOW_ADVANCED; | |
576 break; | |
577 case TYPE_PHISHING: | |
578 histogram_action = PHISHING_SHOW_ADVANCED; | |
579 break; | |
580 } | |
581 break; | |
543 default: | 582 default: |
544 NOTREACHED() << "Unexpected event: " << event; | 583 NOTREACHED() << "Unexpected event: " << event; |
545 } | 584 } |
546 if (histogram_action == MAX_ACTION) { | 585 if (histogram_action == MAX_ACTION) { |
547 NOTREACHED(); | 586 NOTREACHED(); |
548 } else { | 587 } else { |
549 UMA_HISTOGRAM_ENUMERATION("SB2.InterstitialAction", histogram_action, | 588 UMA_HISTOGRAM_ENUMERATION("SB2.InterstitialAction", histogram_action, |
550 MAX_ACTION); | 589 MAX_ACTION); |
551 } | 590 } |
552 | 591 |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
612 } else if (command == kLearnMoreCommand || command == kLearnMoreCommandV2) { | 651 } else if (command == kLearnMoreCommand || command == kLearnMoreCommandV2) { |
613 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.MalwareInterstitialLearnMore", | 652 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.MalwareInterstitialLearnMore", |
614 dt); | 653 dt); |
615 } else if (command == kNavigatedAwayMetaCommand) { | 654 } else if (command == kNavigatedAwayMetaCommand) { |
616 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.MalwareInterstitialTimeClosed", dt); | 655 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.MalwareInterstitialTimeClosed", dt); |
617 } else if (command == kExpandedSeeMore) { | 656 } else if (command == kExpandedSeeMore) { |
618 // Only record the expanded histogram once per display of the | 657 // Only record the expanded histogram once per display of the |
619 // interstitial. | 658 // interstitial. |
620 if (has_expanded_see_more_section_) | 659 if (has_expanded_see_more_section_) |
621 return; | 660 return; |
622 | 661 RecordUserAction(SHOW_ADVANCED); |
623 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.MalwareInterstitialTimeExpandedSeeMore", | 662 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.MalwareInterstitialTimeExpandedSeeMore", |
624 dt); | 663 dt); |
625 has_expanded_see_more_section_ = true; | 664 has_expanded_see_more_section_ = true; |
626 // Expanding the "See More" section doesn't finish the interstitial, so | 665 // Expanding the "See More" section doesn't finish the interstitial, so |
627 // don't mark the reaction time as recorded. | 666 // don't mark the reaction time as recorded. |
628 recorded = false; | 667 recorded = false; |
629 } else { | 668 } else { |
630 recorded = false; | 669 recorded = false; |
631 } | 670 } |
632 } else { | 671 } else { |
633 // Same as above but for phishing warnings. | 672 // Same as above but for phishing warnings. |
634 if (command == kProceedCommand) { | 673 if (command == kProceedCommand) { |
635 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.PhishingInterstitialTimeProceed", dt); | 674 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.PhishingInterstitialTimeProceed", dt); |
636 } else if (command == kTakeMeBackCommand) { | 675 } else if (command == kTakeMeBackCommand) { |
637 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.PhishingInterstitialTimeTakeMeBack", dt); | 676 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.PhishingInterstitialTimeTakeMeBack", dt); |
638 } else if (command == kShowDiagnosticCommand) { | 677 } else if (command == kShowDiagnosticCommand) { |
639 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.PhishingInterstitialTimeReportError", dt); | 678 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.PhishingInterstitialTimeReportError", dt); |
640 } else if (command == kLearnMoreCommand || command == kLearnMoreCommandV2) { | 679 } else if (command == kLearnMoreCommand || command == kLearnMoreCommandV2) { |
641 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.PhishingInterstitialTimeLearnMore", dt); | 680 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.PhishingInterstitialTimeLearnMore", dt); |
642 } else if (command == kNavigatedAwayMetaCommand) { | 681 } else if (command == kNavigatedAwayMetaCommand) { |
643 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.PhishingInterstitialTimeClosed", dt); | 682 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.PhishingInterstitialTimeClosed", dt); |
644 } else if (command == kExpandedSeeMore) { | 683 } else if (command == kExpandedSeeMore) { |
645 // Only record the expanded histogram once per display of the | 684 // Only record the expanded histogram once per display of the |
646 // interstitial. | 685 // interstitial. |
647 if (has_expanded_see_more_section_) | 686 if (has_expanded_see_more_section_) |
648 return; | 687 return; |
649 | 688 RecordUserAction(SHOW_ADVANCED); |
650 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.PhishingInterstitialTimeExpandedSeeMore", | 689 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.PhishingInterstitialTimeExpandedSeeMore", |
651 dt); | 690 dt); |
652 has_expanded_see_more_section_ = true; | 691 has_expanded_see_more_section_ = true; |
653 // Expanding the "See More" section doesn't finish the interstitial, so | 692 // Expanding the "See More" section doesn't finish the interstitial, so |
654 // don't mark the reaction time as recorded. | 693 // don't mark the reaction time as recorded. |
655 recorded = false; | 694 recorded = false; |
656 } else { | 695 } else { |
657 recorded = false; | 696 recorded = false; |
658 } | 697 } |
659 } | 698 } |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
884 void SafeBrowsingBlockingPageV1::PopulatePhishingStringDictionary( | 923 void SafeBrowsingBlockingPageV1::PopulatePhishingStringDictionary( |
885 DictionaryValue* strings) { | 924 DictionaryValue* strings) { |
886 NOTREACHED(); | 925 NOTREACHED(); |
887 } | 926 } |
888 | 927 |
889 SafeBrowsingBlockingPageV2::SafeBrowsingBlockingPageV2( | 928 SafeBrowsingBlockingPageV2::SafeBrowsingBlockingPageV2( |
890 SafeBrowsingUIManager* ui_manager, | 929 SafeBrowsingUIManager* ui_manager, |
891 WebContents* web_contents, | 930 WebContents* web_contents, |
892 const UnsafeResourceList& unsafe_resources) | 931 const UnsafeResourceList& unsafe_resources) |
893 : SafeBrowsingBlockingPage(ui_manager, web_contents, unsafe_resources) { | 932 : SafeBrowsingBlockingPage(ui_manager, web_contents, unsafe_resources) { |
933 if (unsafe_resources_[0].threat_type == SB_THREAT_TYPE_URL_MALWARE) { | |
934 trialCondition_ = | |
935 base::FieldTrialList::FindFullName(kMalwareStudyName); | |
936 } else if (unsafe_resources_[0].threat_type == | |
937 SB_THREAT_TYPE_URL_PHISHING || | |
938 unsafe_resources_[0].threat_type == | |
939 SB_THREAT_TYPE_CLIENT_SIDE_PHISHING_URL) { | |
940 trialCondition_ = | |
941 base::FieldTrialList::FindFullName(kPhishingStudyName); | |
942 } | |
894 } | 943 } |
895 | 944 |
896 std::string SafeBrowsingBlockingPageV2::GetHTMLContents() { | 945 std::string SafeBrowsingBlockingPageV2::GetHTMLContents() { |
897 // Load the HTML page and create the template components. | 946 // Load the HTML page and create the template components. |
898 DictionaryValue strings; | 947 DictionaryValue strings; |
899 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 948 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
900 std::string html; | 949 std::string html; |
901 | 950 |
902 if (unsafe_resources_.empty()) { | 951 if (unsafe_resources_.empty()) { |
903 NOTREACHED(); | 952 NOTREACHED(); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
941 strings->SetBoolean("isMainFrame", is_main_frame_load_blocked_); | 990 strings->SetBoolean("isMainFrame", is_main_frame_load_blocked_); |
942 strings->SetBoolean("isPhishing", interstitial_type_ == TYPE_PHISHING); | 991 strings->SetBoolean("isPhishing", interstitial_type_ == TYPE_PHISHING); |
943 | 992 |
944 strings->SetString("back_button", | 993 strings->SetString("back_button", |
945 l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MALWARE_BACK_BUTTON)); | 994 l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MALWARE_BACK_BUTTON)); |
946 strings->SetString("seeMore", l10n_util::GetStringUTF16( | 995 strings->SetString("seeMore", l10n_util::GetStringUTF16( |
947 IDS_SAFE_BROWSING_MALWARE_V2_SEE_MORE)); | 996 IDS_SAFE_BROWSING_MALWARE_V2_SEE_MORE)); |
948 strings->SetString("proceed", | 997 strings->SetString("proceed", |
949 l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MALWARE_V2_PROCEED_LINK)); | 998 l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MALWARE_V2_PROCEED_LINK)); |
950 | 999 |
1000 // Field trial | |
1001 strings->SetString("trialType", trialCondition_); | |
1002 if (trialCondition_ == kCond7MalwareFearMsg) { | |
1003 strings->SetString("headLine", | |
1004 l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MALWARE_FEAR_HEADLINE)); | |
1005 } else if (trialCondition_ == kCond8PhishingFearMsg) { | |
1006 strings->SetString("headLine", | |
1007 l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_PHISHING_FEAR_HEADLINE)); | |
1008 } else if (trialCondition_ == kCond9MalwareCollabMsg) { | |
1009 strings->SetString("headLine", | |
1010 l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MALWARE_COLLAB_HEADLINE)); | |
1011 } else if (trialCondition_ == kCond10PhishingCollabMsg) { | |
1012 strings->SetString("headLine", | |
1013 l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_PHISHING_COLLAB_HEADLINE)); | |
1014 } else if (trialCondition_ == kCond11MalwareQuestion) { | |
1015 strings->SetString("headLine", | |
1016 l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MALWARE_QUESTION_HEADLINE)); | |
1017 } else if (trialCondition_ == kCond12PhishingQuestion) { | |
1018 strings->SetString("headLine", | |
1019 l10n_util::GetStringUTF16( | |
1020 IDS_SAFE_BROWSING_PHISHING_QUESTION_HEADLINE)); | |
1021 } else if (trialCondition_ == kCond13MalwareGoBack) { | |
1022 strings->SetString("headLine", | |
1023 l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MALWARE_BACK_HEADLINE)); | |
1024 } else if (trialCondition_ == kCond14PhishingGoBack) { | |
1025 strings->SetString("headLine", | |
1026 l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_PHISHING_BACK_HEADLINE)); | |
1027 } | |
1028 | |
951 webui::SetFontAndTextDirection(strings); | 1029 webui::SetFontAndTextDirection(strings); |
952 } | 1030 } |
953 | 1031 |
954 void SafeBrowsingBlockingPageV2::PopulateMultipleThreatStringDictionary( | 1032 void SafeBrowsingBlockingPageV2::PopulateMultipleThreatStringDictionary( |
955 DictionaryValue* strings) { | 1033 DictionaryValue* strings) { |
956 NOTREACHED(); | 1034 NOTREACHED(); |
957 } | 1035 } |
958 | 1036 |
959 void SafeBrowsingBlockingPageV2::PopulateMalwareStringDictionary( | 1037 void SafeBrowsingBlockingPageV2::PopulateMalwareStringDictionary( |
960 DictionaryValue* strings) { | 1038 DictionaryValue* strings) { |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1045 strings->SetString("details", std::string()); | 1123 strings->SetString("details", std::string()); |
1046 strings->SetString("confirm_text", std::string()); | 1124 strings->SetString("confirm_text", std::string()); |
1047 strings->SetString(kBoxChecked, std::string()); | 1125 strings->SetString(kBoxChecked, std::string()); |
1048 strings->SetString( | 1126 strings->SetString( |
1049 "report_error", | 1127 "report_error", |
1050 l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_PHISHING_V2_REPORT_ERROR)); | 1128 l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_PHISHING_V2_REPORT_ERROR)); |
1051 strings->SetBoolean(kDisplayCheckBox, false); | 1129 strings->SetBoolean(kDisplayCheckBox, false); |
1052 strings->SetString("learnMore", | 1130 strings->SetString("learnMore", |
1053 l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MALWARE_V2_LEARN_MORE)); | 1131 l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MALWARE_V2_LEARN_MORE)); |
1054 } | 1132 } |
OLD | NEW |