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

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: 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 side-by-side diff with in-line comments
Download patch
« 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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..d5f93c767ea3ba6a84479bdb6309ecaeb69ea90e 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"
@@ -93,23 +95,25 @@ const char kPrivacyLinkHtml[] =
const int64 kMalwareDetailsProceedDelayMilliSeconds = 3000;
// The commands returned by the page when the user performs an action.
-const char kShowDiagnosticCommand[] = "showDiagnostic";
-const char kReportErrorCommand[] = "reportError";
+const char kDoReportCommand[] = "doReport";
+const char kDontReportCommand[] = "dontReport";
+const char kExpandedSeeMoreCommand[] = "expandedSeeMore";
const char kLearnMoreCommand[] = "learnMore";
const char kLearnMoreCommandV2[] = "learnMore2";
-const char kShowPrivacyCommand[] = "showPrivacy";
const char kProceedCommand[] = "proceed";
+const char kReportErrorCommand[] = "reportError";
+const char kShowDiagnosticCommand[] = "showDiagnostic";
+const char kShowPrivacyCommand[] = "showPrivacy";
const char kTakeMeBackCommand[] = "takeMeBack";
-const char kDoReportCommand[] = "doReport";
-const char kDontReportCommand[] = "dontReport";
-const char kDisplayCheckBox[] = "displaycheckbox";
-const char kBoxChecked[] = "boxchecked";
-const char kExpandedSeeMore[] = "expandedSeeMore";
// Special command that we use when the user navigated away from the
// page. E.g., closed the tab or the window. This is only used by
// RecordUserReactionTime.
const char kNavigatedAwayMetaCommand[] = "closed";
+// Other constants used to communicate with the JavaScript.
+const char kBoxChecked[] = "boxchecked";
+const char kDisplayCheckBox[] = "displaycheckbox";
+
base::LazyInstance<SafeBrowsingBlockingPage::UnsafeResourceMap>
g_unsafe_resource_map = LAZY_INSTANCE_INITIALIZER;
@@ -146,6 +150,32 @@ void RecordDetailedUserAction(DetailedDecision decision) {
MAX_DETAILED_ACTION);
}
+bool Version3Enabled() {
+ if (CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kMalwareInterstitialVersionV3)) {
+ return true;
+ }
+ return false;
+}
+
+class SafeBrowsingBlockingPageV3 : public SafeBrowsingBlockingPage {
+ public:
+ SafeBrowsingBlockingPageV3(SafeBrowsingUIManager* ui_manager,
+ content::WebContents* web_contents,
+ const UnsafeResourceList& unsafe_resources);
+
+ // InterstitialPageDelegate method:
+ virtual std::string GetHTMLContents() OVERRIDE;
+
+ private:
+ // Fills the passed dictionary with the values to be passed to the template
+ // when creating the HTML.
+ void PopulateMalwareLoadTimeData(base::DictionaryValue* load_time_data);
+ void PopulatePhishingLoadTimeData(base::DictionaryValue* load_time_data);
+
+ DISALLOW_COPY_AND_ASSIGN(SafeBrowsingBlockingPageV3);
+};
+
} // namespace
// static
@@ -171,8 +201,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);
@@ -430,7 +465,7 @@ void SafeBrowsingBlockingPage::CommandReceived(const std::string& cmd) {
return;
}
- if (command == kExpandedSeeMore) {
+ if (command == kExpandedSeeMoreCommand) {
// User expanded the "see more info" section of the page. We don't actually
// do any action based on this, it's just so that RecordUserReactionTime can
// track it.
@@ -713,7 +748,7 @@ void SafeBrowsingBlockingPage::RecordUserReactionTime(
dt);
} else if (command == kNavigatedAwayMetaCommand) {
UMA_HISTOGRAM_MEDIUM_TIMES("SB2.MalwareInterstitialTimeClosed", dt);
- } else if (command == kExpandedSeeMore) {
+ } else if (command == kExpandedSeeMoreCommand) {
// Only record the expanded histogram once per display of the
// interstitial.
if (has_expanded_see_more_section_)
@@ -740,7 +775,7 @@ void SafeBrowsingBlockingPage::RecordUserReactionTime(
UMA_HISTOGRAM_MEDIUM_TIMES("SB2.PhishingInterstitialTimeLearnMore", dt);
} else if (command == kNavigatedAwayMetaCommand) {
UMA_HISTOGRAM_MEDIUM_TIMES("SB2.PhishingInterstitialTimeClosed", dt);
- } else if (command == kExpandedSeeMore) {
+ } else if (command == kExpandedSeeMoreCommand) {
// Only record the expanded histogram once per display of the
// interstitial.
if (has_expanded_see_more_section_)
@@ -1192,3 +1227,126 @@ 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) {
+}
+
+std::string SafeBrowsingBlockingPageV3::GetHTMLContents() {
+ if (unsafe_resources_.empty() || unsafe_resources_.size() > 1) {
+ // TODO(felt): Implement new multi-threat interstitial. crbug.com/160336
+ NOTIMPLEMENTED();
+ return std::string();
+ }
+
+ // Fill in the shared values.
+ base::DictionaryValue load_time_data;
+ 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;
+ switch (threat_type) {
+ case SB_THREAT_TYPE_URL_MALWARE:
+ case SB_THREAT_TYPE_CLIENT_SIDE_MALWARE_URL:
+ PopulateMalwareLoadTimeData(&load_time_data);
+ break;
+ case SB_THREAT_TYPE_URL_PHISHING:
+ case SB_THREAT_TYPE_CLIENT_SIDE_PHISHING_URL:
+ PopulatePhishingLoadTimeData(&load_time_data);
+ break;
+ case SB_THREAT_TYPE_SAFE:
+ case SB_THREAT_TYPE_BINARY_MALWARE_URL:
+ case SB_THREAT_TYPE_EXTENSION:
+ NOTREACHED();
+ }
+
+ 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_PHISHING_V2_DESCRIPTION2));
+ load_time_data->SetString(
+ "detailsText",
+ l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_PHISHING_V2_REPORT_ERROR));
+}
« 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