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 // Guards creation of the SubresourceFilterSafeBrowsingActivationThrottle | 67 // Guards creation of the SubresourceFilterSafeBrowsingActivationThrottle |
22 extern const base::Feature kSubresourceFilterSafeBrowsingActivationThrottle; | 68 extern const base::Feature kSubresourceFilterSafeBrowsingActivationThrottle; |
23 | 69 |
24 // Name/values of the variation parameter controlling maximum activation level. | 70 // Name/values of the variation parameter controlling maximum activation level. |
(...skipping 13 matching lines...) Expand all Loading... |
38 extern const char kActivationListSubresourceFilter[]; | 84 extern const char kActivationListSubresourceFilter[]; |
39 | 85 |
40 extern const char kRulesetFlavorParameterName[]; | 86 extern const char kRulesetFlavorParameterName[]; |
41 | 87 |
42 extern const char kPerformanceMeasurementRateParameterName[]; | 88 extern const char kPerformanceMeasurementRateParameterName[]; |
43 | 89 |
44 extern const char kSuppressNotificationsParameterName[]; | 90 extern const char kSuppressNotificationsParameterName[]; |
45 | 91 |
46 extern const char kWhitelistSiteOnReloadParameterName[]; | 92 extern const char kWhitelistSiteOnReloadParameterName[]; |
47 | 93 |
48 // Returns the maximum degree to which subresource filtering should be activated | |
49 // on any RenderFrame. This will be ActivationLevel::DISABLED unless the feature | |
50 // is enabled and variation parameters prescribe a higher activation level. | |
51 ActivationLevel GetMaximumActivationLevel(); | |
52 | |
53 // Returns the current activation scope, that is, the subset of page loads where | |
54 // subresource filtering should be activated. The function returns | |
55 // ActivationScope::NO_SITES unless the feature is enabled and variation | |
56 // parameters prescribe a wider activation scope. | |
57 ActivationScope GetCurrentActivationScope(); | |
58 | |
59 // Returns current activation list, based on the values from variation params in | |
60 // the feature |kSafeBrowsingSubresourceFilter|. When the corresponding | |
61 // variation param is empty, returns most conservative ActivationList::NONE. | |
62 ActivationList GetCurrentActivationList(); | |
63 | |
64 // Returns a number in the range [0, 1], indicating the fraction of page loads | |
65 // that should have extended performance measurements enabled. The rate will be | |
66 // 0 unless a greater frequency is specified by variation parameters. | |
67 double GetPerformanceMeasurementRate(); | |
68 | |
69 // Returns whether notifications indicating that a subresource was disallowed | |
70 // should be suppressed in the UI. | |
71 bool ShouldSuppressNotifications(); | |
72 | |
73 // Returns the ruleset flavor, or the empty string if the default ruleset should | |
74 // be used. | |
75 std::string GetRulesetFlavor(); | |
76 | |
77 // Returns whether the site of reloaded pages should be whitelisted. | |
78 bool ShouldWhitelistSiteOnReload(); | |
79 | |
80 } // namespace subresource_filter | 94 } // namespace subresource_filter |
81 | 95 |
82 #endif // COMPONENTS_SUBRESOURCE_FILTER_CORE_BROWSER_SUBRESOURCE_FILTER_FEATURE
S_H_ | 96 #endif // COMPONENTS_SUBRESOURCE_FILTER_CORE_BROWSER_SUBRESOURCE_FILTER_FEATURE
S_H_ |
OLD | NEW |