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 #ifndef COMPONENTS_SUBRESOURCE_FILTER_CORE_BROWSER_SUBRESOURCE_FILTER_FEATURES_H
_ | 5 #ifndef COMPONENTS_SUBRESOURCE_FILTER_CORE_BROWSER_SUBRESOURCE_FILTER_FEATURES_H
_ |
6 #define COMPONENTS_SUBRESOURCE_FILTER_CORE_BROWSER_SUBRESOURCE_FILTER_FEATURES_H
_ | 6 #define COMPONENTS_SUBRESOURCE_FILTER_CORE_BROWSER_SUBRESOURCE_FILTER_FEATURES_H
_ |
7 | 7 |
8 #include "base/feature_list.h" | 8 #include "base/feature_list.h" |
9 #include "components/subresource_filter/core/common/activation_level.h" | 9 #include "components/subresource_filter/core/common/activation_level.h" |
10 #include "components/subresource_filter/core/common/activation_list.h" | 10 #include "components/subresource_filter/core/common/activation_list.h" |
11 #include "components/subresource_filter/core/common/activation_scope.h" | 11 #include "components/subresource_filter/core/common/activation_scope.h" |
12 | 12 |
13 namespace subresource_filter { | 13 namespace subresource_filter { |
14 | 14 |
| 15 // Encapsulates all parameters that define how the subresource filter feature |
| 16 // should operate. |
| 17 struct Configuration { |
| 18 Configuration(); |
| 19 ~Configuration(); |
| 20 Configuration(Configuration&&); |
| 21 Configuration& operator=(Configuration&&); |
| 22 |
| 23 // The maximum degree to which subresource filtering should be activated on |
| 24 // any RenderFrame. This will be ActivationLevel::DISABLED unless the feature |
| 25 // is enabled and variation parameters prescribe a higher activation level. |
| 26 ActivationLevel activation_level = ActivationLevel::DISABLED; |
| 27 |
| 28 // The activation scope. That is, the subset of page loads where subresource |
| 29 // filtering should be activated. This will be ActivationScope::NO_SITES |
| 30 // unless the feature is =enabled and variation parameters prescribe a wider |
| 31 // activation scope. |
| 32 ActivationScope activation_scope = ActivationScope::NO_SITES; |
| 33 |
| 34 // The activation list to use when the |activation_scope| is ACTIVATION_LIST. |
| 35 // This will be ActivationList::NONE unless variation parameters prescribe a |
| 36 // recognized list. |
| 37 ActivationList activation_list = ActivationList::NONE; |
| 38 |
| 39 // A number in the range [0, 1], indicating the fraction of page loads that |
| 40 // should have extended performance measurements enabled. The rate will |
| 41 // be 0 unless a greater frequency is specified by variation parameters. |
| 42 double performance_measurement_rate = 0.0; |
| 43 |
| 44 // Whether notifications indicating that a subresource was disallowed should |
| 45 // be suppressed in the UI. |
| 46 bool should_suppress_notifications = false; |
| 47 |
| 48 // The ruleset flavor to download through the component updater, or the empty |
| 49 // string if the default ruleset should be used. |
| 50 std::string ruleset_flavor; |
| 51 |
| 52 // Whether to whitelist a site when a page loaded from that site is reloaded. |
| 53 bool should_whitelist_site_on_reload = false; |
| 54 }; |
| 55 |
| 56 // Retrieves the subresource filtering configuration to use. Expensive to call. |
| 57 Configuration GetActiveConfiguration(); |
| 58 |
| 59 // Feature and variation parameter definitions ------------------------------- |
| 60 |
15 // The master toggle to enable/disable the Safe Browsing Subresource Filter. | 61 // The master toggle to enable/disable the Safe Browsing Subresource Filter. |
16 extern const base::Feature kSafeBrowsingSubresourceFilter; | 62 extern const base::Feature kSafeBrowsingSubresourceFilter; |
17 | 63 |
18 // Enables the new experimental UI for the Subresource Filter. | 64 // Enables the new experimental UI for the Subresource Filter. |
19 extern const base::Feature kSafeBrowsingSubresourceFilterExperimentalUI; | 65 extern const base::Feature kSafeBrowsingSubresourceFilterExperimentalUI; |
20 | 66 |
21 // Name/values of the variation parameter controlling maximum activation level. | 67 // Name/values of the variation parameter controlling maximum activation level. |
22 extern const char kActivationLevelParameterName[]; | 68 extern const char kActivationLevelParameterName[]; |
23 extern const char kActivationLevelDryRun[]; | 69 extern const char kActivationLevelDryRun[]; |
24 extern const char kActivationLevelEnabled[]; | 70 extern const char kActivationLevelEnabled[]; |
(...skipping 10 matching lines...) Expand all Loading... |
35 extern const char kActivationListSubresourceFilter[]; | 81 extern const char kActivationListSubresourceFilter[]; |
36 | 82 |
37 extern const char kRulesetFlavorParameterName[]; | 83 extern const char kRulesetFlavorParameterName[]; |
38 | 84 |
39 extern const char kPerformanceMeasurementRateParameterName[]; | 85 extern const char kPerformanceMeasurementRateParameterName[]; |
40 | 86 |
41 extern const char kSuppressNotificationsParameterName[]; | 87 extern const char kSuppressNotificationsParameterName[]; |
42 | 88 |
43 extern const char kWhitelistSiteOnReloadParameterName[]; | 89 extern const char kWhitelistSiteOnReloadParameterName[]; |
44 | 90 |
45 // Returns the maximum degree to which subresource filtering should be activated | |
46 // on any RenderFrame. This will be ActivationLevel::DISABLED unless the feature | |
47 // is enabled and variation parameters prescribe a higher activation level. | |
48 ActivationLevel GetMaximumActivationLevel(); | |
49 | |
50 // Returns the current activation scope, that is, the subset of page loads where | |
51 // subresource filtering should be activated. The function returns | |
52 // ActivationScope::NO_SITES unless the feature is enabled and variation | |
53 // parameters prescribe a wider activation scope. | |
54 ActivationScope GetCurrentActivationScope(); | |
55 | |
56 // Returns current activation list, based on the values from variation params in | |
57 // the feature |kSafeBrowsingSubresourceFilter|. When the corresponding | |
58 // variation param is empty, returns most conservative ActivationList::NONE. | |
59 ActivationList GetCurrentActivationList(); | |
60 | |
61 // Returns a number in the range [0, 1], indicating the fraction of page loads | |
62 // that should have extended performance measurements enabled. The rate will be | |
63 // 0 unless a greater frequency is specified by variation parameters. | |
64 double GetPerformanceMeasurementRate(); | |
65 | |
66 // Returns whether notifications indicating that a subresource was disallowed | |
67 // should be suppressed in the UI. | |
68 bool ShouldSuppressNotifications(); | |
69 | |
70 // Returns the ruleset flavor, or the empty string if the default ruleset should | |
71 // be used. | |
72 std::string GetRulesetFlavor(); | |
73 | |
74 // Returns whether the site of reloaded pages should be whitelisted. | |
75 bool ShouldWhitelistSiteOnReload(); | |
76 | |
77 } // namespace subresource_filter | 91 } // namespace subresource_filter |
78 | 92 |
79 #endif // COMPONENTS_SUBRESOURCE_FILTER_CORE_BROWSER_SUBRESOURCE_FILTER_FEATURE
S_H_ | 93 #endif // COMPONENTS_SUBRESOURCE_FILTER_CORE_BROWSER_SUBRESOURCE_FILTER_FEATURE
S_H_ |
OLD | NEW |