OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/controller_client.h" | 5 #include "components/security_interstitials/core/controller_client.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "components/google/core/browser/google_util.h" | 9 #include "components/google/core/browser/google_util.h" |
10 #include "components/prefs/pref_service.h" | 10 #include "components/prefs/pref_service.h" |
11 #include "components/security_interstitials/core/metrics_helper.h" | 11 #include "components/security_interstitials/core/metrics_helper.h" |
12 #include "components/security_interstitials/core/urls.h" | 12 #include "components/security_interstitials/core/urls.h" |
13 #include "components/strings/grit/components_strings.h" | 13 #include "components/strings/grit/components_strings.h" |
14 #include "ui/base/l10n/l10n_util.h" | 14 #include "ui/base/l10n/l10n_util.h" |
15 #include "url/gurl.h" | |
16 | 15 |
17 namespace security_interstitials { | 16 namespace security_interstitials { |
18 | 17 |
19 const char kBoxChecked[] = "boxchecked"; | 18 const char kBoxChecked[] = "boxchecked"; |
20 const char kDisplayCheckBox[] = "displaycheckbox"; | 19 const char kDisplayCheckBox[] = "displaycheckbox"; |
21 const char kOptInLink[] = "optInLink"; | 20 const char kOptInLink[] = "optInLink"; |
22 const char kPrivacyLinkHtml[] = | 21 const char kPrivacyLinkHtml[] = |
23 "<a id=\"privacy-link\" href=\"#\" onclick=\"sendCommand(%d); " | 22 "<a id=\"privacy-link\" href=\"#\" onclick=\"sendCommand(%d); " |
24 "return false;\" onmousedown=\"return false;\">%s</a>"; | 23 "return false;\" onmousedown=\"return false;\">%s</a>"; |
| 24 const char kHelpCenterUrl[] = "https://support.google.com/chrome/"; |
25 | 25 |
26 ControllerClient::ControllerClient( | 26 ControllerClient::ControllerClient( |
27 std::unique_ptr<MetricsHelper> metrics_helper) | 27 std::unique_ptr<MetricsHelper> metrics_helper) |
28 : metrics_helper_(std::move(metrics_helper)) {} | 28 : metrics_helper_(std::move(metrics_helper)), |
| 29 help_center_url_(kHelpCenterUrl) {} |
29 | 30 |
30 ControllerClient::~ControllerClient() {} | 31 ControllerClient::~ControllerClient() {} |
31 | 32 |
32 MetricsHelper* ControllerClient::metrics_helper() const { | 33 MetricsHelper* ControllerClient::metrics_helper() const { |
33 return metrics_helper_.get(); | 34 return metrics_helper_.get(); |
34 } | 35 } |
35 | 36 |
36 void ControllerClient::SetReportingPreference(bool report) { | 37 void ControllerClient::SetReportingPreference(bool report) { |
37 GetPrefService()->SetBoolean(GetExtendedReportingPrefName(), report); | 38 GetPrefService()->SetBoolean(GetExtendedReportingPrefName(), report); |
38 metrics_helper_->RecordUserInteraction( | 39 metrics_helper_->RecordUserInteraction( |
39 report ? MetricsHelper::SET_EXTENDED_REPORTING_ENABLED | 40 report ? MetricsHelper::SET_EXTENDED_REPORTING_ENABLED |
40 : MetricsHelper::SET_EXTENDED_REPORTING_DISABLED); | 41 : MetricsHelper::SET_EXTENDED_REPORTING_DISABLED); |
41 } | 42 } |
42 | 43 |
43 void ControllerClient::OpenExtendedReportingPrivacyPolicy() { | 44 void ControllerClient::OpenExtendedReportingPrivacyPolicy() { |
44 metrics_helper_->RecordUserInteraction(MetricsHelper::SHOW_PRIVACY_POLICY); | 45 metrics_helper_->RecordUserInteraction(MetricsHelper::SHOW_PRIVACY_POLICY); |
45 GURL privacy_url(kSafeBrowsingPrivacyPolicyUrl); | 46 GURL privacy_url(kSafeBrowsingPrivacyPolicyUrl); |
46 privacy_url = | 47 privacy_url = |
47 google_util::AppendGoogleLocaleParam(privacy_url, GetApplicationLocale()); | 48 google_util::AppendGoogleLocaleParam(privacy_url, GetApplicationLocale()); |
48 OpenUrlInCurrentTab(privacy_url); | 49 OpenUrlInNewForegroundTab(privacy_url); |
49 } | 50 } |
50 | 51 |
51 void ControllerClient::OpenExtendedReportingWhitepaper() { | 52 void ControllerClient::OpenExtendedReportingWhitepaper() { |
52 metrics_helper_->RecordUserInteraction(MetricsHelper::SHOW_WHITEPAPER); | 53 metrics_helper_->RecordUserInteraction(MetricsHelper::SHOW_WHITEPAPER); |
53 GURL whitepaper_url(kSafeBrowsingWhitePaperUrl); | 54 GURL whitepaper_url(kSafeBrowsingWhitePaperUrl); |
54 whitepaper_url = google_util::AppendGoogleLocaleParam(whitepaper_url, | 55 whitepaper_url = google_util::AppendGoogleLocaleParam(whitepaper_url, |
55 GetApplicationLocale()); | 56 GetApplicationLocale()); |
56 OpenUrlInCurrentTab(whitepaper_url); | 57 OpenUrlInNewForegroundTab(whitepaper_url); |
| 58 } |
| 59 |
| 60 GURL ControllerClient::GetBaseHelpCenterUrl() const { |
| 61 return help_center_url_; |
| 62 } |
| 63 |
| 64 void ControllerClient::SetBaseHelpCenterUrlForTesting(const GURL& test_url) { |
| 65 help_center_url_ = test_url; |
57 } | 66 } |
58 | 67 |
59 } // namespace security_interstitials | 68 } // namespace security_interstitials |
OLD | NEW |