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> |
| 8 |
7 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
8 #include "components/google/core/browser/google_util.h" | 10 #include "components/google/core/browser/google_util.h" |
9 #include "components/security_interstitials/core/metrics_helper.h" | 11 #include "components/security_interstitials/core/metrics_helper.h" |
10 #include "grit/components_strings.h" | 12 #include "grit/components_strings.h" |
11 #include "ui/base/l10n/l10n_util.h" | 13 #include "ui/base/l10n/l10n_util.h" |
12 #include "url/gurl.h" | 14 #include "url/gurl.h" |
13 | 15 |
14 namespace security_interstitials { | 16 namespace security_interstitials { |
15 | 17 |
16 const char kBoxChecked[] = "boxchecked"; | 18 const char kBoxChecked[] = "boxchecked"; |
17 const char kDisplayCheckBox[] = "displaycheckbox"; | 19 const char kDisplayCheckBox[] = "displaycheckbox"; |
18 const char kOptInLink[] = "optInLink"; | 20 const char kOptInLink[] = "optInLink"; |
19 const char kPrivacyLinkHtml[] = | 21 const char kPrivacyLinkHtml[] = |
20 "<a id=\"privacy-link\" href=\"\" onclick=\"sendCommand(%d); " | 22 "<a id=\"privacy-link\" href=\"\" onclick=\"sendCommand(%d); " |
21 "return false;\" onmousedown=\"return false;\">%s</a>"; | 23 "return false;\" onmousedown=\"return false;\">%s</a>"; |
22 | 24 |
23 ControllerClient::ControllerClient() {} | 25 ControllerClient::ControllerClient() {} |
24 ControllerClient::~ControllerClient() {} | 26 ControllerClient::~ControllerClient() {} |
25 | 27 |
26 MetricsHelper* ControllerClient::metrics_helper() const { | 28 MetricsHelper* ControllerClient::metrics_helper() const { |
27 return metrics_helper_.get(); | 29 return metrics_helper_.get(); |
28 } | 30 } |
29 | 31 |
30 void ControllerClient::set_metrics_helper( | 32 void ControllerClient::set_metrics_helper( |
31 scoped_ptr<MetricsHelper> metrics_helper) { | 33 scoped_ptr<MetricsHelper> metrics_helper) { |
32 metrics_helper_ = metrics_helper.Pass(); | 34 metrics_helper_ = std::move(metrics_helper); |
33 } | 35 } |
34 | 36 |
35 void ControllerClient::SetReportingPreference(bool report) { | 37 void ControllerClient::SetReportingPreference(bool report) { |
36 GetPrefService()->SetBoolean(GetExtendedReportingPrefName(), report); | 38 GetPrefService()->SetBoolean(GetExtendedReportingPrefName(), report); |
37 metrics_helper_->RecordUserInteraction( | 39 metrics_helper_->RecordUserInteraction( |
38 report ? MetricsHelper::SET_EXTENDED_REPORTING_ENABLED | 40 report ? MetricsHelper::SET_EXTENDED_REPORTING_ENABLED |
39 : MetricsHelper::SET_EXTENDED_REPORTING_DISABLED); | 41 : MetricsHelper::SET_EXTENDED_REPORTING_DISABLED); |
40 } | 42 } |
41 | 43 |
42 void ControllerClient::OpenExtendedReportingPrivacyPolicy() { | 44 void ControllerClient::OpenExtendedReportingPrivacyPolicy() { |
43 metrics_helper_->RecordUserInteraction(MetricsHelper::SHOW_PRIVACY_POLICY); | 45 metrics_helper_->RecordUserInteraction(MetricsHelper::SHOW_PRIVACY_POLICY); |
44 GURL privacy_url( | 46 GURL privacy_url( |
45 l10n_util::GetStringUTF8(IDS_SAFE_BROWSING_PRIVACY_POLICY_URL)); | 47 l10n_util::GetStringUTF8(IDS_SAFE_BROWSING_PRIVACY_POLICY_URL)); |
46 privacy_url = | 48 privacy_url = |
47 google_util::AppendGoogleLocaleParam(privacy_url, GetApplicationLocale()); | 49 google_util::AppendGoogleLocaleParam(privacy_url, GetApplicationLocale()); |
48 OpenUrlInCurrentTab(privacy_url); | 50 OpenUrlInCurrentTab(privacy_url); |
49 } | 51 } |
50 | 52 |
51 } // namespace security_interstitials | 53 } // namespace security_interstitials |
OLD | NEW |