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

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

Issue 10905117: Safebrowsing malware interstitial UI tweaks. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 3 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
« no previous file with comments | « chrome/browser/safe_browsing/safe_browsing_blocking_page.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/i18n/rtl.h" 12 #include "base/i18n/rtl.h"
13 #include "base/lazy_instance.h" 13 #include "base/lazy_instance.h"
14 #include "base/metrics/field_trial.h" 14 #include "base/metrics/field_trial.h"
15 #include "base/metrics/histogram.h" 15 #include "base/metrics/histogram.h"
16 #include "base/string_number_conversions.h" 16 #include "base/string_number_conversions.h"
17 #include "base/string_piece.h" 17 #include "base/string_piece.h"
18 #include "base/stringprintf.h" 18 #include "base/stringprintf.h"
19 #include "base/time.h" 19 #include "base/time.h"
20 #include "base/utf_string_conversions.h" 20 #include "base/utf_string_conversions.h"
21 #include "base/values.h" 21 #include "base/values.h"
22 #include "chrome/browser/browser_process.h" 22 #include "chrome/browser/browser_process.h"
23 #include "chrome/browser/google/google_util.h" 23 #include "chrome/browser/google/google_util.h"
24 #include "chrome/browser/prefs/pref_service.h" 24 #include "chrome/browser/prefs/pref_service.h"
25 #include "chrome/browser/profiles/profile.h" 25 #include "chrome/browser/profiles/profile.h"
26 #include "chrome/browser/renderer_preferences_util.h" 26 #include "chrome/browser/renderer_preferences_util.h"
27 #include "chrome/browser/safe_browsing/malware_details.h" 27 #include "chrome/browser/safe_browsing/malware_details.h"
28 #include "chrome/browser/safe_browsing/safe_browsing_service.h" 28 #include "chrome/browser/safe_browsing/safe_browsing_service.h"
29 #include "chrome/browser/tab_contents/tab_util.h" 29 #include "chrome/browser/tab_contents/tab_util.h"
30 #include "chrome/browser/ui/webui/ntp/new_tab_ui.h" 30 #include "chrome/browser/ui/webui/chrome_url_data_manager.h"
31 #include "chrome/common/jstemplate_builder.h" 31 #include "chrome/common/jstemplate_builder.h"
32 #include "chrome/common/pref_names.h" 32 #include "chrome/common/pref_names.h"
33 #include "chrome/common/url_constants.h" 33 #include "chrome/common/url_constants.h"
34 #include "content/public/browser/browser_thread.h" 34 #include "content/public/browser/browser_thread.h"
35 #include "content/public/browser/interstitial_page.h" 35 #include "content/public/browser/interstitial_page.h"
36 #include "content/public/browser/navigation_controller.h" 36 #include "content/public/browser/navigation_controller.h"
37 #include "content/public/browser/user_metrics.h" 37 #include "content/public/browser/user_metrics.h"
38 #include "content/public/browser/web_contents.h" 38 #include "content/public/browser/web_contents.h"
39 #include "grit/browser_resources.h" 39 #include "grit/browser_resources.h"
40 #include "grit/chromium_strings.h" 40 #include "grit/chromium_strings.h"
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 static const char* const kShowDiagnosticCommand = "showDiagnostic"; 98 static const char* const kShowDiagnosticCommand = "showDiagnostic";
99 static const char* const kReportErrorCommand = "reportError"; 99 static const char* const kReportErrorCommand = "reportError";
100 static const char* const kLearnMoreCommand = "learnMore"; 100 static const char* const kLearnMoreCommand = "learnMore";
101 static const char* const kLearnMoreCommandV2 = "learnMore2"; 101 static const char* const kLearnMoreCommandV2 = "learnMore2";
102 static const char* const kShowPrivacyCommand = "showPrivacy"; 102 static const char* const kShowPrivacyCommand = "showPrivacy";
103 static const char* const kProceedCommand = "proceed"; 103 static const char* const kProceedCommand = "proceed";
104 static const char* const kTakeMeBackCommand = "takeMeBack"; 104 static const char* const kTakeMeBackCommand = "takeMeBack";
105 static const char* const kDoReportCommand = "doReport"; 105 static const char* const kDoReportCommand = "doReport";
106 static const char* const kDontReportCommand = "dontReport"; 106 static const char* const kDontReportCommand = "dontReport";
107 static const char* const kDisplayCheckBox = "displaycheckbox"; 107 static const char* const kDisplayCheckBox = "displaycheckbox";
108 static const char* const kDisplayShowDiagnostic = "displayShowDiagnostic";
109 static const char* const kBoxChecked = "boxchecked"; 108 static const char* const kBoxChecked = "boxchecked";
110 static const char* const kExpandedSeeMore = "expandedSeeMore"; 109 static const char* const kExpandedSeeMore = "expandedSeeMore";
111 // Special command that we use when the user navigated away from the 110 // Special command that we use when the user navigated away from the
112 // page. E.g., closed the tab or the window. This is only used by 111 // page. E.g., closed the tab or the window. This is only used by
113 // RecordUserReactionTime. 112 // RecordUserReactionTime.
114 static const char* const kNavigatedAwayMetaCommand = "closed"; 113 static const char* const kNavigatedAwayMetaCommand = "closed";
115 114
116 // static 115 // static
117 SafeBrowsingBlockingPageFactory* SafeBrowsingBlockingPage::factory_ = NULL; 116 SafeBrowsingBlockingPageFactory* SafeBrowsingBlockingPage::factory_ = NULL;
118 117
(...skipping 921 matching lines...) Expand 10 before | Expand all | Expand 10 after
1040 interstitial_show_time_ = base::TimeTicks::Now(); 1039 interstitial_show_time_ = base::TimeTicks::Now();
1041 return jstemplate_builder::GetTemplatesHtml(html, &strings, "template-root"); 1040 return jstemplate_builder::GetTemplatesHtml(html, &strings, "template-root");
1042 } 1041 }
1043 1042
1044 void SafeBrowsingBlockingPageV2::PopulateStringDictionary( 1043 void SafeBrowsingBlockingPageV2::PopulateStringDictionary(
1045 DictionaryValue* strings, 1044 DictionaryValue* strings,
1046 const string16& title, 1045 const string16& title,
1047 const string16& headline, 1046 const string16& headline,
1048 const string16& description1, 1047 const string16& description1,
1049 const string16& description2, 1048 const string16& description2,
1050 const string16& description3, 1049 const string16& description3) {
1051 const string16& description4) {
1052 strings->SetString("title", title); 1050 strings->SetString("title", title);
1053 strings->SetString("headLine", headline); 1051 strings->SetString("headLine", headline);
1054 strings->SetString("description1", description1); 1052 strings->SetString("description1", description1);
1055 strings->SetString("description2", description2); 1053 strings->SetString("description2", description2);
1056 strings->SetString("description3", description3); 1054 strings->SetString("description3", description3);
1057 strings->SetString("description4", description4);
1058 strings->SetBoolean("proceedDisabled", 1055 strings->SetBoolean("proceedDisabled",
1059 IsPrefEnabled(prefs::kSafeBrowsingProceedAnywayDisabled)); 1056 IsPrefEnabled(prefs::kSafeBrowsingProceedAnywayDisabled));
1057 strings->SetBoolean("isMainFrame", is_main_frame_load_blocked_);
1060 1058
1061 strings->SetString("textdirection", base::i18n::IsRTL() ? "rtl" : "ltr");
1062 strings->SetString("back_button", 1059 strings->SetString("back_button",
1063 l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MALWARE_BACK_BUTTON)); 1060 l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MALWARE_BACK_BUTTON));
1064 strings->SetString("seeMore", l10n_util::GetStringUTF16( 1061 strings->SetString("seeMore", l10n_util::GetStringUTF16(
1065 IDS_SAFE_BROWSING_MALWARE_V2_SEE_MORE)); 1062 IDS_SAFE_BROWSING_MALWARE_V2_SEE_MORE));
1066 strings->SetString("seeLess", l10n_util::GetStringUTF16( 1063
1067 IDS_SAFE_BROWSING_MALWARE_V2_SEE_LESS)); 1064 ChromeURLDataManager::DataSource::SetFontAndTextDirection(strings);
1068 } 1065 }
1069 1066
1070 void SafeBrowsingBlockingPageV2::PopulateMultipleThreatStringDictionary( 1067 void SafeBrowsingBlockingPageV2::PopulateMultipleThreatStringDictionary(
1071 DictionaryValue* strings) { 1068 DictionaryValue* strings) {
1072 NOTREACHED(); 1069 NOTREACHED();
1073 } 1070 }
1074 1071
1075 void SafeBrowsingBlockingPageV2::PopulateMalwareStringDictionary( 1072 void SafeBrowsingBlockingPageV2::PopulateMalwareStringDictionary(
1076 DictionaryValue* strings) { 1073 DictionaryValue* strings) {
1077 std::string diagnostic_link = base::StringPrintf(kSbDiagnosticHtml, 1074 std::string diagnostic_link = base::StringPrintf(kSbDiagnosticHtml,
1078 l10n_util::GetStringUTF8( 1075 l10n_util::GetStringUTF8(
1079 IDS_SAFE_BROWSING_MALWARE_DIAGNOSTIC_PAGE).c_str()); 1076 IDS_SAFE_BROWSING_MALWARE_DIAGNOSTIC_PAGE).c_str());
1080 1077
1081 // Check to see if we're blocking the main page, or a sub-resource on the 1078 // Check to see if we're blocking the main page, or a sub-resource on the
1082 // main page. 1079 // main page.
1083 string16 headline, description1, description2, description3, description4; 1080 string16 headline, description1, description2, description3;
1084 1081
1085 1082
1083 description3 = l10n_util::GetStringUTF16(
1084 IDS_SAFE_BROWSING_MALWARE_V2_DESCRIPTION3);
1086 if (is_main_frame_load_blocked_) { 1085 if (is_main_frame_load_blocked_) {
1087 headline = l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MALWARE_V2_HEADLINE); 1086 headline = l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MALWARE_V2_HEADLINE);
1088 description1 = l10n_util::GetStringFUTF16( 1087 description1 = l10n_util::GetStringFUTF16(
1089 IDS_SAFE_BROWSING_MALWARE_V2_DESCRIPTION1, 1088 IDS_SAFE_BROWSING_MALWARE_V2_DESCRIPTION1,
1090 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME), 1089 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME),
1091 UTF8ToUTF16(url_.host())); 1090 UTF8ToUTF16(url_.host()));
1092 description2 = l10n_util::GetStringUTF16( 1091 description2 = l10n_util::GetStringUTF16(
1093 IDS_SAFE_BROWSING_MALWARE_V2_DESCRIPTION2); 1092 IDS_SAFE_BROWSING_MALWARE_V2_DESCRIPTION2);
1094 description3 = l10n_util::GetStringUTF16( 1093 strings->SetString("details", l10n_util::GetStringUTF16(
1095 IDS_SAFE_BROWSING_MALWARE_V2_DESCRIPTION3); 1094 IDS_SAFE_BROWSING_MALWARE_V2_DETAILS));
1096 description4 = l10n_util::GetStringUTF16(
1097 IDS_SAFE_BROWSING_MALWARE_V2_DESCRIPTION4);
1098 strings->SetBoolean(kDisplayShowDiagnostic, true);
1099 } else { 1095 } else {
1100 headline = l10n_util::GetStringUTF16( 1096 headline = l10n_util::GetStringUTF16(
1101 IDS_SAFE_BROWSING_MALWARE_V2_HEADLINE_SUBRESOURCE); 1097 IDS_SAFE_BROWSING_MALWARE_V2_HEADLINE_SUBRESOURCE);
1102 description1 = l10n_util::GetStringFUTF16( 1098 description1 = l10n_util::GetStringFUTF16(
1103 IDS_SAFE_BROWSING_MALWARE_V2_DESCRIPTION1_SUBRESOURCE, 1099 IDS_SAFE_BROWSING_MALWARE_V2_DESCRIPTION1_SUBRESOURCE,
1104 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME), 1100 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME),
1105 UTF8ToUTF16(web_contents_->GetURL().host())); 1101 UTF8ToUTF16(web_contents_->GetURL().host()));
1106 description2 = l10n_util::GetStringUTF16( 1102 description2 = l10n_util::GetStringFUTF16(
1107 IDS_SAFE_BROWSING_MALWARE_V2_DESCRIPTION2_SUBRESOURCE); 1103 IDS_SAFE_BROWSING_MALWARE_V2_DESCRIPTION2_SUBRESOURCE,
1108 description3 = l10n_util::GetStringUTF16( 1104 UTF8ToUTF16(url_.host()));
1109 IDS_SAFE_BROWSING_MALWARE_V2_DESCRIPTION3_SUBRESOURCE); 1105 strings->SetString("details", l10n_util::GetStringFUTF16(
1110 description4 = l10n_util::GetStringFUTF16( 1106 IDS_SAFE_BROWSING_MALWARE_V2_DETAILS_SUBRESOURCE,
1111 IDS_SAFE_BROWSING_MALWARE_V2_DESCRIPTION4_SUBRESOURCE, 1107 UTF8ToUTF16(url_.host())));
1112 UTF8ToUTF16(url_.host()));
1113 strings->SetBoolean(kDisplayShowDiagnostic, false);
1114 } 1108 }
1115 1109
1116 PopulateStringDictionary( 1110 PopulateStringDictionary(
1117 strings, 1111 strings,
1118 l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MALWARE_V2_TITLE), 1112 l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MALWARE_V2_TITLE),
1119 headline, 1113 headline,
1120 description1, 1114 description1,
1121 description2, 1115 description2,
1122 description3, 1116 description3);
1123 description4);
1124 1117
1125 if (!CanShowMalwareDetailsOption()) { 1118 if (!CanShowMalwareDetailsOption()) {
1126 strings->SetBoolean(kDisplayCheckBox, false); 1119 strings->SetBoolean(kDisplayCheckBox, false);
1127 } else { 1120 } else {
1128 // Show the checkbox for sending malware details. 1121 // Show the checkbox for sending malware details.
1129 strings->SetBoolean(kDisplayCheckBox, true); 1122 strings->SetBoolean(kDisplayCheckBox, true);
1130 1123
1131 std::string privacy_link = base::StringPrintf( 1124 std::string privacy_link = base::StringPrintf(
1132 kPrivacyLinkHtml, 1125 kPrivacyLinkHtml,
1133 l10n_util::GetStringUTF8( 1126 l10n_util::GetStringUTF8(
1134 IDS_SAFE_BROWSING_PRIVACY_POLICY_PAGE_V2).c_str()); 1127 IDS_SAFE_BROWSING_PRIVACY_POLICY_PAGE_V2).c_str());
1135 1128
1136 strings->SetString("confirm_text", 1129 strings->SetString("confirm_text",
1137 l10n_util::GetStringFUTF16( 1130 l10n_util::GetStringFUTF16(
1138 IDS_SAFE_BROWSING_MALWARE_V2_REPORTING_AGREE, 1131 IDS_SAFE_BROWSING_MALWARE_V2_REPORTING_AGREE,
1139 UTF8ToUTF16(privacy_link))); 1132 UTF8ToUTF16(privacy_link)));
1140 if (IsPrefEnabled(prefs::kSafeBrowsingReportingEnabled)) 1133 if (IsPrefEnabled(prefs::kSafeBrowsingReportingEnabled))
1141 strings->SetString(kBoxChecked, "yes"); 1134 strings->SetString(kBoxChecked, "yes");
1142 else 1135 else
1143 strings->SetString(kBoxChecked, ""); 1136 strings->SetString(kBoxChecked, "");
1144 } 1137 }
1145 1138
1139 strings->SetString("proceed",
1140 l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MALWARE_V2_PROCEED_LINK));
1146 strings->SetString("learnMore", 1141 strings->SetString("learnMore",
1147 l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MALWARE_V2_LEARN_MORE)); 1142 l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MALWARE_V2_LEARN_MORE));
1148 strings->SetString("details",
1149 l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MALWARE_V2_DETAILS));
1150 } 1143 }
1151 1144
1152 void SafeBrowsingBlockingPageV2::PopulatePhishingStringDictionary( 1145 void SafeBrowsingBlockingPageV2::PopulatePhishingStringDictionary(
1153 DictionaryValue* strings) { 1146 DictionaryValue* strings) {
1154 NOTREACHED(); 1147 NOTREACHED();
1155 } 1148 }
OLDNEW
« no previous file with comments | « chrome/browser/safe_browsing/safe_browsing_blocking_page.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698