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

Side by Side Diff: components/security_interstitials/core/safe_browsing_loud_error_ui.cc

Issue 2955503002: Make interstitial links open in a new tab (Closed)
Patch Set: Fix compilation error Created 3 years, 5 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 #include "components/security_interstitials/core/safe_browsing_loud_error_ui.h" 5 #include "components/security_interstitials/core/safe_browsing_loud_error_ui.h"
6 6
7 #include "base/i18n/time_formatting.h" 7 #include "base/i18n/time_formatting.h"
8 #include "base/metrics/histogram_macros.h" 8 #include "base/metrics/histogram_macros.h"
9 #include "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
11 #include "components/google/core/browser/google_util.h" 11 #include "components/google/core/browser/google_util.h"
12 #include "components/grit/components_resources.h" 12 #include "components/grit/components_resources.h"
13 #include "components/security_interstitials/core/common_string_util.h" 13 #include "components/security_interstitials/core/common_string_util.h"
14 #include "components/security_interstitials/core/metrics_helper.h" 14 #include "components/security_interstitials/core/metrics_helper.h"
15 #include "components/strings/grit/components_strings.h" 15 #include "components/strings/grit/components_strings.h"
16 #include "net/base/escape.h" 16 #include "net/base/escape.h"
17 #include "net/base/url_util.h" 17 #include "net/base/url_util.h"
18 #include "ui/base/l10n/l10n_util.h" 18 #include "ui/base/l10n/l10n_util.h"
19 19
20 namespace security_interstitials { 20 namespace security_interstitials {
21 namespace { 21 namespace {
22 22
23 // URL for the Help Center
24 const char kLearnMore[] = "https://support.google.com/chrome/";
25
26 // For malware interstitial pages, we link the problematic URL to Google's 23 // For malware interstitial pages, we link the problematic URL to Google's
27 // diagnostic page. 24 // diagnostic page.
28 #if defined(GOOGLE_CHROME_BUILD) 25 #if defined(GOOGLE_CHROME_BUILD)
29 const char kSbDiagnosticUrl[] = 26 const char kSbDiagnosticUrl[] =
30 "https://www.google.com/safebrowsing/" 27 "https://www.google.com/safebrowsing/"
31 "diagnostic?site=%s&client=googlechrome"; 28 "diagnostic?site=%s&client=googlechrome";
32 #else 29 #else
33 const char kSbDiagnosticUrl[] = 30 const char kSbDiagnosticUrl[] =
34 "https://www.google.com/safebrowsing/diagnostic?site=%s&client=chromium"; 31 "https://www.google.com/safebrowsing/diagnostic?site=%s&client=chromium";
35 #endif 32 #endif
(...skipping 27 matching lines...) Expand all
63 : BaseSafeBrowsingErrorUI(request_url, 60 : BaseSafeBrowsingErrorUI(request_url,
64 main_frame_url, 61 main_frame_url,
65 reason, 62 reason,
66 display_options, 63 display_options,
67 app_locale, 64 app_locale,
68 time_triggered, 65 time_triggered,
69 controller) { 66 controller) {
70 controller->metrics_helper()->RecordUserDecision(MetricsHelper::SHOW); 67 controller->metrics_helper()->RecordUserDecision(MetricsHelper::SHOW);
71 controller->metrics_helper()->RecordUserInteraction( 68 controller->metrics_helper()->RecordUserInteraction(
72 MetricsHelper::TOTAL_VISITS); 69 MetricsHelper::TOTAL_VISITS);
73 if (is_proceed_anyway_disabled()) 70 if (is_proceed_anyway_disabled()) {
74 controller->metrics_helper()->RecordUserDecision( 71 controller->metrics_helper()->RecordUserDecision(
75 security_interstitials::MetricsHelper::PROCEEDING_DISABLED); 72 security_interstitials::MetricsHelper::PROCEEDING_DISABLED);
73 }
76 } 74 }
77 75
78 SafeBrowsingLoudErrorUI::~SafeBrowsingLoudErrorUI() { 76 SafeBrowsingLoudErrorUI::~SafeBrowsingLoudErrorUI() {
79 controller()->metrics_helper()->RecordShutdownMetrics(); 77 controller()->metrics_helper()->RecordShutdownMetrics();
80 } 78 }
81 79
82 void SafeBrowsingLoudErrorUI::PopulateStringsForHtml( 80 void SafeBrowsingLoudErrorUI::PopulateStringsForHtml(
83 base::DictionaryValue* load_time_data) { 81 base::DictionaryValue* load_time_data) {
84 DCHECK(load_time_data); 82 DCHECK(load_time_data);
85 83
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 } 156 }
159 case CMD_SHOW_MORE_SECTION: { 157 case CMD_SHOW_MORE_SECTION: {
160 controller()->metrics_helper()->RecordUserInteraction( 158 controller()->metrics_helper()->RecordUserInteraction(
161 security_interstitials::MetricsHelper::SHOW_ADVANCED); 159 security_interstitials::MetricsHelper::SHOW_ADVANCED);
162 break; 160 break;
163 } 161 }
164 case CMD_OPEN_HELP_CENTER: { 162 case CMD_OPEN_HELP_CENTER: {
165 // User pressed "Learn more". 163 // User pressed "Learn more".
166 controller()->metrics_helper()->RecordUserInteraction( 164 controller()->metrics_helper()->RecordUserInteraction(
167 security_interstitials::MetricsHelper::SHOW_LEARN_MORE); 165 security_interstitials::MetricsHelper::SHOW_LEARN_MORE);
168 GURL learn_more_url(kLearnMore); 166
167 GURL learn_more_url = controller()->GetBaseHelpCenterUrl();
169 learn_more_url = net::AppendQueryParameter( 168 learn_more_url = net::AppendQueryParameter(
170 learn_more_url, "p", get_help_center_article_link()); 169 learn_more_url, "p", get_help_center_article_link());
171 learn_more_url = 170 learn_more_url =
172 google_util::AppendGoogleLocaleParam(learn_more_url, app_locale()); 171 google_util::AppendGoogleLocaleParam(learn_more_url, app_locale());
173 controller()->OpenUrlInCurrentTab(learn_more_url); 172 OpenURL(learn_more_url);
174 break; 173 break;
175 } 174 }
176 case CMD_RELOAD: { 175 case CMD_RELOAD: {
177 controller()->metrics_helper()->RecordUserInteraction( 176 controller()->metrics_helper()->RecordUserInteraction(
178 security_interstitials::MetricsHelper::RELOAD); 177 security_interstitials::MetricsHelper::RELOAD);
179 controller()->Reload(); 178 controller()->Reload();
180 break; 179 break;
181 } 180 }
182 case CMD_OPEN_REPORTING_PRIVACY: { 181 case CMD_OPEN_REPORTING_PRIVACY: {
183 // User pressed on the SB Extended Reporting "privacy policy" link. 182 // User pressed on the SB Extended Reporting "privacy policy" link.
184 controller()->OpenExtendedReportingPrivacyPolicy(); 183 controller()->OpenExtendedReportingPrivacyPolicy();
185 break; 184 break;
186 } 185 }
187 case CMD_OPEN_WHITEPAPER: { 186 case CMD_OPEN_WHITEPAPER: {
188 controller()->OpenExtendedReportingWhitepaper(); 187 controller()->OpenExtendedReportingWhitepaper();
189 break; 188 break;
190 } 189 }
191 case CMD_OPEN_DIAGNOSTIC: { 190 case CMD_OPEN_DIAGNOSTIC: {
192 controller()->metrics_helper()->RecordUserInteraction( 191 controller()->metrics_helper()->RecordUserInteraction(
193 security_interstitials::MetricsHelper::SHOW_DIAGNOSTIC); 192 security_interstitials::MetricsHelper::SHOW_DIAGNOSTIC);
194 std::string diagnostic = base::StringPrintf( 193 std::string diagnostic = base::StringPrintf(
195 kSbDiagnosticUrl, 194 kSbDiagnosticUrl,
196 net::EscapeQueryParamValue(request_url().spec(), true).c_str()); 195 net::EscapeQueryParamValue(request_url().spec(), true).c_str());
197 GURL diagnostic_url(diagnostic); 196 GURL diagnostic_url(diagnostic);
198 diagnostic_url = 197 diagnostic_url =
199 google_util::AppendGoogleLocaleParam(diagnostic_url, app_locale()); 198 google_util::AppendGoogleLocaleParam(diagnostic_url, app_locale());
200 controller()->OpenUrlInCurrentTab(diagnostic_url); 199 OpenURL(diagnostic_url);
201 break; 200 break;
202 } 201 }
203 case CMD_REPORT_PHISHING_ERROR: { 202 case CMD_REPORT_PHISHING_ERROR: {
204 controller()->metrics_helper()->RecordUserInteraction( 203 controller()->metrics_helper()->RecordUserInteraction(
205 security_interstitials::MetricsHelper::REPORT_PHISHING_ERROR); 204 security_interstitials::MetricsHelper::REPORT_PHISHING_ERROR);
206 GURL phishing_error_url(kReportPhishingErrorUrl); 205 GURL phishing_error_url(kReportPhishingErrorUrl);
207 phishing_error_url = google_util::AppendGoogleLocaleParam( 206 phishing_error_url = google_util::AppendGoogleLocaleParam(
208 phishing_error_url, app_locale()); 207 phishing_error_url, app_locale());
209 controller()->OpenUrlInCurrentTab(phishing_error_url); 208 OpenURL(phishing_error_url);
210 break; 209 break;
211 } 210 }
212 case CMD_OPEN_DATE_SETTINGS: 211 case CMD_OPEN_DATE_SETTINGS:
213 case CMD_OPEN_LOGIN: 212 case CMD_OPEN_LOGIN:
214 case CMD_ERROR: 213 case CMD_ERROR:
215 case CMD_TEXT_FOUND: 214 case CMD_TEXT_FOUND:
216 case CMD_TEXT_NOT_FOUND: 215 case CMD_TEXT_NOT_FOUND:
217 break; 216 break;
218 } 217 }
219 } 218 }
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 load_time_data->SetString( 280 load_time_data->SetString(
282 "finalParagraph", 281 "finalParagraph",
283 l10n_util::GetStringUTF16(IDS_PHISHING_V4_PROCEED_AND_REPORT_PARAGRAPH)); 282 l10n_util::GetStringUTF16(IDS_PHISHING_V4_PROCEED_AND_REPORT_PARAGRAPH));
284 } 283 }
285 284
286 void SafeBrowsingLoudErrorUI::PopulateExtendedReportingOption( 285 void SafeBrowsingLoudErrorUI::PopulateExtendedReportingOption(
287 base::DictionaryValue* load_time_data) { 286 base::DictionaryValue* load_time_data) {
288 bool can_show_extended_reporting_option = CanShowExtendedReportingOption(); 287 bool can_show_extended_reporting_option = CanShowExtendedReportingOption();
289 load_time_data->SetBoolean(security_interstitials::kDisplayCheckBox, 288 load_time_data->SetBoolean(security_interstitials::kDisplayCheckBox,
290 can_show_extended_reporting_option); 289 can_show_extended_reporting_option);
291 if (!can_show_extended_reporting_option) 290 if (!can_show_extended_reporting_option) {
292 return; 291 return;
292 }
293 293
294 const std::string privacy_link = base::StringPrintf( 294 const std::string privacy_link = base::StringPrintf(
295 security_interstitials::kPrivacyLinkHtml, 295 security_interstitials::kPrivacyLinkHtml,
296 security_interstitials::CMD_OPEN_REPORTING_PRIVACY, 296 security_interstitials::CMD_OPEN_REPORTING_PRIVACY,
297 l10n_util::GetStringUTF8(IDS_SAFE_BROWSING_PRIVACY_POLICY_PAGE).c_str()); 297 l10n_util::GetStringUTF8(IDS_SAFE_BROWSING_PRIVACY_POLICY_PAGE).c_str());
298 load_time_data->SetString(security_interstitials::kOptInLink, 298 load_time_data->SetString(security_interstitials::kOptInLink,
299 l10n_util::GetStringFUTF16( 299 l10n_util::GetStringFUTF16(
300 is_scout_reporting_enabled() 300 is_scout_reporting_enabled()
301 ? IDS_SAFE_BROWSING_SCOUT_REPORTING_AGREE 301 ? IDS_SAFE_BROWSING_SCOUT_REPORTING_AGREE
302 : IDS_SAFE_BROWSING_MALWARE_REPORTING_AGREE, 302 : IDS_SAFE_BROWSING_MALWARE_REPORTING_AGREE,
303 base::UTF8ToUTF16(privacy_link))); 303 base::UTF8ToUTF16(privacy_link)));
304 load_time_data->SetBoolean(security_interstitials::kBoxChecked, 304 load_time_data->SetBoolean(security_interstitials::kBoxChecked,
305 is_extended_reporting_enabled()); 305 is_extended_reporting_enabled());
306 } 306 }
307 307
308 void SafeBrowsingLoudErrorUI::OpenURL(const GURL& url) {
309 if (should_open_links_in_new_tab()) {
310 controller()->OpenUrlInNewForegroundTab(url);
311 } else {
312 controller()->OpenUrlInCurrentTab(url);
313 }
314 }
315
308 int SafeBrowsingLoudErrorUI::GetHTMLTemplateId() const { 316 int SafeBrowsingLoudErrorUI::GetHTMLTemplateId() const {
309 return IDR_SECURITY_INTERSTITIAL_HTML; 317 return IDR_SECURITY_INTERSTITIAL_HTML;
310 }; 318 };
311 319
312 } // security_interstitials 320 } // security_interstitials
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698