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

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

Issue 319193002: Update the malware interstitial to have the new layout (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased again Created 6 years, 6 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 | Annotate | Revision Log
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
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
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";
(...skipping 16 matching lines...) Expand all
139 PHISHING_PROCEED_CROSS_SITE, 143 PHISHING_PROCEED_CROSS_SITE,
140 MAX_DETAILED_ACTION 144 MAX_DETAILED_ACTION
141 }; 145 };
142 146
143 void RecordDetailedUserAction(DetailedDecision decision) { 147 void RecordDetailedUserAction(DetailedDecision decision) {
144 UMA_HISTOGRAM_ENUMERATION("SB2.InterstitialActionDetails", 148 UMA_HISTOGRAM_ENUMERATION("SB2.InterstitialActionDetails",
145 decision, 149 decision,
146 MAX_DETAILED_ACTION); 150 MAX_DETAILED_ACTION);
147 } 151 }
148 152
153 bool Version3Enabled() {
154 if (CommandLine::ForCurrentProcess()->HasSwitch(
155 switches::kMalwareInterstitialVersionV3)) {
156 return true;
157 }
158 return false;
159 }
160
161 class SafeBrowsingBlockingPageV3 : public SafeBrowsingBlockingPage {
162 public:
163 SafeBrowsingBlockingPageV3(SafeBrowsingUIManager* ui_manager,
164 content::WebContents* web_contents,
165 const UnsafeResourceList& unsafe_resources);
166
167 // InterstitialPageDelegate method:
168 virtual std::string GetHTMLContents() OVERRIDE;
169
170 private:
171 // Fills the passed dictionary with the values to be passed to the template
172 // when creating the HTML.
173 void PopulateMalwareLoadTimeData(base::DictionaryValue* load_time_data);
174 void PopulatePhishingLoadTimeData(base::DictionaryValue* load_time_data);
175
176 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingBlockingPageV3);
177 };
178
149 } // namespace 179 } // namespace
150 180
151 // static 181 // static
152 SafeBrowsingBlockingPageFactory* SafeBrowsingBlockingPage::factory_ = NULL; 182 SafeBrowsingBlockingPageFactory* SafeBrowsingBlockingPage::factory_ = NULL;
153 183
154 // The default SafeBrowsingBlockingPageFactory. Global, made a singleton so we 184 // The default SafeBrowsingBlockingPageFactory. Global, made a singleton so we
155 // don't leak it. 185 // don't leak it.
156 class SafeBrowsingBlockingPageFactoryImpl 186 class SafeBrowsingBlockingPageFactoryImpl
157 : public SafeBrowsingBlockingPageFactory { 187 : public SafeBrowsingBlockingPageFactory {
158 public: 188 public:
159 virtual SafeBrowsingBlockingPage* CreateSafeBrowsingPage( 189 virtual SafeBrowsingBlockingPage* CreateSafeBrowsingPage(
160 SafeBrowsingUIManager* ui_manager, 190 SafeBrowsingUIManager* ui_manager,
161 WebContents* web_contents, 191 WebContents* web_contents,
162 const SafeBrowsingBlockingPage::UnsafeResourceList& unsafe_resources) 192 const SafeBrowsingBlockingPage::UnsafeResourceList& unsafe_resources)
163 OVERRIDE { 193 OVERRIDE {
164 // Only use the V2 page if the interstitial is for a single malware or 194 // 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 195 // phishing resource, the multi-threat interstitial has not been updated to
166 // V2 yet. 196 // V2 yet.
167 if (unsafe_resources.size() == 1 && 197 if (unsafe_resources.size() == 1 &&
168 (unsafe_resources[0].threat_type == SB_THREAT_TYPE_URL_MALWARE || 198 (unsafe_resources[0].threat_type == SB_THREAT_TYPE_URL_MALWARE ||
169 unsafe_resources[0].threat_type == 199 unsafe_resources[0].threat_type ==
170 SB_THREAT_TYPE_CLIENT_SIDE_MALWARE_URL || 200 SB_THREAT_TYPE_CLIENT_SIDE_MALWARE_URL ||
171 unsafe_resources[0].threat_type == SB_THREAT_TYPE_URL_PHISHING || 201 unsafe_resources[0].threat_type == SB_THREAT_TYPE_URL_PHISHING ||
172 unsafe_resources[0].threat_type == 202 unsafe_resources[0].threat_type ==
173 SB_THREAT_TYPE_CLIENT_SIDE_PHISHING_URL)) { 203 SB_THREAT_TYPE_CLIENT_SIDE_PHISHING_URL)) {
174 return new SafeBrowsingBlockingPageV2(ui_manager, web_contents, 204 if (Version3Enabled()) {
175 unsafe_resources); 205 return new SafeBrowsingBlockingPageV3(ui_manager, web_contents,
206 unsafe_resources);
207 } else {
208 return new SafeBrowsingBlockingPageV2(ui_manager, web_contents,
209 unsafe_resources);
210 }
176 } 211 }
177 return new SafeBrowsingBlockingPageV1(ui_manager, web_contents, 212 return new SafeBrowsingBlockingPageV1(ui_manager, web_contents,
178 unsafe_resources); 213 unsafe_resources);
179 } 214 }
180 215
181 private: 216 private:
182 friend struct base::DefaultLazyInstanceTraits< 217 friend struct base::DefaultLazyInstanceTraits<
183 SafeBrowsingBlockingPageFactoryImpl>; 218 SafeBrowsingBlockingPageFactoryImpl>;
184 219
185 SafeBrowsingBlockingPageFactoryImpl() { } 220 SafeBrowsingBlockingPageFactoryImpl() { }
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 SB_THREAT_TYPE_URL_MALWARE || 458 SB_THREAT_TYPE_URL_MALWARE ||
424 unsafe_resources_[element_index].threat_type == 459 unsafe_resources_[element_index].threat_type ==
425 SB_THREAT_TYPE_CLIENT_SIDE_MALWARE_URL); 460 SB_THREAT_TYPE_CLIENT_SIDE_MALWARE_URL);
426 OpenURLParams params( 461 OpenURLParams params(
427 diagnostic_url, Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_LINK, 462 diagnostic_url, Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_LINK,
428 false); 463 false);
429 web_contents_->OpenURL(params); 464 web_contents_->OpenURL(params);
430 return; 465 return;
431 } 466 }
432 467
433 if (command == kExpandedSeeMore) { 468 if (command == kExpandedSeeMoreCommand) {
434 // User expanded the "see more info" section of the page. We don't actually 469 // 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 470 // do any action based on this, it's just so that RecordUserReactionTime can
436 // track it. 471 // track it.
437 return; 472 return;
438 } 473 }
439 474
440 NOTREACHED() << "Unexpected command: " << command; 475 NOTREACHED() << "Unexpected command: " << command;
441 } 476 }
442 477
443 void SafeBrowsingBlockingPage::OverrideRendererPrefs( 478 void SafeBrowsingBlockingPage::OverrideRendererPrefs(
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
706 } else if (command == kShowDiagnosticCommand) { 741 } else if (command == kShowDiagnosticCommand) {
707 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.MalwareInterstitialTimeDiagnostic", dt); 742 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.MalwareInterstitialTimeDiagnostic", dt);
708 } else if (command == kShowPrivacyCommand) { 743 } else if (command == kShowPrivacyCommand) {
709 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.MalwareInterstitialTimePrivacyPolicy", 744 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.MalwareInterstitialTimePrivacyPolicy",
710 dt); 745 dt);
711 } else if (command == kLearnMoreCommand || command == kLearnMoreCommandV2) { 746 } else if (command == kLearnMoreCommand || command == kLearnMoreCommandV2) {
712 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.MalwareInterstitialLearnMore", 747 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.MalwareInterstitialLearnMore",
713 dt); 748 dt);
714 } else if (command == kNavigatedAwayMetaCommand) { 749 } else if (command == kNavigatedAwayMetaCommand) {
715 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.MalwareInterstitialTimeClosed", dt); 750 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.MalwareInterstitialTimeClosed", dt);
716 } else if (command == kExpandedSeeMore) { 751 } else if (command == kExpandedSeeMoreCommand) {
717 // Only record the expanded histogram once per display of the 752 // Only record the expanded histogram once per display of the
718 // interstitial. 753 // interstitial.
719 if (has_expanded_see_more_section_) 754 if (has_expanded_see_more_section_)
720 return; 755 return;
721 RecordUserAction(SHOW_ADVANCED); 756 RecordUserAction(SHOW_ADVANCED);
722 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.MalwareInterstitialTimeExpandedSeeMore", 757 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.MalwareInterstitialTimeExpandedSeeMore",
723 dt); 758 dt);
724 has_expanded_see_more_section_ = true; 759 has_expanded_see_more_section_ = true;
725 // Expanding the "See More" section doesn't finish the interstitial, so 760 // Expanding the "See More" section doesn't finish the interstitial, so
726 // don't mark the reaction time as recorded. 761 // don't mark the reaction time as recorded.
727 recorded = false; 762 recorded = false;
728 } else { 763 } else {
729 recorded = false; 764 recorded = false;
730 } 765 }
731 } else { 766 } else {
732 // Same as above but for phishing warnings. 767 // Same as above but for phishing warnings.
733 if (command == kProceedCommand) { 768 if (command == kProceedCommand) {
734 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.PhishingInterstitialTimeProceed", dt); 769 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.PhishingInterstitialTimeProceed", dt);
735 } else if (command == kTakeMeBackCommand) { 770 } else if (command == kTakeMeBackCommand) {
736 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.PhishingInterstitialTimeTakeMeBack", dt); 771 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.PhishingInterstitialTimeTakeMeBack", dt);
737 } else if (command == kShowDiagnosticCommand) { 772 } else if (command == kShowDiagnosticCommand) {
738 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.PhishingInterstitialTimeReportError", dt); 773 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.PhishingInterstitialTimeReportError", dt);
739 } else if (command == kLearnMoreCommand || command == kLearnMoreCommandV2) { 774 } else if (command == kLearnMoreCommand || command == kLearnMoreCommandV2) {
740 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.PhishingInterstitialTimeLearnMore", dt); 775 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.PhishingInterstitialTimeLearnMore", dt);
741 } else if (command == kNavigatedAwayMetaCommand) { 776 } else if (command == kNavigatedAwayMetaCommand) {
742 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.PhishingInterstitialTimeClosed", dt); 777 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.PhishingInterstitialTimeClosed", dt);
743 } else if (command == kExpandedSeeMore) { 778 } else if (command == kExpandedSeeMoreCommand) {
744 // Only record the expanded histogram once per display of the 779 // Only record the expanded histogram once per display of the
745 // interstitial. 780 // interstitial.
746 if (has_expanded_see_more_section_) 781 if (has_expanded_see_more_section_)
747 return; 782 return;
748 RecordUserAction(SHOW_ADVANCED); 783 RecordUserAction(SHOW_ADVANCED);
749 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.PhishingInterstitialTimeExpandedSeeMore", 784 UMA_HISTOGRAM_MEDIUM_TIMES("SB2.PhishingInterstitialTimeExpandedSeeMore",
750 dt); 785 dt);
751 has_expanded_see_more_section_ = true; 786 has_expanded_see_more_section_ = true;
752 // Expanding the "See More" section doesn't finish the interstitial, so 787 // Expanding the "See More" section doesn't finish the interstitial, so
753 // don't mark the reaction time as recorded. 788 // don't mark the reaction time as recorded.
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after
1185 strings->SetString("details", std::string()); 1220 strings->SetString("details", std::string());
1186 strings->SetString("confirm_text", std::string()); 1221 strings->SetString("confirm_text", std::string());
1187 strings->SetString(kBoxChecked, std::string()); 1222 strings->SetString(kBoxChecked, std::string());
1188 strings->SetString( 1223 strings->SetString(
1189 "report_error", 1224 "report_error",
1190 l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_PHISHING_V2_REPORT_ERROR)); 1225 l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_PHISHING_V2_REPORT_ERROR));
1191 strings->SetBoolean(kDisplayCheckBox, false); 1226 strings->SetBoolean(kDisplayCheckBox, false);
1192 strings->SetString("learnMore", 1227 strings->SetString("learnMore",
1193 l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MALWARE_V2_LEARN_MORE)); 1228 l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MALWARE_V2_LEARN_MORE));
1194 } 1229 }
1230
1231 SafeBrowsingBlockingPageV3::SafeBrowsingBlockingPageV3(
1232 SafeBrowsingUIManager* ui_manager,
1233 WebContents* web_contents,
1234 const UnsafeResourceList& unsafe_resources)
1235 : SafeBrowsingBlockingPage(ui_manager, web_contents, unsafe_resources) {
1236 }
1237
1238 std::string SafeBrowsingBlockingPageV3::GetHTMLContents() {
1239 if (unsafe_resources_.empty() || unsafe_resources_.size() > 1) {
1240 // TODO(felt): Implement new multi-threat interstitial. crbug.com/160336
1241 NOTIMPLEMENTED();
1242 return std::string();
1243 }
1244
1245 // Fill in the shared values.
1246 base::DictionaryValue load_time_data;
1247 webui::SetFontAndTextDirection(&load_time_data);
1248 load_time_data.SetBoolean("ssl", false);
1249 load_time_data.SetString(
1250 "openDetails",
1251 l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MALWARE_V2_SEE_MORE));
1252 load_time_data.SetString(
1253 "closeDetails",
1254 l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MALWARE_V2_SEE_MORE));
1255 load_time_data.SetString(
1256 "primaryButtonText",
1257 l10n_util::GetStringUTF16(IDS_SSL_OVERRIDABLE_SAFETY_BUTTON));
1258 load_time_data.SetString(
1259 "proceedText",
1260 l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MALWARE_V2_PROCEED_LINK));
1261 load_time_data.SetBoolean(
1262 "overridable",
1263 !IsPrefEnabled(prefs::kSafeBrowsingProceedAnywayDisabled));
1264
1265 // Fill in the values that are specific to malware or phishing.
1266 SBThreatType threat_type = unsafe_resources_[0].threat_type;
1267 switch (threat_type) {
1268 case SB_THREAT_TYPE_URL_MALWARE:
1269 case SB_THREAT_TYPE_CLIENT_SIDE_MALWARE_URL:
1270 PopulateMalwareLoadTimeData(&load_time_data);
1271 break;
1272 case SB_THREAT_TYPE_URL_PHISHING:
1273 case SB_THREAT_TYPE_CLIENT_SIDE_PHISHING_URL:
1274 PopulatePhishingLoadTimeData(&load_time_data);
1275 break;
1276 case SB_THREAT_TYPE_SAFE:
1277 case SB_THREAT_TYPE_BINARY_MALWARE_URL:
1278 case SB_THREAT_TYPE_EXTENSION:
1279 NOTREACHED();
1280 }
1281
1282 interstitial_show_time_ = base::TimeTicks::Now();
1283
1284 base::StringPiece html(
1285 ResourceBundle::GetSharedInstance().GetRawDataResource(
1286 IRD_SSL_INTERSTITIAL_V2_HTML));
1287 webui::UseVersion2 version;
1288 return webui::GetI18nTemplateHtml(html, &load_time_data);
1289 }
1290
1291 void SafeBrowsingBlockingPageV3::PopulateMalwareLoadTimeData(
1292 base::DictionaryValue* load_time_data) {
1293 load_time_data->SetBoolean("phishing", false);
1294 load_time_data->SetString(
1295 "tabTitle",
1296 l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MALWARE_V2_TITLE));
1297 load_time_data->SetString(
1298 "heading",
1299 l10n_util::GetStringUTF16(is_main_frame_load_blocked_ ?
1300 IDS_SAFE_BROWSING_MALWARE_V2_HEADLINE :
1301 IDS_SAFE_BROWSING_MALWARE_V2_HEADLINE_SUBRESOURCE));
1302 load_time_data->SetString(
1303 "primaryParagraph",
1304 l10n_util::GetStringFUTF16(
1305 is_main_frame_load_blocked_ ?
1306 IDS_SAFE_BROWSING_MALWARE_V2_DESCRIPTION1 :
1307 IDS_SAFE_BROWSING_MALWARE_V2_DESCRIPTION1_SUBRESOURCE,
1308 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME),
1309 base::UTF8ToUTF16(is_main_frame_load_blocked_ ?
1310 url_.host() : web_contents_->GetURL().host())));
1311 load_time_data->SetString(
1312 "secondParagraph",
1313 is_main_frame_load_blocked_ ?
1314 l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MALWARE_V2_DESCRIPTION2) :
1315 l10n_util::GetStringFUTF16(
1316 IDS_SAFE_BROWSING_MALWARE_V2_DESCRIPTION2_SUBRESOURCE,
1317 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME),
1318 base::UTF8ToUTF16(url_.host())));
1319 load_time_data->SetString(
1320 "thirdParagraph",
1321 l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MALWARE_V2_DESCRIPTION3));
1322 load_time_data->SetString(
1323 "detailsText",
1324 is_main_frame_load_blocked_ ?
1325 l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MALWARE_V2_DETAILS) :
1326 l10n_util::GetStringFUTF16(
1327 IDS_SAFE_BROWSING_MALWARE_V2_DETAILS_SUBRESOURCE,
1328 base::UTF8ToUTF16(url_.host())));
1329 }
1330
1331 void SafeBrowsingBlockingPageV3::PopulatePhishingLoadTimeData(
1332 base::DictionaryValue* load_time_data) {
1333 load_time_data->SetBoolean("phishing", true);
1334 load_time_data->SetString(
1335 "tabTitle",
1336 l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_PHISHING_V2_TITLE));
1337 load_time_data->SetString(
1338 "heading",
1339 l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_PHISHING_V2_HEADLINE));
1340 load_time_data->SetString(
1341 "primaryParagraph",
1342 l10n_util::GetStringFUTF16(
1343 IDS_SAFE_BROWSING_PHISHING_V2_DESCRIPTION1,
1344 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME),
1345 base::UTF8ToUTF16(url_.host())));
1346 load_time_data->SetString(
1347 "secondParagraph",
1348 l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_PHISHING_V2_DESCRIPTION2));
1349 load_time_data->SetString(
1350 "detailsText",
1351 l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_PHISHING_V2_REPORT_ERROR));
1352 }
OLDNEW
« no previous file with comments | « chrome/browser/resources/ssl/ssl_errors_common.js ('k') | chrome/browser/ssl/ssl_blocking_page.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698