OLD | NEW |
| (Empty) |
1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 // | |
5 // Safe Browsing preferences and some basic utility functions for using them. | |
6 | |
7 #ifndef COMPONENTS_SAFE_BROWSING_DB_SAFE_BROWSING_PREFS_H_ | |
8 #define COMPONENTS_SAFE_BROWSING_DB_SAFE_BROWSING_PREFS_H_ | |
9 | |
10 #include "base/feature_list.h" | |
11 | |
12 class PrefService; | |
13 | |
14 namespace prefs { | |
15 // Boolean that tell us whether Safe Browsing extended reporting is enabled. | |
16 extern const char kSafeBrowsingExtendedReportingEnabled[]; | |
17 | |
18 // Boolean indicating whether Safe Browsing Scout reporting is enabled, which | |
19 // collects data for malware detection. | |
20 extern const char kSafeBrowsingScoutReportingEnabled[]; | |
21 | |
22 // Boolean indicating whether the Scout reporting workflow is enabled. This | |
23 // affects which of SafeBrowsingExtendedReporting or SafeBrowsingScoutReporting | |
24 // is used. | |
25 extern const char kSafeBrowsingScoutGroupSelected[]; | |
26 | |
27 // Boolean indicating whether the user has ever seen a security interstitial | |
28 // containing the legacy Extended Reporting opt-in. | |
29 extern const char kSafeBrowsingSawInterstitialExtendedReporting[]; | |
30 | |
31 // Boolean indicating whether the user has ever seen a security interstitial | |
32 // containing the new Scout opt-in. | |
33 extern const char kSafeBrowsingSawInterstitialScoutReporting[]; | |
34 } | |
35 | |
36 namespace safe_browsing { | |
37 | |
38 // Command-line switch for changing the scout_group_selected preference. Should | |
39 // be set to either 'true' or 'false'. Primarily for testing purposes. | |
40 // TODO: this is temporary (crbug.com/662944) | |
41 extern const char kSwitchForceScoutGroup[]; | |
42 | |
43 // When this feature is enabled, the Scout opt-in text will be displayed as of | |
44 // the next security incident. Until then, the legacy SBER text will appear. | |
45 // TODO: this is temporary (crbug.com/662944) | |
46 extern const base::Feature kCanShowScoutOptIn; | |
47 | |
48 // When this feature is enabled, the Scout opt-in text will immediately be | |
49 // displayed everywhere. | |
50 // TODO: this is temporary (crbug.com/662944) | |
51 extern const base::Feature kOnlyShowScoutOptIn; | |
52 | |
53 // Enumerates the level of Safe Browsing Extended Reporting that is currently | |
54 // available. | |
55 enum ExtendedReportingLevel { | |
56 // Extended reporting is off. | |
57 SBER_LEVEL_OFF = 0, | |
58 // The Legacy level of extended reporting is available, reporting happens in | |
59 // response to security incidents. | |
60 SBER_LEVEL_LEGACY = 1, | |
61 // The Scout level of extended reporting is available, some data can be | |
62 // collected to actively detect dangerous apps and sites. | |
63 SBER_LEVEL_SCOUT = 2, | |
64 }; | |
65 | |
66 // Enumerates all the places where the Safe Browsing Extended Reporting | |
67 // preference can be changed. | |
68 // These values are written to logs. New enum values can be added, but | |
69 // existing enums must never be renumbered or deleted and reused. | |
70 enum ExtendedReportingOptInLocation { | |
71 // The chrome://settings UI (also shared with chrome://md-settings). | |
72 SBER_OPTIN_SITE_CHROME_SETTINGS = 0, | |
73 // The Android settings UI. | |
74 SBER_OPTIN_SITE_ANDROID_SETTINGS = 1, | |
75 // The Download Feedback popup. | |
76 SBER_OPTIN_SITE_DOWNLOAD_FEEDBACK_POPUP = 2, | |
77 // Any security interstitial (malware, SSL, etc). | |
78 SBER_OPTIN_SITE_SECURITY_INTERSTITIAL = 3, | |
79 // New sites must be added before SBER_OPTIN_SITE_MAX. | |
80 SBER_OPTIN_SITE_MAX | |
81 }; | |
82 | |
83 // Determines which opt-in text should be used based on the currently active | |
84 // preference. Will return either |extended_reporting_pref| if the legacy | |
85 // Extended Reporting pref is active, or |scout_pref| if the Scout pref is | |
86 // active. Used for Android. | |
87 std::string ChooseOptInTextPreference( | |
88 const PrefService& prefs, | |
89 const std::string& extended_reporting_pref, | |
90 const std::string& scout_pref); | |
91 | |
92 // Determines which opt-in text should be used based on the currently active | |
93 // preference. Will return either |extended_reporting_resource| if the legacy | |
94 // Extended Reporting pref is active, or |scout_resource| if the Scout pref is | |
95 // active. | |
96 int ChooseOptInTextResource(const PrefService& prefs, | |
97 int extended_reporting_resource, | |
98 int scout_resource); | |
99 | |
100 // Returns whether the currently active Safe Browsing Extended Reporting | |
101 // preference exists (eg: has been set before). | |
102 bool ExtendedReportingPrefExists(const PrefService& prefs); | |
103 | |
104 // Returns the level of reporting available for the current user. | |
105 ExtendedReportingLevel GetExtendedReportingLevel(const PrefService& prefs); | |
106 | |
107 // Returns the name of the Safe Browsing Extended Reporting pref that is | |
108 // currently in effect. The specific pref in-use may change through experiments. | |
109 const char* GetExtendedReportingPrefName(const PrefService& prefs); | |
110 | |
111 // Initializes Safe Browsing preferences based on data such as experiment state, | |
112 // command line flags, etc. | |
113 // TODO: this is temporary (crbug.com/662944) | |
114 void InitializeSafeBrowsingPrefs(PrefService* prefs); | |
115 | |
116 // Returns whether Safe Browsing Extended Reporting is currently enabled. | |
117 // This should be used to decide if any of the reporting preferences are set, | |
118 // regardless of which specific one is set. | |
119 bool IsExtendedReportingEnabled(const PrefService& prefs); | |
120 | |
121 // Returns whether the currently-active Extended Reporting pref is Scout. | |
122 bool IsScout(const PrefService& prefs); | |
123 | |
124 // Updates UMA metrics about Safe Browsing Extended Reporting states. | |
125 void RecordExtendedReportingMetrics(const PrefService& prefs); | |
126 | |
127 // Sets the currently active Safe Browsing Extended Reporting preference to the | |
128 // specified value. The |location| indicates the UI where the change was | |
129 // made. | |
130 void SetExtendedReportingPrefAndMetric(PrefService* prefs, | |
131 bool value, | |
132 ExtendedReportingOptInLocation location); | |
133 // This variant is used to simplify test code by omitting the location. | |
134 void SetExtendedReportingPref(PrefService* prefs, bool value); | |
135 | |
136 // Called when a security interstitial is closed by the user. | |
137 // |on_show_pref_existed| indicates whether the pref existed when the | |
138 // interstitial was shown. |on_show_pref_value| contains the pref value when the | |
139 // interstitial was shown. | |
140 void UpdateMetricsAfterSecurityInterstitial(const PrefService& prefs, | |
141 bool on_show_pref_existed, | |
142 bool on_show_pref_value); | |
143 | |
144 // Called to indicate that a security interstitial is about to be shown to the | |
145 // user. This may trigger the user to begin seeing the Scout opt-in text | |
146 // depending on their experiment state. | |
147 void UpdatePrefsBeforeSecurityInterstitial(PrefService* prefs); | |
148 | |
149 } // namespace safe_browsing | |
150 | |
151 #endif // COMPONENTS_SAFE_BROWSING_DB_SAFE_BROWSING_PREFS_H_ | |
OLD | NEW |