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 |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/command_line.h" | |
12 #include "base/i18n/rtl.h" | 13 #include "base/i18n/rtl.h" |
13 #include "base/lazy_instance.h" | 14 #include "base/lazy_instance.h" |
14 #include "base/metrics/field_trial.h" | 15 #include "base/metrics/field_trial.h" |
15 #include "base/metrics/histogram.h" | 16 #include "base/metrics/histogram.h" |
16 #include "base/prefs/pref_service.h" | 17 #include "base/prefs/pref_service.h" |
17 #include "base/strings/string_number_conversions.h" | 18 #include "base/strings/string_number_conversions.h" |
18 #include "base/strings/string_piece.h" | 19 #include "base/strings/string_piece.h" |
19 #include "base/strings/stringprintf.h" | 20 #include "base/strings/stringprintf.h" |
20 #include "base/strings/utf_string_conversions.h" | 21 #include "base/strings/utf_string_conversions.h" |
21 #include "base/time/time.h" | 22 #include "base/time/time.h" |
22 #include "base/values.h" | 23 #include "base/values.h" |
23 #include "chrome/browser/browser_process.h" | 24 #include "chrome/browser/browser_process.h" |
24 #include "chrome/browser/google/google_util.h" | 25 #include "chrome/browser/google/google_util.h" |
25 #include "chrome/browser/history/history_service_factory.h" | 26 #include "chrome/browser/history/history_service_factory.h" |
26 #include "chrome/browser/profiles/profile.h" | 27 #include "chrome/browser/profiles/profile.h" |
27 #include "chrome/browser/renderer_preferences_util.h" | 28 #include "chrome/browser/renderer_preferences_util.h" |
28 #include "chrome/browser/safe_browsing/malware_details.h" | 29 #include "chrome/browser/safe_browsing/malware_details.h" |
29 #include "chrome/browser/safe_browsing/ui_manager.h" | 30 #include "chrome/browser/safe_browsing/ui_manager.h" |
30 #include "chrome/browser/tab_contents/tab_util.h" | 31 #include "chrome/browser/tab_contents/tab_util.h" |
32 #include "chrome/common/chrome_switches.h" | |
31 #include "chrome/common/pref_names.h" | 33 #include "chrome/common/pref_names.h" |
32 #include "chrome/common/url_constants.h" | 34 #include "chrome/common/url_constants.h" |
33 #include "content/public/browser/browser_thread.h" | 35 #include "content/public/browser/browser_thread.h" |
34 #include "content/public/browser/interstitial_page.h" | 36 #include "content/public/browser/interstitial_page.h" |
35 #include "content/public/browser/navigation_controller.h" | 37 #include "content/public/browser/navigation_controller.h" |
36 #include "content/public/browser/user_metrics.h" | 38 #include "content/public/browser/user_metrics.h" |
37 #include "content/public/browser/web_contents.h" | 39 #include "content/public/browser/web_contents.h" |
38 #include "grit/browser_resources.h" | 40 #include "grit/browser_resources.h" |
39 #include "grit/chromium_strings.h" | 41 #include "grit/chromium_strings.h" |
40 #include "grit/generated_resources.h" | 42 #include "grit/generated_resources.h" |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
86 "<a id=\"privacy-link\" href=\"\" onclick=\"sendCommand('showPrivacy'); " | 88 "<a id=\"privacy-link\" href=\"\" onclick=\"sendCommand('showPrivacy'); " |
87 "return false;\" onmousedown=\"return false;\">%s</a>"; | 89 "return false;\" onmousedown=\"return false;\">%s</a>"; |
88 | 90 |
89 // After a malware interstitial where the user opted-in to the report | 91 // After a malware interstitial where the user opted-in to the report |
90 // but clicked "proceed anyway", we delay the call to | 92 // but clicked "proceed anyway", we delay the call to |
91 // MalwareDetails::FinishCollection() by this much time (in | 93 // MalwareDetails::FinishCollection() by this much time (in |
92 // milliseconds). | 94 // milliseconds). |
93 const int64 kMalwareDetailsProceedDelayMilliSeconds = 3000; | 95 const int64 kMalwareDetailsProceedDelayMilliSeconds = 3000; |
94 | 96 |
95 // The commands returned by the page when the user performs an action. | 97 // The commands returned by the page when the user performs an action. |
96 const char kShowDiagnosticCommand[] = "showDiagnostic"; | 98 const char kDoReportCommand[] = "doReport"; |
97 const char kReportErrorCommand[] = "reportError"; | 99 const char kDontReportCommand[] = "dontReport"; |
100 const char kExpandedSeeMoreCommand[] = "expandedSeeMore"; | |
98 const char kLearnMoreCommand[] = "learnMore"; | 101 const char kLearnMoreCommand[] = "learnMore"; |
99 const char kLearnMoreCommandV2[] = "learnMore2"; | 102 const char kLearnMoreCommandV2[] = "learnMore2"; |
103 const char kProceedCommand[] = "proceed"; | |
104 const char kReportErrorCommand[] = "reportError"; | |
105 const char kShowDiagnosticCommand[] = "showDiagnostic"; | |
100 const char kShowPrivacyCommand[] = "showPrivacy"; | 106 const char kShowPrivacyCommand[] = "showPrivacy"; |
101 const char kProceedCommand[] = "proceed"; | |
102 const char kTakeMeBackCommand[] = "takeMeBack"; | 107 const char kTakeMeBackCommand[] = "takeMeBack"; |
103 const char kDoReportCommand[] = "doReport"; | |
104 const char kDontReportCommand[] = "dontReport"; | |
105 const char kDisplayCheckBox[] = "displaycheckbox"; | |
106 const char kBoxChecked[] = "boxchecked"; | |
107 const char kExpandedSeeMore[] = "expandedSeeMore"; | |
108 // Special command that we use when the user navigated away from the | 108 // Special command that we use when the user navigated away from the |
109 // page. E.g., closed the tab or the window. This is only used by | 109 // page. E.g., closed the tab or the window. This is only used by |
110 // RecordUserReactionTime. | 110 // RecordUserReactionTime. |
111 const char kNavigatedAwayMetaCommand[] = "closed"; | 111 const char kNavigatedAwayMetaCommand[] = "closed"; |
112 | 112 |
113 // Other constants used to communicate with the JavaScript. | |
114 const char kBoxChecked[] = "boxchecked"; | |
115 const char kDisplayCheckBox[] = "displaycheckbox"; | |
116 | |
113 base::LazyInstance<SafeBrowsingBlockingPage::UnsafeResourceMap> | 117 base::LazyInstance<SafeBrowsingBlockingPage::UnsafeResourceMap> |
114 g_unsafe_resource_map = LAZY_INSTANCE_INITIALIZER; | 118 g_unsafe_resource_map = LAZY_INSTANCE_INITIALIZER; |
115 | 119 |
116 // These are the conditions for the summer 2013 Finch experiment. | 120 // These are the conditions for the summer 2013 Finch experiment. |
117 // TODO(felt): Get rid of these now that experiment has ended. | 121 // TODO(felt): Get rid of these now that experiment has ended. |
118 const char kMalwareStudyName[] = "InterstitialMalware310"; | 122 const char kMalwareStudyName[] = "InterstitialMalware310"; |
119 const char kPhishingStudyName[] = "InterstitialPhishing564"; | 123 const char kPhishingStudyName[] = "InterstitialPhishing564"; |
120 const char kCond7MalwareFearMsg[] = "cond7MalwareFearMsg"; | 124 const char kCond7MalwareFearMsg[] = "cond7MalwareFearMsg"; |
121 const char kCond8PhishingFearMsg[] = "cond8PhishingFearMsg"; | 125 const char kCond8PhishingFearMsg[] = "cond8PhishingFearMsg"; |
122 const char kCond9MalwareCollabMsg[] = "cond9MalwareCollabMsg"; | 126 const char kCond9MalwareCollabMsg[] = "cond9MalwareCollabMsg"; |
123 const char kCond10PhishingCollabMsg[] = "cond10PhishingCollabMsg"; | 127 const char kCond10PhishingCollabMsg[] = "cond10PhishingCollabMsg"; |
124 const char kCond11MalwareQuestion[] = "cond11MalwareQuestion"; | 128 const char kCond11MalwareQuestion[] = "cond11MalwareQuestion"; |
125 const char kCond12PhishingQuestion[] = "cond12PhishingQuestion"; | 129 const char kCond12PhishingQuestion[] = "cond12PhishingQuestion"; |
126 const char kCond13MalwareGoBack[] = "cond13MalwareGoBack"; | 130 const char kCond13MalwareGoBack[] = "cond13MalwareGoBack"; |
127 const char kCond14PhishingGoBack[] = "cond14PhishingGoBack"; | 131 const char kCond14PhishingGoBack[] = "cond14PhishingGoBack"; |
128 | 132 |
133 // These are the constants for the M37 Finch trial. | |
134 const char kV3StudyName[] = "MalwareInterstitialVersion"; | |
135 const char kCondUseV3[] = "V3"; | |
136 | |
129 // This enum is used for a histogram. Don't reorder, delete, or insert | 137 // This enum is used for a histogram. Don't reorder, delete, or insert |
130 // elements. New elements should be added before MAX_ACTION only. | 138 // elements. New elements should be added before MAX_ACTION only. |
131 enum DetailedDecision { | 139 enum DetailedDecision { |
132 MALWARE_SHOW_NEW_SITE = 0, | 140 MALWARE_SHOW_NEW_SITE = 0, |
133 MALWARE_PROCEED_NEW_SITE, | 141 MALWARE_PROCEED_NEW_SITE, |
134 MALWARE_SHOW_CROSS_SITE, | 142 MALWARE_SHOW_CROSS_SITE, |
135 MALWARE_PROCEED_CROSS_SITE, | 143 MALWARE_PROCEED_CROSS_SITE, |
136 PHISHING_SHOW_NEW_SITE, | 144 PHISHING_SHOW_NEW_SITE, |
137 PHISHING_PROCEED_NEW_SITE, | 145 PHISHING_PROCEED_NEW_SITE, |
138 PHISHING_SHOW_CROSS_SITE, | 146 PHISHING_SHOW_CROSS_SITE, |
139 PHISHING_PROCEED_CROSS_SITE, | 147 PHISHING_PROCEED_CROSS_SITE, |
140 MAX_DETAILED_ACTION | 148 MAX_DETAILED_ACTION |
141 }; | 149 }; |
142 | 150 |
143 void RecordDetailedUserAction(DetailedDecision decision) { | 151 void RecordDetailedUserAction(DetailedDecision decision) { |
144 UMA_HISTOGRAM_ENUMERATION("SB2.InterstitialActionDetails", | 152 UMA_HISTOGRAM_ENUMERATION("SB2.InterstitialActionDetails", |
145 decision, | 153 decision, |
146 MAX_DETAILED_ACTION); | 154 MAX_DETAILED_ACTION); |
147 } | 155 } |
148 | 156 |
157 bool Version3Enabled() { | |
158 if (CommandLine::ForCurrentProcess()->HasSwitch( | |
159 switches::kMalwareInterstitialVersionV3)) { | |
160 return true; | |
161 } | |
162 if (base::FieldTrialList::FindFullName(kV3StudyName) == kCondUseV3) | |
163 return true; | |
mattm
2014/06/11 02:11:45
It might be better not to honor the field trial un
felt
2014/06/11 02:23:29
Good idea, removing the field trial.
| |
164 return false; | |
165 } | |
166 | |
167 class SafeBrowsingBlockingPageV3 : public SafeBrowsingBlockingPage { | |
168 public: | |
169 SafeBrowsingBlockingPageV3(SafeBrowsingUIManager* ui_manager, | |
170 content::WebContents* web_contents, | |
171 const UnsafeResourceList& unsafe_resources); | |
172 | |
173 // InterstitialPageDelegate method: | |
174 virtual std::string GetHTMLContents() OVERRIDE; | |
175 | |
176 private: | |
177 // Fills the passed dictionary with the values to be passed to the template | |
178 // when creating the HTML. | |
179 void PopulateMalwareLoadTimeData(base::DictionaryValue* load_time_data); | |
180 void PopulatePhishingLoadTimeData(base::DictionaryValue* load_time_data); | |
181 | |
182 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingBlockingPageV3); | |
183 }; | |
184 | |
149 } // namespace | 185 } // namespace |
150 | 186 |
151 // static | 187 // static |
152 SafeBrowsingBlockingPageFactory* SafeBrowsingBlockingPage::factory_ = NULL; | 188 SafeBrowsingBlockingPageFactory* SafeBrowsingBlockingPage::factory_ = NULL; |
153 | 189 |
154 // The default SafeBrowsingBlockingPageFactory. Global, made a singleton so we | 190 // The default SafeBrowsingBlockingPageFactory. Global, made a singleton so we |
155 // don't leak it. | 191 // don't leak it. |
156 class SafeBrowsingBlockingPageFactoryImpl | 192 class SafeBrowsingBlockingPageFactoryImpl |
157 : public SafeBrowsingBlockingPageFactory { | 193 : public SafeBrowsingBlockingPageFactory { |
158 public: | 194 public: |
159 virtual SafeBrowsingBlockingPage* CreateSafeBrowsingPage( | 195 virtual SafeBrowsingBlockingPage* CreateSafeBrowsingPage( |
160 SafeBrowsingUIManager* ui_manager, | 196 SafeBrowsingUIManager* ui_manager, |
161 WebContents* web_contents, | 197 WebContents* web_contents, |
162 const SafeBrowsingBlockingPage::UnsafeResourceList& unsafe_resources) | 198 const SafeBrowsingBlockingPage::UnsafeResourceList& unsafe_resources) |
163 OVERRIDE { | 199 OVERRIDE { |
164 // Only use the V2 page if the interstitial is for a single malware or | 200 // Only use the V2 page if the interstitial is for a single malware or |
165 // phishing resource, the multi-threat interstitial has not been updated to | 201 // phishing resource, the multi-threat interstitial has not been updated to |
166 // V2 yet. | 202 // V2 yet. |
167 if (unsafe_resources.size() == 1 && | 203 if (unsafe_resources.size() == 1 && |
168 (unsafe_resources[0].threat_type == SB_THREAT_TYPE_URL_MALWARE || | 204 (unsafe_resources[0].threat_type == SB_THREAT_TYPE_URL_MALWARE || |
169 unsafe_resources[0].threat_type == | 205 unsafe_resources[0].threat_type == |
170 SB_THREAT_TYPE_CLIENT_SIDE_MALWARE_URL || | 206 SB_THREAT_TYPE_CLIENT_SIDE_MALWARE_URL || |
171 unsafe_resources[0].threat_type == SB_THREAT_TYPE_URL_PHISHING || | 207 unsafe_resources[0].threat_type == SB_THREAT_TYPE_URL_PHISHING || |
172 unsafe_resources[0].threat_type == | 208 unsafe_resources[0].threat_type == |
173 SB_THREAT_TYPE_CLIENT_SIDE_PHISHING_URL)) { | 209 SB_THREAT_TYPE_CLIENT_SIDE_PHISHING_URL)) { |
174 return new SafeBrowsingBlockingPageV2(ui_manager, web_contents, | 210 if (Version3Enabled()) { |
175 unsafe_resources); | 211 return new SafeBrowsingBlockingPageV3(ui_manager, web_contents, |
212 unsafe_resources); | |
213 } else { | |
214 return new SafeBrowsingBlockingPageV2(ui_manager, web_contents, | |
215 unsafe_resources); | |
216 } | |
176 } | 217 } |
177 return new SafeBrowsingBlockingPageV1(ui_manager, web_contents, | 218 return new SafeBrowsingBlockingPageV1(ui_manager, web_contents, |
178 unsafe_resources); | 219 unsafe_resources); |
179 } | 220 } |
180 | 221 |
181 private: | 222 private: |
182 friend struct base::DefaultLazyInstanceTraits< | 223 friend struct base::DefaultLazyInstanceTraits< |
183 SafeBrowsingBlockingPageFactoryImpl>; | 224 SafeBrowsingBlockingPageFactoryImpl>; |
184 | 225 |
185 SafeBrowsingBlockingPageFactoryImpl() { } | 226 SafeBrowsingBlockingPageFactoryImpl() { } |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
423 SB_THREAT_TYPE_URL_MALWARE || | 464 SB_THREAT_TYPE_URL_MALWARE || |
424 unsafe_resources_[element_index].threat_type == | 465 unsafe_resources_[element_index].threat_type == |
425 SB_THREAT_TYPE_CLIENT_SIDE_MALWARE_URL); | 466 SB_THREAT_TYPE_CLIENT_SIDE_MALWARE_URL); |
426 OpenURLParams params( | 467 OpenURLParams params( |
427 diagnostic_url, Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_LINK, | 468 diagnostic_url, Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_LINK, |
428 false); | 469 false); |
429 web_contents_->OpenURL(params); | 470 web_contents_->OpenURL(params); |
430 return; | 471 return; |
431 } | 472 } |
432 | 473 |
433 if (command == kExpandedSeeMore) { | 474 if (command == kExpandedSeeMoreCommand) { |
434 // User expanded the "see more info" section of the page. We don't actually | 475 // User expanded the "see more info" section of the page. We don't actually |
435 // do any action based on this, it's just so that RecordUserReactionTime can | 476 // do any action based on this, it's just so that RecordUserReactionTime can |
436 // track it. | 477 // track it. |
437 return; | 478 return; |
438 } | 479 } |
439 | 480 |
440 NOTREACHED() << "Unexpected command: " << command; | 481 NOTREACHED() << "Unexpected command: " << command; |
441 } | 482 } |
442 | 483 |
443 void SafeBrowsingBlockingPage::OverrideRendererPrefs( | 484 void SafeBrowsingBlockingPage::OverrideRendererPrefs( |
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
706 } else if (command == kShowDiagnosticCommand) { | 747 } else if (command == kShowDiagnosticCommand) { |
707 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.MalwareInterstitialTimeDiagnostic", dt); | 748 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.MalwareInterstitialTimeDiagnostic", dt); |
708 } else if (command == kShowPrivacyCommand) { | 749 } else if (command == kShowPrivacyCommand) { |
709 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.MalwareInterstitialTimePrivacyPolicy", | 750 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.MalwareInterstitialTimePrivacyPolicy", |
710 dt); | 751 dt); |
711 } else if (command == kLearnMoreCommand || command == kLearnMoreCommandV2) { | 752 } else if (command == kLearnMoreCommand || command == kLearnMoreCommandV2) { |
712 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.MalwareInterstitialLearnMore", | 753 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.MalwareInterstitialLearnMore", |
713 dt); | 754 dt); |
714 } else if (command == kNavigatedAwayMetaCommand) { | 755 } else if (command == kNavigatedAwayMetaCommand) { |
715 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.MalwareInterstitialTimeClosed", dt); | 756 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.MalwareInterstitialTimeClosed", dt); |
716 } else if (command == kExpandedSeeMore) { | 757 } else if (command == kExpandedSeeMoreCommand) { |
717 // Only record the expanded histogram once per display of the | 758 // Only record the expanded histogram once per display of the |
718 // interstitial. | 759 // interstitial. |
719 if (has_expanded_see_more_section_) | 760 if (has_expanded_see_more_section_) |
720 return; | 761 return; |
721 RecordUserAction(SHOW_ADVANCED); | 762 RecordUserAction(SHOW_ADVANCED); |
722 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.MalwareInterstitialTimeExpandedSeeMore", | 763 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.MalwareInterstitialTimeExpandedSeeMore", |
723 dt); | 764 dt); |
724 has_expanded_see_more_section_ = true; | 765 has_expanded_see_more_section_ = true; |
725 // Expanding the "See More" section doesn't finish the interstitial, so | 766 // Expanding the "See More" section doesn't finish the interstitial, so |
726 // don't mark the reaction time as recorded. | 767 // don't mark the reaction time as recorded. |
727 recorded = false; | 768 recorded = false; |
728 } else { | 769 } else { |
729 recorded = false; | 770 recorded = false; |
730 } | 771 } |
731 } else { | 772 } else { |
732 // Same as above but for phishing warnings. | 773 // Same as above but for phishing warnings. |
733 if (command == kProceedCommand) { | 774 if (command == kProceedCommand) { |
734 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.PhishingInterstitialTimeProceed", dt); | 775 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.PhishingInterstitialTimeProceed", dt); |
735 } else if (command == kTakeMeBackCommand) { | 776 } else if (command == kTakeMeBackCommand) { |
736 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.PhishingInterstitialTimeTakeMeBack", dt); | 777 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.PhishingInterstitialTimeTakeMeBack", dt); |
737 } else if (command == kShowDiagnosticCommand) { | 778 } else if (command == kShowDiagnosticCommand) { |
738 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.PhishingInterstitialTimeReportError", dt); | 779 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.PhishingInterstitialTimeReportError", dt); |
739 } else if (command == kLearnMoreCommand || command == kLearnMoreCommandV2) { | 780 } else if (command == kLearnMoreCommand || command == kLearnMoreCommandV2) { |
740 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.PhishingInterstitialTimeLearnMore", dt); | 781 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.PhishingInterstitialTimeLearnMore", dt); |
741 } else if (command == kNavigatedAwayMetaCommand) { | 782 } else if (command == kNavigatedAwayMetaCommand) { |
742 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.PhishingInterstitialTimeClosed", dt); | 783 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.PhishingInterstitialTimeClosed", dt); |
743 } else if (command == kExpandedSeeMore) { | 784 } else if (command == kExpandedSeeMoreCommand) { |
744 // Only record the expanded histogram once per display of the | 785 // Only record the expanded histogram once per display of the |
745 // interstitial. | 786 // interstitial. |
746 if (has_expanded_see_more_section_) | 787 if (has_expanded_see_more_section_) |
747 return; | 788 return; |
748 RecordUserAction(SHOW_ADVANCED); | 789 RecordUserAction(SHOW_ADVANCED); |
749 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.PhishingInterstitialTimeExpandedSeeMore", | 790 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.PhishingInterstitialTimeExpandedSeeMore", |
750 dt); | 791 dt); |
751 has_expanded_see_more_section_ = true; | 792 has_expanded_see_more_section_ = true; |
752 // Expanding the "See More" section doesn't finish the interstitial, so | 793 // Expanding the "See More" section doesn't finish the interstitial, so |
753 // don't mark the reaction time as recorded. | 794 // don't mark the reaction time as recorded. |
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1185 strings->SetString("details", std::string()); | 1226 strings->SetString("details", std::string()); |
1186 strings->SetString("confirm_text", std::string()); | 1227 strings->SetString("confirm_text", std::string()); |
1187 strings->SetString(kBoxChecked, std::string()); | 1228 strings->SetString(kBoxChecked, std::string()); |
1188 strings->SetString( | 1229 strings->SetString( |
1189 "report_error", | 1230 "report_error", |
1190 l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_PHISHING_V2_REPORT_ERROR)); | 1231 l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_PHISHING_V2_REPORT_ERROR)); |
1191 strings->SetBoolean(kDisplayCheckBox, false); | 1232 strings->SetBoolean(kDisplayCheckBox, false); |
1192 strings->SetString("learnMore", | 1233 strings->SetString("learnMore", |
1193 l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MALWARE_V2_LEARN_MORE)); | 1234 l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MALWARE_V2_LEARN_MORE)); |
1194 } | 1235 } |
1236 | |
1237 SafeBrowsingBlockingPageV3::SafeBrowsingBlockingPageV3( | |
1238 SafeBrowsingUIManager* ui_manager, | |
1239 WebContents* web_contents, | |
1240 const UnsafeResourceList& unsafe_resources) | |
1241 : SafeBrowsingBlockingPage(ui_manager, web_contents, unsafe_resources) { | |
1242 } | |
1243 | |
1244 std::string SafeBrowsingBlockingPageV3::GetHTMLContents() { | |
1245 if (unsafe_resources_.empty() || unsafe_resources_.size() > 1) { | |
1246 // TODO(felt): Implement new multi-threat interstitial. crbug.com/160336 | |
1247 NOTIMPLEMENTED(); | |
1248 return std::string(); | |
1249 } | |
1250 | |
1251 // Fill in the shared values. | |
1252 base::DictionaryValue load_time_data; | |
1253 webui::SetFontAndTextDirection(&load_time_data); | |
1254 load_time_data.SetBoolean("ssl", false); | |
1255 load_time_data.SetString( | |
1256 "openDetails", | |
1257 l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MALWARE_V2_SEE_MORE)); | |
1258 load_time_data.SetString( | |
1259 "closeDetails", | |
1260 l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MALWARE_V2_SEE_MORE)); | |
1261 load_time_data.SetString( | |
1262 "primaryButtonText", | |
1263 l10n_util::GetStringUTF16(IDS_SSL_OVERRIDABLE_SAFETY_BUTTON)); | |
1264 load_time_data.SetString( | |
1265 "proceedText", | |
1266 l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MALWARE_V2_PROCEED_LINK)); | |
1267 load_time_data.SetBoolean( | |
1268 "overridable", | |
1269 !IsPrefEnabled(prefs::kSafeBrowsingProceedAnywayDisabled)); | |
1270 | |
1271 // Fill in the values that are specific to malware or phishing. | |
1272 SBThreatType threat_type = unsafe_resources_[0].threat_type; | |
1273 switch (threat_type) { | |
1274 case SB_THREAT_TYPE_URL_MALWARE: | |
1275 case SB_THREAT_TYPE_CLIENT_SIDE_MALWARE_URL: | |
1276 PopulateMalwareLoadTimeData(&load_time_data); | |
1277 break; | |
1278 case SB_THREAT_TYPE_URL_PHISHING: | |
1279 case SB_THREAT_TYPE_CLIENT_SIDE_PHISHING_URL: | |
1280 PopulatePhishingLoadTimeData(&load_time_data); | |
1281 break; | |
1282 case SB_THREAT_TYPE_SAFE: | |
1283 case SB_THREAT_TYPE_BINARY_MALWARE_URL: | |
1284 case SB_THREAT_TYPE_EXTENSION: | |
1285 NOTREACHED(); | |
1286 } | |
1287 | |
1288 interstitial_show_time_ = base::TimeTicks::Now(); | |
1289 | |
1290 base::StringPiece html( | |
1291 ResourceBundle::GetSharedInstance().GetRawDataResource( | |
1292 IRD_SSL_INTERSTITIAL_V2_HTML)); | |
1293 webui::UseVersion2 version; | |
1294 return webui::GetI18nTemplateHtml(html, &load_time_data); | |
1295 } | |
1296 | |
1297 void SafeBrowsingBlockingPageV3::PopulateMalwareLoadTimeData( | |
1298 base::DictionaryValue* load_time_data) { | |
1299 load_time_data->SetBoolean("phishing", false); | |
1300 load_time_data->SetString( | |
1301 "tabTitle", | |
1302 l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MALWARE_V2_TITLE)); | |
1303 load_time_data->SetString( | |
1304 "heading", | |
1305 l10n_util::GetStringUTF16(is_main_frame_load_blocked_ ? | |
1306 IDS_SAFE_BROWSING_MALWARE_V2_HEADLINE : | |
1307 IDS_SAFE_BROWSING_MALWARE_V2_HEADLINE_SUBRESOURCE)); | |
1308 load_time_data->SetString( | |
1309 "primaryParagraph", | |
1310 l10n_util::GetStringFUTF16( | |
1311 is_main_frame_load_blocked_ ? | |
1312 IDS_SAFE_BROWSING_MALWARE_V2_DESCRIPTION1 : | |
1313 IDS_SAFE_BROWSING_MALWARE_V2_DESCRIPTION1_SUBRESOURCE, | |
1314 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME), | |
1315 base::UTF8ToUTF16(is_main_frame_load_blocked_ ? | |
1316 url_.host() : web_contents_->GetURL().host()))); | |
1317 load_time_data->SetString( | |
1318 "secondParagraph", | |
1319 is_main_frame_load_blocked_ ? | |
1320 l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MALWARE_V2_DESCRIPTION2) : | |
1321 l10n_util::GetStringFUTF16( | |
1322 IDS_SAFE_BROWSING_MALWARE_V2_DESCRIPTION2_SUBRESOURCE, | |
1323 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME), | |
1324 base::UTF8ToUTF16(url_.host()))); | |
1325 load_time_data->SetString( | |
1326 "thirdParagraph", | |
1327 l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MALWARE_V2_DESCRIPTION3)); | |
1328 load_time_data->SetString( | |
1329 "detailsText", | |
1330 is_main_frame_load_blocked_ ? | |
1331 l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MALWARE_V2_DETAILS) : | |
1332 l10n_util::GetStringFUTF16( | |
1333 IDS_SAFE_BROWSING_MALWARE_V2_DETAILS_SUBRESOURCE, | |
1334 base::UTF8ToUTF16(url_.host()))); | |
1335 } | |
1336 | |
1337 void SafeBrowsingBlockingPageV3::PopulatePhishingLoadTimeData( | |
1338 base::DictionaryValue* load_time_data) { | |
1339 load_time_data->SetBoolean("phishing", true); | |
1340 load_time_data->SetString( | |
1341 "tabTitle", | |
1342 l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_PHISHING_V2_TITLE)); | |
1343 load_time_data->SetString( | |
1344 "heading", | |
1345 l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_PHISHING_V2_HEADLINE)); | |
1346 load_time_data->SetString( | |
1347 "primaryParagraph", | |
1348 l10n_util::GetStringFUTF16( | |
1349 IDS_SAFE_BROWSING_PHISHING_V2_DESCRIPTION1, | |
1350 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME), | |
1351 base::UTF8ToUTF16(url_.host()))); | |
1352 load_time_data->SetString( | |
1353 "secondParagraph", | |
1354 l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_PHISHING_V2_DESCRIPTION2)); | |
1355 load_time_data->SetString( | |
1356 "detailsText", | |
1357 l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_PHISHING_V2_REPORT_ERROR)); | |
1358 } | |
OLD | NEW |