| 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 4fdc312970e7ad2e925ba4a44366c57ce4f020f8..a12ed72d351d5a99629f748d0ca11c779b77419d 100644
|
| --- a/chrome/browser/safe_browsing/safe_browsing_blocking_page.cc
|
| +++ b/chrome/browser/safe_browsing/safe_browsing_blocking_page.cc
|
| @@ -11,6 +11,7 @@
|
| #include "base/bind.h"
|
| #include "base/i18n/rtl.h"
|
| #include "base/lazy_instance.h"
|
| +#include "base/metrics/field_trial.h"
|
| #include "base/metrics/histogram.h"
|
| #include "base/string_number_conversions.h"
|
| #include "base/string_piece.h"
|
| @@ -36,6 +37,7 @@
|
| #include "content/public/browser/user_metrics.h"
|
| #include "content/public/browser/web_contents.h"
|
| #include "grit/browser_resources.h"
|
| +#include "grit/chromium_strings.h"
|
| #include "grit/generated_resources.h"
|
| #include "grit/locale_settings.h"
|
| #include "net/base/escape.h"
|
| @@ -67,16 +69,13 @@ static const char* const kSbReportPhishingErrorUrl =
|
| static const char* const kLearnMoreMalwareUrl =
|
| "https://www.google.com/support/bin/answer.py?answer=45449&topic=360"
|
| "&sa=X&oi=malwarewarninglink&resnum=1&ct=help";
|
| +static const char* const kLearnMoreMalwareUrlV2 =
|
| + "https://www.google.com/goodtoknow/online-safety/malware/";
|
|
|
| // URL for the "Learn more" link on the phishing blocking page.
|
| static const char* const kLearnMorePhishingUrl =
|
| "https://www.google.com/support/bin/answer.py?answer=106318";
|
|
|
| -// URL for the "Safe Browsing Privacy Policies" link on the blocking page.
|
| -// Note: this page is not yet localized.
|
| -static const char* const kSbPrivacyPolicyUrl =
|
| - "http://www.google.com/intl/en_us/privacy/browsing.html";
|
| -
|
| static const char* const kSbDiagnosticHtml =
|
| "<a href=\"\" onclick=\"sendCommand('showDiagnostic'); return false;\" "
|
| "onmousedown=\"return false;\">%s</a>";
|
| @@ -99,13 +98,16 @@ static const int64 kMalwareDetailsProceedDelayMilliSeconds = 3000;
|
| static const char* const kShowDiagnosticCommand = "showDiagnostic";
|
| static const char* const kReportErrorCommand = "reportError";
|
| static const char* const kLearnMoreCommand = "learnMore";
|
| +static const char* const kLearnMoreCommandV2 = "learnMore2";
|
| static const char* const kShowPrivacyCommand = "showPrivacy";
|
| static const char* const kProceedCommand = "proceed";
|
| static const char* const kTakeMeBackCommand = "takeMeBack";
|
| static const char* const kDoReportCommand = "doReport";
|
| static const char* const kDontReportCommand = "dontReport";
|
| static const char* const kDisplayCheckBox = "displaycheckbox";
|
| +static const char* const kDisplayShowDiagnostic = "displayShowDiagnostic";
|
| static const char* const kBoxChecked = "boxchecked";
|
| +static const char* const 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.
|
| @@ -126,8 +128,19 @@ class SafeBrowsingBlockingPageFactoryImpl
|
| SafeBrowsingService* service,
|
| WebContents* web_contents,
|
| const SafeBrowsingBlockingPage::UnsafeResourceList& unsafe_resources) {
|
| - return new SafeBrowsingBlockingPage(service, web_contents,
|
| - unsafe_resources);
|
| + // Only do the trial if the interstitial is for a single malware resource,
|
| + // the other types of interstitials have not been updated to V2 yet.
|
| + if (unsafe_resources.size() == 1 &&
|
| + unsafe_resources[0].threat_type == SafeBrowsingService::URL_MALWARE) {
|
| + if (base::FieldTrialList::FindFullName("SBInterstitial") == "V2") {
|
| + DVLOG(1) << "In V2 group.";
|
| + return new SafeBrowsingBlockingPageV2(service, web_contents,
|
| + unsafe_resources);
|
| + }
|
| + DVLOG(1) << "In V1 group.";
|
| + }
|
| + return new SafeBrowsingBlockingPageV1(service, web_contents,
|
| + unsafe_resources);
|
| }
|
|
|
| private:
|
| @@ -154,7 +167,29 @@ SafeBrowsingBlockingPage::SafeBrowsingBlockingPage(
|
| unsafe_resources_(unsafe_resources),
|
| proceeded_(false),
|
| web_contents_(web_contents),
|
| - url_(unsafe_resources[0].url) {
|
| + url_(unsafe_resources[0].url),
|
| + has_expanded_see_more_section_(false) {
|
| + bool malware = false;
|
| + bool phishing = false;
|
| + for (UnsafeResourceList::const_iterator iter = unsafe_resources_.begin();
|
| + iter != unsafe_resources_.end(); ++iter) {
|
| + const SafeBrowsingService::UnsafeResource& resource = *iter;
|
| + SafeBrowsingService::UrlCheckResult threat_type = resource.threat_type;
|
| + if (threat_type == SafeBrowsingService::URL_MALWARE) {
|
| + malware = true;
|
| + } else {
|
| + DCHECK(threat_type == SafeBrowsingService::URL_PHISHING ||
|
| + threat_type == SafeBrowsingService::CLIENT_SIDE_PHISHING_URL);
|
| + phishing = true;
|
| + }
|
| + }
|
| + DCHECK(phishing || malware);
|
| + if (malware && phishing)
|
| + interstitial_type_ = TYPE_MALWARE_AND_PHISHING;
|
| + else if (malware)
|
| + interstitial_type_ = TYPE_MALWARE;
|
| + else
|
| + interstitial_type_ = TYPE_PHISHING;
|
| RecordUserAction(SHOW);
|
| if (!is_main_frame_load_blocked_) {
|
| navigation_entry_index_to_remove_ =
|
| @@ -188,242 +223,6 @@ bool SafeBrowsingBlockingPage::CanShowMalwareDetailsOption() {
|
| SafeBrowsingBlockingPage::~SafeBrowsingBlockingPage() {
|
| }
|
|
|
| -std::string SafeBrowsingBlockingPage::GetHTMLContents() {
|
| - // Load the HTML page and create the template components.
|
| - DictionaryValue strings;
|
| - ResourceBundle& rb = ResourceBundle::GetSharedInstance();
|
| - std::string html;
|
| -
|
| - if (unsafe_resources_.empty()) {
|
| - NOTREACHED();
|
| - return std::string();
|
| - }
|
| -
|
| - if (unsafe_resources_.size() > 1) {
|
| - PopulateMultipleThreatStringDictionary(&strings);
|
| - html = rb.GetRawDataResource(
|
| - IDR_SAFE_BROWSING_MULTIPLE_THREAT_BLOCK,
|
| - ui::SCALE_FACTOR_NONE).as_string();
|
| - is_malware_interstitial_ = true;
|
| - } else {
|
| - SafeBrowsingService::UrlCheckResult threat_type =
|
| - unsafe_resources_[0].threat_type;
|
| - if (threat_type == SafeBrowsingService::URL_MALWARE) {
|
| - PopulateMalwareStringDictionary(&strings);
|
| - html = rb.GetRawDataResource(
|
| - IDR_SAFE_BROWSING_MALWARE_BLOCK,
|
| - ui::SCALE_FACTOR_NONE).as_string();
|
| - is_malware_interstitial_ = true;
|
| - } else { // Phishing.
|
| - DCHECK(threat_type == SafeBrowsingService::URL_PHISHING ||
|
| - threat_type == SafeBrowsingService::CLIENT_SIDE_PHISHING_URL);
|
| - PopulatePhishingStringDictionary(&strings);
|
| - html = rb.GetRawDataResource(
|
| - IDR_SAFE_BROWSING_PHISHING_BLOCK,
|
| - ui::SCALE_FACTOR_NONE).as_string();
|
| - is_malware_interstitial_ = false;
|
| - }
|
| - }
|
| - interstitial_show_time_ = base::TimeTicks::Now();
|
| - return jstemplate_builder::GetTemplatesHtml(html, &strings, "template_root");
|
| -}
|
| -
|
| -void SafeBrowsingBlockingPage::PopulateStringDictionary(
|
| - DictionaryValue* strings,
|
| - const string16& title,
|
| - const string16& headline,
|
| - const string16& description1,
|
| - const string16& description2,
|
| - const string16& description3) {
|
| - strings->SetString("title", title);
|
| - strings->SetString("headLine", headline);
|
| - strings->SetString("description1", description1);
|
| - strings->SetString("description2", description2);
|
| - strings->SetString("description3", description3);
|
| - strings->SetBoolean("proceedDisabled",
|
| - IsPrefEnabled(prefs::kSafeBrowsingProceedAnywayDisabled));
|
| -}
|
| -
|
| -void SafeBrowsingBlockingPage::PopulateMultipleThreatStringDictionary(
|
| - DictionaryValue* strings) {
|
| - bool malware = false;
|
| - bool phishing = false;
|
| -
|
| - string16 malware_label =
|
| - l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MALWARE_LABEL);
|
| - string16 malware_link =
|
| - l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MALWARE_DIAGNOSTIC_PAGE);
|
| - string16 phishing_label =
|
| - l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_PHISHING_LABEL);
|
| - string16 phishing_link =
|
| - l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_PHISHING_REPORT_ERROR);
|
| -
|
| - ListValue* error_strings = new ListValue;
|
| - for (UnsafeResourceList::const_iterator iter = unsafe_resources_.begin();
|
| - iter != unsafe_resources_.end(); ++iter) {
|
| - const SafeBrowsingService::UnsafeResource& resource = *iter;
|
| - SafeBrowsingService::UrlCheckResult threat_type = resource.threat_type;
|
| - DictionaryValue* current_error_strings = new DictionaryValue;
|
| - if (threat_type == SafeBrowsingService::URL_MALWARE) {
|
| - malware = true;
|
| - current_error_strings->SetString("type", "malware");
|
| - current_error_strings->SetString("typeLabel", malware_label);
|
| - current_error_strings->SetString("errorLink", malware_link);
|
| - } else {
|
| - DCHECK(threat_type == SafeBrowsingService::URL_PHISHING ||
|
| - threat_type == SafeBrowsingService::CLIENT_SIDE_PHISHING_URL);
|
| - phishing = true;
|
| - current_error_strings->SetString("type", "phishing");
|
| - current_error_strings->SetString("typeLabel", phishing_label);
|
| - current_error_strings->SetString("errorLink", phishing_link);
|
| - }
|
| - current_error_strings->SetString("url", resource.url.spec());
|
| - error_strings->Append(current_error_strings);
|
| - }
|
| - strings->Set("errors", error_strings);
|
| - DCHECK(phishing || malware);
|
| -
|
| - if (malware && phishing) {
|
| - PopulateStringDictionary(
|
| - strings,
|
| - // Use the malware headline, it is the scariest one.
|
| - l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MULTI_THREAT_TITLE),
|
| - l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MALWARE_HEADLINE),
|
| - l10n_util::GetStringFUTF16(IDS_SAFE_BROWSING_MULTI_THREAT_DESCRIPTION1,
|
| - UTF8ToUTF16(web_contents_->GetURL().host())),
|
| - l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MULTI_THREAT_DESCRIPTION2),
|
| - string16());
|
| - } else if (malware) {
|
| - // Just malware.
|
| - PopulateStringDictionary(
|
| - strings,
|
| - l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MALWARE_TITLE),
|
| - l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MALWARE_HEADLINE),
|
| - l10n_util::GetStringFUTF16(IDS_SAFE_BROWSING_MULTI_MALWARE_DESCRIPTION1,
|
| - UTF8ToUTF16(web_contents_->GetURL().host())),
|
| - l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MULTI_MALWARE_DESCRIPTION2),
|
| - l10n_util::GetStringUTF16(
|
| - IDS_SAFE_BROWSING_MULTI_MALWARE_DESCRIPTION3));
|
| - } else {
|
| - // Just phishing.
|
| - PopulateStringDictionary(
|
| - strings,
|
| - l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_PHISHING_TITLE),
|
| - l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_PHISHING_HEADLINE),
|
| - l10n_util::GetStringFUTF16(
|
| - IDS_SAFE_BROWSING_MULTI_PHISHING_DESCRIPTION1,
|
| - UTF8ToUTF16(web_contents_->GetURL().host())),
|
| - string16(),
|
| - string16());
|
| - }
|
| -
|
| - strings->SetString("confirm_text",
|
| - l10n_util::GetStringUTF16(
|
| - IDS_SAFE_BROWSING_MULTI_MALWARE_DESCRIPTION_AGREE));
|
| - strings->SetString("continue_button",
|
| - l10n_util::GetStringUTF16(
|
| - IDS_SAFE_BROWSING_MULTI_MALWARE_PROCEED_BUTTON));
|
| - strings->SetString("back_button",
|
| - l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MALWARE_BACK_BUTTON));
|
| - strings->SetString("textdirection", base::i18n::IsRTL() ? "rtl" : "ltr");
|
| -}
|
| -
|
| -void SafeBrowsingBlockingPage::PopulateMalwareStringDictionary(
|
| - DictionaryValue* strings) {
|
| - std::string diagnostic_link = base::StringPrintf(kSbDiagnosticHtml,
|
| - l10n_util::GetStringUTF8(
|
| - IDS_SAFE_BROWSING_MALWARE_DIAGNOSTIC_PAGE).c_str());
|
| -
|
| - strings->SetString("badURL", url_.host());
|
| - // Check to see if we're blocking the main page, or a sub-resource on the
|
| - // main page.
|
| - string16 description1, description3, description5;
|
| - if (is_main_frame_load_blocked_) {
|
| - description1 = l10n_util::GetStringFUTF16(
|
| - IDS_SAFE_BROWSING_MALWARE_DESCRIPTION1, UTF8ToUTF16(url_.host()));
|
| - } else {
|
| - description1 = l10n_util::GetStringFUTF16(
|
| - IDS_SAFE_BROWSING_MALWARE_DESCRIPTION4,
|
| - UTF8ToUTF16(web_contents_->GetURL().host()),
|
| - UTF8ToUTF16(url_.host()));
|
| - }
|
| -
|
| - std::string proceed_link = base::StringPrintf(kPLinkHtml,
|
| - l10n_util::GetStringUTF8(IDS_SAFE_BROWSING_MALWARE_PROCEED_LINK).c_str());
|
| - description3 =
|
| - l10n_util::GetStringFUTF16(IDS_SAFE_BROWSING_MALWARE_DESCRIPTION3,
|
| - UTF8ToUTF16(proceed_link));
|
| -
|
| - PopulateStringDictionary(
|
| - strings,
|
| - l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MALWARE_TITLE),
|
| - l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MALWARE_HEADLINE),
|
| - description1,
|
| - l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MALWARE_DESCRIPTION2),
|
| - description3);
|
| -
|
| - description5 =
|
| - l10n_util::GetStringFUTF16(IDS_SAFE_BROWSING_MALWARE_DESCRIPTION5,
|
| - UTF8ToUTF16(url_.host()),
|
| - UTF8ToUTF16(url_.host()),
|
| - UTF8ToUTF16(diagnostic_link));
|
| -
|
| - strings->SetString("description5", description5);
|
| -
|
| - strings->SetString("back_button",
|
| - l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MALWARE_BACK_BUTTON));
|
| - strings->SetString("proceed_link",
|
| - l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MALWARE_PROCEED_LINK));
|
| - strings->SetString("textdirection", base::i18n::IsRTL() ? "rtl" : "ltr");
|
| -
|
| - if (!CanShowMalwareDetailsOption()) {
|
| - strings->SetBoolean(kDisplayCheckBox, false);
|
| - } else {
|
| - // Show the checkbox for sending malware details.
|
| - strings->SetBoolean(kDisplayCheckBox, true);
|
| -
|
| - std::string privacy_link = base::StringPrintf(
|
| - kPrivacyLinkHtml,
|
| - l10n_util::GetStringUTF8(
|
| - IDS_SAFE_BROWSING_PRIVACY_POLICY_PAGE).c_str());
|
| -
|
| - strings->SetString("confirm_text",
|
| - l10n_util::GetStringFUTF16(
|
| - IDS_SAFE_BROWSING_MALWARE_REPORTING_AGREE,
|
| - UTF8ToUTF16(privacy_link)));
|
| - if (IsPrefEnabled(prefs::kSafeBrowsingReportingEnabled))
|
| - strings->SetString(kBoxChecked, "yes");
|
| - else
|
| - strings->SetString(kBoxChecked, "");
|
| - }
|
| -}
|
| -
|
| -void SafeBrowsingBlockingPage::PopulatePhishingStringDictionary(
|
| - DictionaryValue* strings) {
|
| - std::string proceed_link = base::StringPrintf(
|
| - kPLinkHtml,
|
| - l10n_util::GetStringUTF8(
|
| - IDS_SAFE_BROWSING_PHISHING_PROCEED_LINK).c_str());
|
| - string16 description3 = l10n_util::GetStringFUTF16(
|
| - IDS_SAFE_BROWSING_PHISHING_DESCRIPTION3,
|
| - UTF8ToUTF16(proceed_link));
|
| -
|
| - PopulateStringDictionary(
|
| - strings,
|
| - l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_PHISHING_TITLE),
|
| - l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_PHISHING_HEADLINE),
|
| - l10n_util::GetStringFUTF16(IDS_SAFE_BROWSING_PHISHING_DESCRIPTION1,
|
| - UTF8ToUTF16(url_.host())),
|
| - l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_PHISHING_DESCRIPTION2),
|
| - description3);
|
| -
|
| - strings->SetString("back_button",
|
| - l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_PHISHING_BACK_BUTTON));
|
| - strings->SetString("report_error",
|
| - l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_PHISHING_REPORT_ERROR));
|
| - strings->SetString("textdirection", base::i18n::IsRTL() ? "rtl" : "ltr");
|
| -}
|
| -
|
| void SafeBrowsingBlockingPage::CommandReceived(const std::string& cmd) {
|
| std::string command(cmd); // Make a local copy so we can modify it.
|
| // The Jasonified response has quotes, remove them.
|
| @@ -461,9 +260,26 @@ void SafeBrowsingBlockingPage::CommandReceived(const std::string& cmd) {
|
| return;
|
| }
|
|
|
| + if (command == kLearnMoreCommandV2) {
|
| + // User pressed "Learn more".
|
| + GURL url;
|
| + SafeBrowsingService::UrlCheckResult threat_type =
|
| + unsafe_resources_[0].threat_type;
|
| + if (threat_type == SafeBrowsingService::URL_MALWARE) {
|
| + url = google_util::AppendGoogleLocaleParam(GURL(kLearnMoreMalwareUrlV2));
|
| + } else {
|
| + NOTREACHED();
|
| + }
|
| +
|
| + OpenURLParams params(
|
| + url, Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_LINK, false);
|
| + web_contents_->OpenURL(params);
|
| + return;
|
| + }
|
| +
|
| if (command == kShowPrivacyCommand) {
|
| // User pressed "Safe Browsing privacy policy".
|
| - GURL url(kSbPrivacyPolicyUrl);
|
| + GURL url(l10n_util::GetStringUTF8(IDS_SAFE_BROWSING_PRIVACY_POLICY_URL));
|
| OpenURLParams params(
|
| url, Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_LINK, false);
|
| web_contents_->OpenURL(params);
|
| @@ -560,6 +376,13 @@ void SafeBrowsingBlockingPage::CommandReceived(const std::string& cmd) {
|
| return;
|
| }
|
|
|
| + if (command == kExpandedSeeMore) {
|
| + // 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.
|
| + return;
|
| + }
|
| +
|
| NOTREACHED() << "Unexpected command: " << command;
|
| }
|
|
|
| @@ -644,28 +467,105 @@ void SafeBrowsingBlockingPage::OnDontProceed() {
|
| }
|
|
|
| void SafeBrowsingBlockingPage::RecordUserAction(BlockingPageEvent event) {
|
| - // Determine the interstitial type from the blocked resources.
|
| - // This is the same logic that is used to actually construct the
|
| - // page contents; we can look at the title to see which type of
|
| - // interstitial is being displayed.
|
| - DictionaryValue strings;
|
| - PopulateMultipleThreatStringDictionary(&strings);
|
| + // This enum is used for a histogram. Don't reorder, delete, or insert
|
| + // elements. New elements should be added before MAX_ACTION only.
|
| + enum {
|
| + MALWARE_SHOW = 0,
|
| + MALWARE_DONT_PROCEED,
|
| + MALWARE_FORCED_DONT_PROCEED,
|
| + MALWARE_PROCEED,
|
| + MULTIPLE_SHOW,
|
| + MULTIPLE_DONT_PROCEED,
|
| + MULTIPLE_FORCED_DONT_PROCEED,
|
| + MULTIPLE_PROCEED,
|
| + PHISHING_SHOW,
|
| + PHISHING_DONT_PROCEED,
|
| + PHISHING_FORCED_DONT_PROCEED,
|
| + PHISHING_PROCEED,
|
| + MAX_ACTION
|
| + } histogram_action = MAX_ACTION;
|
|
|
| - string16 title;
|
| - bool success = strings.GetString("title", &title);
|
| - DCHECK(success);
|
| + switch (event) {
|
| + case SHOW:
|
| + switch (interstitial_type_) {
|
| + case TYPE_MALWARE_AND_PHISHING:
|
| + histogram_action = MULTIPLE_SHOW;
|
| + break;
|
| + case TYPE_MALWARE:
|
| + histogram_action = MALWARE_SHOW;
|
| + break;
|
| + case TYPE_PHISHING:
|
| + histogram_action = PHISHING_SHOW;
|
| + break;
|
| + }
|
| + break;
|
| + case PROCEED:
|
| + switch (interstitial_type_) {
|
| + case TYPE_MALWARE_AND_PHISHING:
|
| + histogram_action = MULTIPLE_PROCEED;
|
| + break;
|
| + case TYPE_MALWARE:
|
| + histogram_action = MALWARE_PROCEED;
|
| + break;
|
| + case TYPE_PHISHING:
|
| + histogram_action = PHISHING_PROCEED;
|
| + break;
|
| + }
|
| + break;
|
| + case DONT_PROCEED:
|
| + if (IsPrefEnabled(prefs::kSafeBrowsingProceedAnywayDisabled)) {
|
| + switch (interstitial_type_) {
|
| + case TYPE_MALWARE_AND_PHISHING:
|
| + histogram_action = MULTIPLE_FORCED_DONT_PROCEED;
|
| + break;
|
| + case TYPE_MALWARE:
|
| + histogram_action = MALWARE_FORCED_DONT_PROCEED;
|
| + break;
|
| + case TYPE_PHISHING:
|
| + histogram_action = PHISHING_FORCED_DONT_PROCEED;
|
| + break;
|
| + }
|
| + } else {
|
| + switch (interstitial_type_) {
|
| + case TYPE_MALWARE_AND_PHISHING:
|
| + histogram_action = MULTIPLE_DONT_PROCEED;
|
| + break;
|
| + case TYPE_MALWARE:
|
| + histogram_action = MALWARE_DONT_PROCEED;
|
| + break;
|
| + case TYPE_PHISHING:
|
| + histogram_action = PHISHING_DONT_PROCEED;
|
| + break;
|
| + }
|
| + }
|
| + break;
|
| + default:
|
| + NOTREACHED() << "Unexpected event: " << event;
|
| + }
|
| + if (histogram_action == MAX_ACTION) {
|
| + NOTREACHED();
|
| + } else {
|
| + UMA_HISTOGRAM_ENUMERATION("SB2.InterstitialAction", histogram_action,
|
| + MAX_ACTION);
|
| + UMA_HISTOGRAM_ENUMERATION(
|
| + base::FieldTrial::MakeName("SB2.InterstitialAction", "SBInterstitial"),
|
| + histogram_action,
|
| + MAX_ACTION);
|
| + }
|
|
|
| + // TODO(mattm): now that we've added the histogram above, should we remove
|
| + // this old user metric at some future point?
|
| std::string action = "SBInterstitial";
|
| - if (title ==
|
| - l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MULTI_THREAT_TITLE)) {
|
| - action.append("Multiple");
|
| - } else if (title ==
|
| - l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MALWARE_TITLE)) {
|
| - action.append("Malware");
|
| - } else {
|
| - DCHECK_EQ(title,
|
| - l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_PHISHING_TITLE));
|
| - action.append("Phishing");
|
| + switch (interstitial_type_) {
|
| + case TYPE_MALWARE_AND_PHISHING:
|
| + action.append("Multiple");
|
| + break;
|
| + case TYPE_MALWARE:
|
| + action.append("Malware");
|
| + break;
|
| + case TYPE_PHISHING:
|
| + action.append("Phishing");
|
| + break;
|
| }
|
|
|
| switch (event) {
|
| @@ -685,7 +585,14 @@ void SafeBrowsingBlockingPage::RecordUserAction(BlockingPageEvent event) {
|
| NOTREACHED() << "Unexpected event: " << event;
|
| }
|
|
|
| + std::string field_trial_action;
|
| + if (base::FieldTrialList::FindFullName("SBInterstitial") == "V2")
|
| + field_trial_action = action + "_V2";
|
| + else
|
| + field_trial_action = action + "_V1";
|
| +
|
| content::RecordComputedAction(action);
|
| + content::RecordComputedAction(field_trial_action);
|
| }
|
|
|
| void SafeBrowsingBlockingPage::RecordUserReactionTime(
|
| @@ -694,25 +601,52 @@ void SafeBrowsingBlockingPage::RecordUserReactionTime(
|
| return; // We already reported the user reaction time.
|
| base::TimeDelta dt = base::TimeTicks::Now() - interstitial_show_time_;
|
| DVLOG(1) << "User reaction time for command:" << command
|
| - << " on is_malware:" << is_malware_interstitial_
|
| + << " on interstitial_type_:" << interstitial_type_
|
| << " warning took " << dt.InMilliseconds() << "ms";
|
| bool recorded = true;
|
| - if (is_malware_interstitial_) {
|
| + if (interstitial_type_ == TYPE_MALWARE ||
|
| + interstitial_type_ == TYPE_MALWARE_AND_PHISHING) {
|
| // There are six ways in which the malware interstitial can go
|
| // away. We handle all of them here but we group two together: closing the
|
| // tag / browser window and clicking on the back button in the browser (not
|
| // the big green button) are considered the same action.
|
| if (command == kProceedCommand) {
|
| UMA_HISTOGRAM_MEDIUM_TIMES("SB2.MalwareInterstitialTimeProceed", dt);
|
| + UMA_HISTOGRAM_MEDIUM_TIMES(base::FieldTrial::MakeName(
|
| + "SB2.MalwareInterstitialTimeProceed", "SBInterstitial"), dt);
|
| } else if (command == kTakeMeBackCommand) {
|
| UMA_HISTOGRAM_MEDIUM_TIMES("SB2.MalwareInterstitialTimeTakeMeBack", dt);
|
| + UMA_HISTOGRAM_MEDIUM_TIMES(base::FieldTrial::MakeName(
|
| + "SB2.MalwareInterstitialTimeTakeMeBack", "SBInterstitial"), dt);
|
| } else if (command == kShowDiagnosticCommand) {
|
| UMA_HISTOGRAM_MEDIUM_TIMES("SB2.MalwareInterstitialTimeDiagnostic", dt);
|
| + UMA_HISTOGRAM_MEDIUM_TIMES(base::FieldTrial::MakeName(
|
| + "SB2.MalwareInterstitialTimeDiagnostic", "SBInterstitial"), dt);
|
| } else if (command == kShowPrivacyCommand) {
|
| UMA_HISTOGRAM_MEDIUM_TIMES("SB2.MalwareInterstitialTimePrivacyPolicy",
|
| dt);
|
| + UMA_HISTOGRAM_MEDIUM_TIMES(base::FieldTrial::MakeName(
|
| + "SB2.MalwareInterstitialTimePrivacyPolicy", "SBInterstitial"), dt);
|
| + } else if (command == kLearnMoreCommand || command == kLearnMoreCommandV2) {
|
| + UMA_HISTOGRAM_MEDIUM_TIMES("SB2.MalwareInterstitialLearnMore",
|
| + dt);
|
| + UMA_HISTOGRAM_MEDIUM_TIMES(base::FieldTrial::MakeName(
|
| + "SB2.MalwareInterstitialLearnMore", "SBInterstitial"), dt);
|
| } else if (command == kNavigatedAwayMetaCommand) {
|
| UMA_HISTOGRAM_MEDIUM_TIMES("SB2.MalwareInterstitialTimeClosed", dt);
|
| + UMA_HISTOGRAM_MEDIUM_TIMES(base::FieldTrial::MakeName(
|
| + "SB2.MalwareInterstitialTimeClosed", "SBInterstitial"), dt);
|
| + } else if (command == kExpandedSeeMore) {
|
| + // Only record the expanded histogram once per display of the
|
| + // interstitial.
|
| + if (has_expanded_see_more_section_)
|
| + return;
|
| + UMA_HISTOGRAM_MEDIUM_TIMES("SB2.MalwareInterstitialTimeExpandedSeeMore",
|
| + dt);
|
| + has_expanded_see_more_section_ = true;
|
| + // Expanding the "See More" section doesn't finish the interstitial, so
|
| + // don't mark the reaction time as recorded.
|
| + recorded = false;
|
| } else {
|
| recorded = false;
|
| }
|
| @@ -724,10 +658,15 @@ void SafeBrowsingBlockingPage::RecordUserReactionTime(
|
| UMA_HISTOGRAM_MEDIUM_TIMES("SB2.PhishingInterstitialTimeTakeMeBack", dt);
|
| } else if (command == kShowDiagnosticCommand) {
|
| UMA_HISTOGRAM_MEDIUM_TIMES("SB2.PhishingInterstitialTimeReportError", dt);
|
| - } else if (command == kShowPrivacyCommand) {
|
| + } else if (command == kLearnMoreCommand || command == kLearnMoreCommandV2) {
|
| UMA_HISTOGRAM_MEDIUM_TIMES("SB2.PhishingInterstitialTimeLearnMore", dt);
|
| } else if (command == kNavigatedAwayMetaCommand) {
|
| UMA_HISTOGRAM_MEDIUM_TIMES("SB2.PhishingInterstitialTimeClosed", dt);
|
| + } else if (command == kExpandedSeeMore) {
|
| + // TODO(mattm): Add histogram for this when we implement V2 of the
|
| + // phishing interstitial.
|
| + NOTREACHED();
|
| + recorded = false;
|
| } else {
|
| recorded = false;
|
| }
|
| @@ -776,6 +715,7 @@ SafeBrowsingBlockingPage::UnsafeResourceMap*
|
| void SafeBrowsingBlockingPage::ShowBlockingPage(
|
| SafeBrowsingService* sb_service,
|
| const SafeBrowsingService::UnsafeResource& unsafe_resource) {
|
| + DVLOG(1) << __FUNCTION__ << " " << unsafe_resource.url.spec();
|
| WebContents* web_contents = tab_util::GetWebContentsByID(
|
| unsafe_resource.render_process_host_id, unsafe_resource.render_view_id);
|
|
|
| @@ -822,3 +762,394 @@ bool SafeBrowsingBlockingPage::IsMainPageLoadBlocked(
|
| // Otherwise, check the threat type.
|
| return unsafe_resources.size() == 1 && !unsafe_resources[0].is_subresource;
|
| }
|
| +
|
| +SafeBrowsingBlockingPageV1::SafeBrowsingBlockingPageV1(
|
| + SafeBrowsingService* sb_service,
|
| + WebContents* web_contents,
|
| + const UnsafeResourceList& unsafe_resources)
|
| + : SafeBrowsingBlockingPage(sb_service, web_contents, unsafe_resources) {
|
| +}
|
| +
|
| +std::string SafeBrowsingBlockingPageV1::GetHTMLContents() {
|
| + // Load the HTML page and create the template components.
|
| + DictionaryValue strings;
|
| + ResourceBundle& rb = ResourceBundle::GetSharedInstance();
|
| + std::string html;
|
| +
|
| + if (unsafe_resources_.empty()) {
|
| + NOTREACHED();
|
| + return std::string();
|
| + }
|
| +
|
| + if (unsafe_resources_.size() > 1) {
|
| + PopulateMultipleThreatStringDictionary(&strings);
|
| + html = rb.GetRawDataResource(
|
| + IDR_SAFE_BROWSING_MULTIPLE_THREAT_BLOCK,
|
| + ui::SCALE_FACTOR_NONE).as_string();
|
| + } else {
|
| + SafeBrowsingService::UrlCheckResult threat_type =
|
| + unsafe_resources_[0].threat_type;
|
| + if (threat_type == SafeBrowsingService::URL_MALWARE) {
|
| + PopulateMalwareStringDictionary(&strings);
|
| + html = rb.GetRawDataResource(
|
| + IDR_SAFE_BROWSING_MALWARE_BLOCK,
|
| + ui::SCALE_FACTOR_NONE).as_string();
|
| + } else { // Phishing.
|
| + DCHECK(threat_type == SafeBrowsingService::URL_PHISHING ||
|
| + threat_type == SafeBrowsingService::CLIENT_SIDE_PHISHING_URL);
|
| + PopulatePhishingStringDictionary(&strings);
|
| + html = rb.GetRawDataResource(
|
| + IDR_SAFE_BROWSING_PHISHING_BLOCK,
|
| + ui::SCALE_FACTOR_NONE).as_string();
|
| + }
|
| + }
|
| + interstitial_show_time_ = base::TimeTicks::Now();
|
| + return jstemplate_builder::GetTemplatesHtml(html, &strings, "template_root");
|
| +}
|
| +
|
| +void SafeBrowsingBlockingPageV1::PopulateStringDictionary(
|
| + DictionaryValue* strings,
|
| + const string16& title,
|
| + const string16& headline,
|
| + const string16& description1,
|
| + const string16& description2,
|
| + const string16& description3) {
|
| + strings->SetString("title", title);
|
| + strings->SetString("headLine", headline);
|
| + strings->SetString("description1", description1);
|
| + strings->SetString("description2", description2);
|
| + strings->SetString("description3", description3);
|
| + strings->SetBoolean("proceedDisabled",
|
| + IsPrefEnabled(prefs::kSafeBrowsingProceedAnywayDisabled));
|
| +}
|
| +
|
| +void SafeBrowsingBlockingPageV1::PopulateMultipleThreatStringDictionary(
|
| + DictionaryValue* strings) {
|
| +
|
| + string16 malware_label =
|
| + l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MALWARE_LABEL);
|
| + string16 malware_link =
|
| + l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MALWARE_DIAGNOSTIC_PAGE);
|
| + string16 phishing_label =
|
| + l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_PHISHING_LABEL);
|
| + string16 phishing_link =
|
| + l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_PHISHING_REPORT_ERROR);
|
| +
|
| + ListValue* error_strings = new ListValue;
|
| + for (UnsafeResourceList::const_iterator iter = unsafe_resources_.begin();
|
| + iter != unsafe_resources_.end(); ++iter) {
|
| + const SafeBrowsingService::UnsafeResource& resource = *iter;
|
| + SafeBrowsingService::UrlCheckResult threat_type = resource.threat_type;
|
| + DictionaryValue* current_error_strings = new DictionaryValue;
|
| + if (threat_type == SafeBrowsingService::URL_MALWARE) {
|
| + current_error_strings->SetString("type", "malware");
|
| + current_error_strings->SetString("typeLabel", malware_label);
|
| + current_error_strings->SetString("errorLink", malware_link);
|
| + } else {
|
| + DCHECK(threat_type == SafeBrowsingService::URL_PHISHING ||
|
| + threat_type == SafeBrowsingService::CLIENT_SIDE_PHISHING_URL);
|
| + current_error_strings->SetString("type", "phishing");
|
| + current_error_strings->SetString("typeLabel", phishing_label);
|
| + current_error_strings->SetString("errorLink", phishing_link);
|
| + }
|
| + current_error_strings->SetString("url", resource.url.spec());
|
| + error_strings->Append(current_error_strings);
|
| + }
|
| + strings->Set("errors", error_strings);
|
| +
|
| + switch (interstitial_type_) {
|
| + case TYPE_MALWARE_AND_PHISHING:
|
| + PopulateStringDictionary(
|
| + strings,
|
| + // Use the malware headline, it is the scariest one.
|
| + l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MULTI_THREAT_TITLE),
|
| + l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MALWARE_HEADLINE),
|
| + l10n_util::GetStringFUTF16(
|
| + IDS_SAFE_BROWSING_MULTI_THREAT_DESCRIPTION1,
|
| + UTF8ToUTF16(web_contents_->GetURL().host())),
|
| + l10n_util::GetStringUTF16(
|
| + IDS_SAFE_BROWSING_MULTI_THREAT_DESCRIPTION2),
|
| + string16());
|
| + break;
|
| + case TYPE_MALWARE:
|
| + PopulateStringDictionary(
|
| + strings,
|
| + l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MALWARE_TITLE),
|
| + l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MALWARE_HEADLINE),
|
| + l10n_util::GetStringFUTF16(
|
| + IDS_SAFE_BROWSING_MULTI_MALWARE_DESCRIPTION1,
|
| + UTF8ToUTF16(web_contents_->GetURL().host())),
|
| + l10n_util::GetStringUTF16(
|
| + IDS_SAFE_BROWSING_MULTI_MALWARE_DESCRIPTION2),
|
| + l10n_util::GetStringUTF16(
|
| + IDS_SAFE_BROWSING_MULTI_MALWARE_DESCRIPTION3));
|
| + break;
|
| + case TYPE_PHISHING:
|
| + PopulateStringDictionary(
|
| + strings,
|
| + l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_PHISHING_TITLE),
|
| + l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_PHISHING_HEADLINE),
|
| + l10n_util::GetStringFUTF16(
|
| + IDS_SAFE_BROWSING_MULTI_PHISHING_DESCRIPTION1,
|
| + UTF8ToUTF16(web_contents_->GetURL().host())),
|
| + string16(),
|
| + string16());
|
| + break;
|
| + }
|
| +
|
| + strings->SetString("confirm_text",
|
| + l10n_util::GetStringUTF16(
|
| + IDS_SAFE_BROWSING_MULTI_MALWARE_DESCRIPTION_AGREE));
|
| + strings->SetString("continue_button",
|
| + l10n_util::GetStringUTF16(
|
| + IDS_SAFE_BROWSING_MULTI_MALWARE_PROCEED_BUTTON));
|
| + strings->SetString("back_button",
|
| + l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MALWARE_BACK_BUTTON));
|
| + strings->SetString("textdirection", base::i18n::IsRTL() ? "rtl" : "ltr");
|
| +}
|
| +
|
| +void SafeBrowsingBlockingPageV1::PopulateMalwareStringDictionary(
|
| + DictionaryValue* strings) {
|
| + std::string diagnostic_link = base::StringPrintf(kSbDiagnosticHtml,
|
| + l10n_util::GetStringUTF8(
|
| + IDS_SAFE_BROWSING_MALWARE_DIAGNOSTIC_PAGE).c_str());
|
| +
|
| + // Check to see if we're blocking the main page, or a sub-resource on the
|
| + // main page.
|
| + string16 description1, description3, description5;
|
| + if (is_main_frame_load_blocked_) {
|
| + description1 = l10n_util::GetStringFUTF16(
|
| + IDS_SAFE_BROWSING_MALWARE_DESCRIPTION1, UTF8ToUTF16(url_.host()));
|
| + } else {
|
| + description1 = l10n_util::GetStringFUTF16(
|
| + IDS_SAFE_BROWSING_MALWARE_DESCRIPTION4,
|
| + UTF8ToUTF16(web_contents_->GetURL().host()),
|
| + UTF8ToUTF16(url_.host()));
|
| + }
|
| +
|
| + std::string proceed_link = base::StringPrintf(kPLinkHtml,
|
| + l10n_util::GetStringUTF8(IDS_SAFE_BROWSING_MALWARE_PROCEED_LINK).c_str());
|
| + description3 =
|
| + l10n_util::GetStringFUTF16(IDS_SAFE_BROWSING_MALWARE_DESCRIPTION3,
|
| + UTF8ToUTF16(proceed_link));
|
| +
|
| + PopulateStringDictionary(
|
| + strings,
|
| + l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MALWARE_TITLE),
|
| + l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MALWARE_HEADLINE),
|
| + description1,
|
| + l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MALWARE_DESCRIPTION2),
|
| + description3);
|
| +
|
| + description5 =
|
| + l10n_util::GetStringFUTF16(IDS_SAFE_BROWSING_MALWARE_DESCRIPTION5,
|
| + UTF8ToUTF16(url_.host()),
|
| + UTF8ToUTF16(url_.host()),
|
| + UTF8ToUTF16(diagnostic_link));
|
| +
|
| + strings->SetString("description5", description5);
|
| +
|
| + strings->SetString("back_button",
|
| + l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MALWARE_BACK_BUTTON));
|
| + strings->SetString("proceed_link",
|
| + l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MALWARE_PROCEED_LINK));
|
| + strings->SetString("textdirection", base::i18n::IsRTL() ? "rtl" : "ltr");
|
| +
|
| + if (!CanShowMalwareDetailsOption()) {
|
| + strings->SetBoolean(kDisplayCheckBox, false);
|
| + } else {
|
| + // Show the checkbox for sending malware details.
|
| + strings->SetBoolean(kDisplayCheckBox, true);
|
| +
|
| + std::string privacy_link = base::StringPrintf(
|
| + kPrivacyLinkHtml,
|
| + l10n_util::GetStringUTF8(
|
| + IDS_SAFE_BROWSING_PRIVACY_POLICY_PAGE).c_str());
|
| +
|
| + strings->SetString("confirm_text",
|
| + l10n_util::GetStringFUTF16(
|
| + IDS_SAFE_BROWSING_MALWARE_REPORTING_AGREE,
|
| + UTF8ToUTF16(privacy_link)));
|
| + if (IsPrefEnabled(prefs::kSafeBrowsingReportingEnabled))
|
| + strings->SetString(kBoxChecked, "yes");
|
| + else
|
| + strings->SetString(kBoxChecked, "");
|
| + }
|
| +}
|
| +
|
| +void SafeBrowsingBlockingPageV1::PopulatePhishingStringDictionary(
|
| + DictionaryValue* strings) {
|
| + std::string proceed_link = base::StringPrintf(
|
| + kPLinkHtml,
|
| + l10n_util::GetStringUTF8(
|
| + IDS_SAFE_BROWSING_PHISHING_PROCEED_LINK).c_str());
|
| + string16 description3 = l10n_util::GetStringFUTF16(
|
| + IDS_SAFE_BROWSING_PHISHING_DESCRIPTION3,
|
| + UTF8ToUTF16(proceed_link));
|
| +
|
| + PopulateStringDictionary(
|
| + strings,
|
| + l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_PHISHING_TITLE),
|
| + l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_PHISHING_HEADLINE),
|
| + l10n_util::GetStringFUTF16(IDS_SAFE_BROWSING_PHISHING_DESCRIPTION1,
|
| + UTF8ToUTF16(url_.host())),
|
| + l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_PHISHING_DESCRIPTION2),
|
| + description3);
|
| +
|
| + strings->SetString("back_button",
|
| + l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_PHISHING_BACK_BUTTON));
|
| + strings->SetString("report_error",
|
| + l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_PHISHING_REPORT_ERROR));
|
| + strings->SetString("textdirection", base::i18n::IsRTL() ? "rtl" : "ltr");
|
| +}
|
| +
|
| +SafeBrowsingBlockingPageV2::SafeBrowsingBlockingPageV2(
|
| + SafeBrowsingService* sb_service,
|
| + WebContents* web_contents,
|
| + const UnsafeResourceList& unsafe_resources)
|
| + : SafeBrowsingBlockingPage(sb_service, web_contents, unsafe_resources) {
|
| +}
|
| +
|
| +std::string SafeBrowsingBlockingPageV2::GetHTMLContents() {
|
| + // Load the HTML page and create the template components.
|
| + DictionaryValue strings;
|
| + ResourceBundle& rb = ResourceBundle::GetSharedInstance();
|
| + std::string html;
|
| +
|
| + if (unsafe_resources_.empty()) {
|
| + NOTREACHED();
|
| + return std::string();
|
| + }
|
| +
|
| + if (unsafe_resources_.size() > 1) {
|
| + NOTREACHED();
|
| + } else {
|
| + SafeBrowsingService::UrlCheckResult threat_type =
|
| + unsafe_resources_[0].threat_type;
|
| + if (threat_type == SafeBrowsingService::URL_MALWARE) {
|
| + PopulateMalwareStringDictionary(&strings);
|
| + html = rb.GetRawDataResource(
|
| + IDR_SAFE_BROWSING_MALWARE_BLOCK_V2,
|
| + ui::SCALE_FACTOR_NONE).as_string();
|
| + } else { // Phishing.
|
| + DCHECK(threat_type == SafeBrowsingService::URL_PHISHING ||
|
| + threat_type == SafeBrowsingService::CLIENT_SIDE_PHISHING_URL);
|
| + NOTREACHED();
|
| + }
|
| + }
|
| + interstitial_show_time_ = base::TimeTicks::Now();
|
| + return jstemplate_builder::GetTemplatesHtml(html, &strings, "template-root");
|
| +}
|
| +
|
| +void SafeBrowsingBlockingPageV2::PopulateStringDictionary(
|
| + DictionaryValue* strings,
|
| + const string16& title,
|
| + const string16& headline,
|
| + const string16& description1,
|
| + const string16& description2,
|
| + const string16& description3,
|
| + const string16& description4) {
|
| + strings->SetString("title", title);
|
| + strings->SetString("headLine", headline);
|
| + strings->SetString("description1", description1);
|
| + strings->SetString("description2", description2);
|
| + strings->SetString("description3", description3);
|
| + strings->SetString("description4", description4);
|
| + strings->SetBoolean("proceedDisabled",
|
| + IsPrefEnabled(prefs::kSafeBrowsingProceedAnywayDisabled));
|
| +
|
| + strings->SetString("textdirection", base::i18n::IsRTL() ? "rtl" : "ltr");
|
| + strings->SetString("back_button",
|
| + l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MALWARE_BACK_BUTTON));
|
| + strings->SetString("seeMore", l10n_util::GetStringUTF16(
|
| + IDS_SAFE_BROWSING_MALWARE_V2_SEE_MORE));
|
| + strings->SetString("seeLess", l10n_util::GetStringUTF16(
|
| + IDS_SAFE_BROWSING_MALWARE_V2_SEE_LESS));
|
| +}
|
| +
|
| +void SafeBrowsingBlockingPageV2::PopulateMultipleThreatStringDictionary(
|
| + DictionaryValue* strings) {
|
| + NOTREACHED();
|
| +}
|
| +
|
| +void SafeBrowsingBlockingPageV2::PopulateMalwareStringDictionary(
|
| + DictionaryValue* strings) {
|
| + std::string diagnostic_link = base::StringPrintf(kSbDiagnosticHtml,
|
| + l10n_util::GetStringUTF8(
|
| + IDS_SAFE_BROWSING_MALWARE_DIAGNOSTIC_PAGE).c_str());
|
| +
|
| + // Check to see if we're blocking the main page, or a sub-resource on the
|
| + // main page.
|
| + string16 headline, description1, description2, description3, description4;
|
| +
|
| +
|
| + if (is_main_frame_load_blocked_) {
|
| + headline = l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MALWARE_V2_HEADLINE);
|
| + description1 = l10n_util::GetStringFUTF16(
|
| + IDS_SAFE_BROWSING_MALWARE_V2_DESCRIPTION1,
|
| + l10n_util::GetStringUTF16(IDS_PRODUCT_NAME),
|
| + UTF8ToUTF16(url_.host()));
|
| + description2 = l10n_util::GetStringUTF16(
|
| + IDS_SAFE_BROWSING_MALWARE_V2_DESCRIPTION2);
|
| + description3 = l10n_util::GetStringUTF16(
|
| + IDS_SAFE_BROWSING_MALWARE_V2_DESCRIPTION3);
|
| + description4 = l10n_util::GetStringUTF16(
|
| + IDS_SAFE_BROWSING_MALWARE_V2_DESCRIPTION4);
|
| + strings->SetBoolean(kDisplayShowDiagnostic, true);
|
| + } else {
|
| + headline = l10n_util::GetStringUTF16(
|
| + IDS_SAFE_BROWSING_MALWARE_V2_HEADLINE_SUBRESOURCE);
|
| + description1 = l10n_util::GetStringFUTF16(
|
| + IDS_SAFE_BROWSING_MALWARE_V2_DESCRIPTION1_SUBRESOURCE,
|
| + l10n_util::GetStringUTF16(IDS_PRODUCT_NAME),
|
| + UTF8ToUTF16(web_contents_->GetURL().host()));
|
| + description2 = l10n_util::GetStringUTF16(
|
| + IDS_SAFE_BROWSING_MALWARE_V2_DESCRIPTION2_SUBRESOURCE);
|
| + description3 = l10n_util::GetStringUTF16(
|
| + IDS_SAFE_BROWSING_MALWARE_V2_DESCRIPTION3_SUBRESOURCE);
|
| + description4 = l10n_util::GetStringFUTF16(
|
| + IDS_SAFE_BROWSING_MALWARE_V2_DESCRIPTION4_SUBRESOURCE,
|
| + UTF8ToUTF16(url_.host()));
|
| + strings->SetBoolean(kDisplayShowDiagnostic, false);
|
| + }
|
| +
|
| + PopulateStringDictionary(
|
| + strings,
|
| + l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MALWARE_V2_TITLE),
|
| + headline,
|
| + description1,
|
| + description2,
|
| + description3,
|
| + description4);
|
| +
|
| + if (!CanShowMalwareDetailsOption()) {
|
| + strings->SetBoolean(kDisplayCheckBox, false);
|
| + } else {
|
| + // Show the checkbox for sending malware details.
|
| + strings->SetBoolean(kDisplayCheckBox, true);
|
| +
|
| + std::string privacy_link = base::StringPrintf(
|
| + kPrivacyLinkHtml,
|
| + l10n_util::GetStringUTF8(
|
| + IDS_SAFE_BROWSING_PRIVACY_POLICY_PAGE_V2).c_str());
|
| +
|
| + strings->SetString("confirm_text",
|
| + l10n_util::GetStringFUTF16(
|
| + IDS_SAFE_BROWSING_MALWARE_V2_REPORTING_AGREE,
|
| + UTF8ToUTF16(privacy_link)));
|
| + if (IsPrefEnabled(prefs::kSafeBrowsingReportingEnabled))
|
| + strings->SetString(kBoxChecked, "yes");
|
| + else
|
| + strings->SetString(kBoxChecked, "");
|
| + }
|
| +
|
| + strings->SetString("learnMore",
|
| + l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MALWARE_V2_LEARN_MORE));
|
| + strings->SetString("details",
|
| + l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MALWARE_V2_DETAILS));
|
| +}
|
| +
|
| +void SafeBrowsingBlockingPageV2::PopulatePhishingStringDictionary(
|
| + DictionaryValue* strings) {
|
| + NOTREACHED();
|
| +}
|
|
|