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

Unified 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: Pre-review style fixes 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/safe_browsing/safe_browsing_blocking_page.cc
diff --git a/chrome/browser/safe_browsing/safe_browsing_blocking_page.cc b/chrome/browser/safe_browsing/safe_browsing_blocking_page.cc
index c5b4c449b0d539b87804e0550ea47bfb989e208e..3c8733976ee3e93b24bba82994757b441e8573c2 100644
--- a/chrome/browser/safe_browsing/safe_browsing_blocking_page.cc
+++ b/chrome/browser/safe_browsing/safe_browsing_blocking_page.cc
@@ -9,6 +9,7 @@
#include <string>
#include "base/bind.h"
+#include "base/command_line.h"
#include "base/i18n/rtl.h"
#include "base/lazy_instance.h"
#include "base/metrics/field_trial.h"
@@ -28,6 +29,7 @@
#include "chrome/browser/safe_browsing/malware_details.h"
#include "chrome/browser/safe_browsing/ui_manager.h"
#include "chrome/browser/tab_contents/tab_util.h"
+#include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/url_constants.h"
#include "content/public/browser/browser_thread.h"
@@ -146,6 +148,16 @@ void RecordDetailedUserAction(DetailedDecision decision) {
MAX_DETAILED_ACTION);
}
+bool Version3Enabled() {
+ if (CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kMalwareInterstitialVersionV3) ||
+ base::FieldTrialList::FindFullName("MalwareInterstitialVersion")
+ == "V3") {
+ return true;
Bernhard Bauer 2014/06/09 10:04:03 You could split these individual conditions up and
felt 2014/06/09 14:24:09 Done.
+ }
+ return false;
+}
+
} // namespace
// static
@@ -171,8 +183,13 @@ class SafeBrowsingBlockingPageFactoryImpl
unsafe_resources[0].threat_type == SB_THREAT_TYPE_URL_PHISHING ||
unsafe_resources[0].threat_type ==
SB_THREAT_TYPE_CLIENT_SIDE_PHISHING_URL)) {
- return new SafeBrowsingBlockingPageV2(ui_manager, web_contents,
- unsafe_resources);
+ if (Version3Enabled()) {
+ return new SafeBrowsingBlockingPageV3(ui_manager, web_contents,
+ unsafe_resources);
+ } else {
+ return new SafeBrowsingBlockingPageV2(ui_manager, web_contents,
+ unsafe_resources);
+ }
}
return new SafeBrowsingBlockingPageV1(ui_manager, web_contents,
unsafe_resources);
@@ -1192,3 +1209,122 @@ void SafeBrowsingBlockingPageV2::PopulatePhishingStringDictionary(
strings->SetString("learnMore",
l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MALWARE_V2_LEARN_MORE));
}
+
+SafeBrowsingBlockingPageV3::SafeBrowsingBlockingPageV3(
+ SafeBrowsingUIManager* ui_manager,
+ WebContents* web_contents,
+ const UnsafeResourceList& unsafe_resources)
+ : SafeBrowsingBlockingPage(ui_manager, web_contents, unsafe_resources) {
Bernhard Bauer 2014/06/09 10:04:03 Indent two more spaces.
felt 2014/06/09 14:24:09 Done.
+}
+
+std::string SafeBrowsingBlockingPageV3::GetHTMLContents() {
+ if (unsafe_resources_.empty() || unsafe_resources_.size() > 1) {
+ // TODO(felt): Implement new multi-threat interstitial. crbug.com/160336
+ NOTREACHED();
Bernhard Bauer 2014/06/09 10:04:03 When is this branch reached? If you want to expres
felt 2014/06/09 14:24:09 That can happen if a page is marked as both malwar
Bernhard Bauer 2014/06/09 14:45:41 OK... the usual way would be to DCHECK this instea
+ return std::string();
+ }
+
+ // Fill in the shared values.
+ base::DictionaryValue load_time_data;
+ bool rtl = base::i18n::IsRTL();
+ load_time_data.SetString("textDirection", rtl ? "rtl" : "ltr");
Bernhard Bauer 2014/06/09 10:04:03 Doesn't SetFontAndTextDirection already set this?
felt 2014/06/09 14:24:09 Done.
+ webui::SetFontAndTextDirection(&load_time_data);
+ load_time_data.SetBoolean("ssl", false);
+ load_time_data.SetString(
+ "openDetails",
+ l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MALWARE_V2_SEE_MORE));
+ load_time_data.SetString(
+ "closeDetails",
+ l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MALWARE_V2_SEE_MORE));
+ load_time_data.SetString(
+ "primaryButtonText",
+ l10n_util::GetStringUTF16(IDS_SSL_OVERRIDABLE_SAFETY_BUTTON));
+ load_time_data.SetString(
+ "proceedText",
+ l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MALWARE_V2_PROCEED_LINK));
+ load_time_data.SetBoolean(
+ "overridable",
+ !IsPrefEnabled(prefs::kSafeBrowsingProceedAnywayDisabled));
+
+ // Fill in the values that are specific to malware or phishing.
+ SBThreatType threat_type = unsafe_resources_[0].threat_type;
+ if (threat_type == SB_THREAT_TYPE_URL_MALWARE ||
+ threat_type == SB_THREAT_TYPE_CLIENT_SIDE_MALWARE_URL) {
+ PopulateMalwareLoadTimeData(&load_time_data);
+ } else { // Phishing.
+ DCHECK(threat_type == SB_THREAT_TYPE_URL_PHISHING ||
+ threat_type == SB_THREAT_TYPE_CLIENT_SIDE_PHISHING_URL);
Bernhard Bauer 2014/06/09 10:04:03 How many threat types are there? Could you replace
felt 2014/06/09 14:24:09 Done.
+ PopulatePhishingLoadTimeData(&load_time_data);
+ }
+
+ interstitial_show_time_ = base::TimeTicks::Now();
+
+ base::StringPiece html(
+ ResourceBundle::GetSharedInstance().GetRawDataResource(
+ IRD_SSL_INTERSTITIAL_V2_HTML));
+ webui::UseVersion2 version;
+ return webui::GetI18nTemplateHtml(html, &load_time_data);
+}
+
+void SafeBrowsingBlockingPageV3::PopulateMalwareLoadTimeData(
+ base::DictionaryValue* load_time_data) {
+ load_time_data->SetBoolean("phishing", false);
+ load_time_data->SetString(
+ "tabTitle",
+ l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MALWARE_V2_TITLE));
+ load_time_data->SetString(
+ "heading",
+ l10n_util::GetStringUTF16(is_main_frame_load_blocked_ ?
+ IDS_SAFE_BROWSING_MALWARE_V2_HEADLINE :
+ IDS_SAFE_BROWSING_MALWARE_V2_HEADLINE_SUBRESOURCE));
+ load_time_data->SetString(
+ "primaryParagraph",
+ l10n_util::GetStringFUTF16(
+ is_main_frame_load_blocked_ ?
+ IDS_SAFE_BROWSING_MALWARE_V2_DESCRIPTION1 :
+ IDS_SAFE_BROWSING_MALWARE_V2_DESCRIPTION1_SUBRESOURCE,
+ l10n_util::GetStringUTF16(IDS_PRODUCT_NAME),
+ base::UTF8ToUTF16(is_main_frame_load_blocked_ ?
+ url_.host() : web_contents_->GetURL().host())));
+ load_time_data->SetString(
+ "secondParagraph",
+ is_main_frame_load_blocked_ ?
+ l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MALWARE_V2_DESCRIPTION2) :
+ l10n_util::GetStringFUTF16(
+ IDS_SAFE_BROWSING_MALWARE_V2_DESCRIPTION2_SUBRESOURCE,
+ l10n_util::GetStringUTF16(IDS_PRODUCT_NAME),
+ base::UTF8ToUTF16(url_.host())));
+ load_time_data->SetString(
+ "thirdParagraph",
+ l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MALWARE_V2_DESCRIPTION3));
+ load_time_data->SetString(
+ "detailsText",
+ is_main_frame_load_blocked_ ?
+ l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MALWARE_V2_DETAILS) :
+ l10n_util::GetStringFUTF16(
+ IDS_SAFE_BROWSING_MALWARE_V2_DETAILS_SUBRESOURCE,
+ base::UTF8ToUTF16(url_.host())));
+}
+
+void SafeBrowsingBlockingPageV3::PopulatePhishingLoadTimeData(
+ base::DictionaryValue* load_time_data) {
+ load_time_data->SetBoolean("phishing", true);
+ load_time_data->SetString(
+ "tabTitle",
+ l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_PHISHING_V2_TITLE));
+ load_time_data->SetString(
+ "heading",
+ l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_PHISHING_V2_HEADLINE));
+ load_time_data->SetString(
+ "primaryParagraph",
+ l10n_util::GetStringFUTF16(
+ IDS_SAFE_BROWSING_PHISHING_V2_DESCRIPTION1,
+ l10n_util::GetStringUTF16(IDS_PRODUCT_NAME),
+ base::UTF8ToUTF16(url_.host())));
+ load_time_data->SetString(
+ "secondParagraph",
+ l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MALWARE_V2_DESCRIPTION2));
+ load_time_data->SetString(
+ "detailsText",
+ l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_PHISHING_V2_REPORT_ERROR));
+}

Powered by Google App Engine
This is Rietveld 408576698