OLD | NEW |
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 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 } | 155 } |
159 case CMD_SHOW_MORE_SECTION: { | 156 case CMD_SHOW_MORE_SECTION: { |
160 controller()->metrics_helper()->RecordUserInteraction( | 157 controller()->metrics_helper()->RecordUserInteraction( |
161 security_interstitials::MetricsHelper::SHOW_ADVANCED); | 158 security_interstitials::MetricsHelper::SHOW_ADVANCED); |
162 break; | 159 break; |
163 } | 160 } |
164 case CMD_OPEN_HELP_CENTER: { | 161 case CMD_OPEN_HELP_CENTER: { |
165 // User pressed "Learn more". | 162 // User pressed "Learn more". |
166 controller()->metrics_helper()->RecordUserInteraction( | 163 controller()->metrics_helper()->RecordUserInteraction( |
167 security_interstitials::MetricsHelper::SHOW_LEARN_MORE); | 164 security_interstitials::MetricsHelper::SHOW_LEARN_MORE); |
168 GURL learn_more_url(kLearnMore); | 165 |
| 166 GURL learn_more_url = controller()->GetBaseHelpCenterUrl(); |
169 learn_more_url = net::AppendQueryParameter( | 167 learn_more_url = net::AppendQueryParameter( |
170 learn_more_url, "p", get_help_center_article_link()); | 168 learn_more_url, "p", get_help_center_article_link()); |
171 learn_more_url = | 169 learn_more_url = |
172 google_util::AppendGoogleLocaleParam(learn_more_url, app_locale()); | 170 google_util::AppendGoogleLocaleParam(learn_more_url, app_locale()); |
173 controller()->OpenUrlInCurrentTab(learn_more_url); | 171 controller()->OpenUrlInNewForegroundTab(learn_more_url); |
174 break; | 172 break; |
175 } | 173 } |
176 case CMD_RELOAD: { | 174 case CMD_RELOAD: { |
177 controller()->metrics_helper()->RecordUserInteraction( | 175 controller()->metrics_helper()->RecordUserInteraction( |
178 security_interstitials::MetricsHelper::RELOAD); | 176 security_interstitials::MetricsHelper::RELOAD); |
179 controller()->Reload(); | 177 controller()->Reload(); |
180 break; | 178 break; |
181 } | 179 } |
182 case CMD_OPEN_REPORTING_PRIVACY: { | 180 case CMD_OPEN_REPORTING_PRIVACY: { |
183 // User pressed on the SB Extended Reporting "privacy policy" link. | 181 // User pressed on the SB Extended Reporting "privacy policy" link. |
184 controller()->OpenExtendedReportingPrivacyPolicy(); | 182 controller()->OpenExtendedReportingPrivacyPolicy(); |
185 break; | 183 break; |
186 } | 184 } |
187 case CMD_OPEN_WHITEPAPER: { | 185 case CMD_OPEN_WHITEPAPER: { |
188 controller()->OpenExtendedReportingWhitepaper(); | 186 controller()->OpenExtendedReportingWhitepaper(); |
189 break; | 187 break; |
190 } | 188 } |
191 case CMD_OPEN_DIAGNOSTIC: { | 189 case CMD_OPEN_DIAGNOSTIC: { |
192 controller()->metrics_helper()->RecordUserInteraction( | 190 controller()->metrics_helper()->RecordUserInteraction( |
193 security_interstitials::MetricsHelper::SHOW_DIAGNOSTIC); | 191 security_interstitials::MetricsHelper::SHOW_DIAGNOSTIC); |
194 std::string diagnostic = base::StringPrintf( | 192 std::string diagnostic = base::StringPrintf( |
195 kSbDiagnosticUrl, | 193 kSbDiagnosticUrl, |
196 net::EscapeQueryParamValue(request_url().spec(), true).c_str()); | 194 net::EscapeQueryParamValue(request_url().spec(), true).c_str()); |
197 GURL diagnostic_url(diagnostic); | 195 GURL diagnostic_url(diagnostic); |
198 diagnostic_url = | 196 diagnostic_url = |
199 google_util::AppendGoogleLocaleParam(diagnostic_url, app_locale()); | 197 google_util::AppendGoogleLocaleParam(diagnostic_url, app_locale()); |
200 controller()->OpenUrlInCurrentTab(diagnostic_url); | 198 controller()->OpenUrlInNewForegroundTab(diagnostic_url); |
201 break; | 199 break; |
202 } | 200 } |
203 case CMD_REPORT_PHISHING_ERROR: { | 201 case CMD_REPORT_PHISHING_ERROR: { |
204 controller()->metrics_helper()->RecordUserInteraction( | 202 controller()->metrics_helper()->RecordUserInteraction( |
205 security_interstitials::MetricsHelper::REPORT_PHISHING_ERROR); | 203 security_interstitials::MetricsHelper::REPORT_PHISHING_ERROR); |
206 GURL phishing_error_url(kReportPhishingErrorUrl); | 204 GURL phishing_error_url(kReportPhishingErrorUrl); |
207 phishing_error_url = google_util::AppendGoogleLocaleParam( | 205 phishing_error_url = google_util::AppendGoogleLocaleParam( |
208 phishing_error_url, app_locale()); | 206 phishing_error_url, app_locale()); |
209 controller()->OpenUrlInCurrentTab(phishing_error_url); | 207 controller()->OpenUrlInNewForegroundTab(phishing_error_url); |
210 break; | 208 break; |
211 } | 209 } |
212 case CMD_OPEN_DATE_SETTINGS: | 210 case CMD_OPEN_DATE_SETTINGS: |
213 case CMD_OPEN_LOGIN: | 211 case CMD_OPEN_LOGIN: |
214 case CMD_ERROR: | 212 case CMD_ERROR: |
215 case CMD_TEXT_FOUND: | 213 case CMD_TEXT_FOUND: |
216 case CMD_TEXT_NOT_FOUND: | 214 case CMD_TEXT_NOT_FOUND: |
217 break; | 215 break; |
218 } | 216 } |
219 } | 217 } |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
303 base::UTF8ToUTF16(privacy_link))); | 301 base::UTF8ToUTF16(privacy_link))); |
304 load_time_data->SetBoolean(security_interstitials::kBoxChecked, | 302 load_time_data->SetBoolean(security_interstitials::kBoxChecked, |
305 is_extended_reporting_enabled()); | 303 is_extended_reporting_enabled()); |
306 } | 304 } |
307 | 305 |
308 int SafeBrowsingLoudErrorUI::GetHTMLTemplateId() const { | 306 int SafeBrowsingLoudErrorUI::GetHTMLTemplateId() const { |
309 return IDR_SECURITY_INTERSTITIAL_HTML; | 307 return IDR_SECURITY_INTERSTITIAL_HTML; |
310 }; | 308 }; |
311 | 309 |
312 } // security_interstitials | 310 } // security_interstitials |
OLD | NEW |