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 "base/macros.h" | |
10 #include "base/memory/ref_counted.h" | |
9 #include "components/subresource_filter/core/common/activation_level.h" | 11 #include "components/subresource_filter/core/common/activation_level.h" |
10 #include "components/subresource_filter/core/common/activation_list.h" | 12 #include "components/subresource_filter/core/common/activation_list.h" |
11 #include "components/subresource_filter/core/common/activation_scope.h" | 13 #include "components/subresource_filter/core/common/activation_scope.h" |
12 | 14 |
13 namespace subresource_filter { | 15 namespace subresource_filter { |
14 | 16 |
15 // Encapsulates all parameters that define how the subresource filter feature | 17 // Encapsulates all parameters that define how the subresource filter feature |
16 // should operate. | 18 // should operate. |
17 struct Configuration { | 19 struct Configuration { |
18 Configuration(); | 20 Configuration(); |
(...skipping 27 matching lines...) Expand all Loading... | |
46 bool should_suppress_notifications = false; | 48 bool should_suppress_notifications = false; |
47 | 49 |
48 // The ruleset flavor to download through the component updater, or the empty | 50 // The ruleset flavor to download through the component updater, or the empty |
49 // string if the default ruleset should be used. | 51 // string if the default ruleset should be used. |
50 std::string ruleset_flavor; | 52 std::string ruleset_flavor; |
51 | 53 |
52 // Whether to whitelist a site when a page loaded from that site is reloaded. | 54 // Whether to whitelist a site when a page loaded from that site is reloaded. |
53 bool should_whitelist_site_on_reload = false; | 55 bool should_whitelist_site_on_reload = false; |
54 }; | 56 }; |
55 | 57 |
56 // Retrieves the subresource filtering configuration to use. Expensive to call. | 58 // TODO(engedy): Make this an actual list once all call sites are prepared to |
57 Configuration GetActiveConfiguration(); | 59 // handle multiple simultaneous configurations. |
60 class ConfigurationList : public base::RefCountedThreadSafe<ConfigurationList> { | |
61 public: | |
62 ConfigurationList(Configuration config); | |
Sorin Jianu
2017/04/24 21:58:59
explicit?
engedy
2017/04/25 08:34:24
Done.
| |
63 | |
64 const Configuration& the_one_and_only() const { return config_; } | |
65 | |
66 private: | |
67 friend class base::RefCountedThreadSafe<ConfigurationList>; | |
68 ~ConfigurationList(); | |
69 | |
70 const Configuration config_; | |
71 | |
72 DISALLOW_COPY_AND_ASSIGN(ConfigurationList); | |
73 }; | |
74 | |
75 // Retrieves all currently enabled subresource filtering configurations. The | |
76 // configurations are parsed on first access and then the result is cached. | |
77 // | |
78 // In tests, however, the config may change in-between navigations, so callers | |
79 // should not hold on to the result for long. | |
80 scoped_refptr<ConfigurationList> GetActiveConfigurations(); | |
81 | |
82 namespace testing { | |
83 | |
84 // Clears the cached active ConfigurationList so that it will be recomputed on | |
85 // next access. Used in tests when the variation parameters are altered. | |
86 void ClearCachedActiveConfigurations(); | |
87 | |
88 } // namespace testing | |
58 | 89 |
59 // Feature and variation parameter definitions ------------------------------- | 90 // Feature and variation parameter definitions ------------------------------- |
60 | 91 |
61 // The master toggle to enable/disable the Safe Browsing Subresource Filter. | 92 // The master toggle to enable/disable the Safe Browsing Subresource Filter. |
62 extern const base::Feature kSafeBrowsingSubresourceFilter; | 93 extern const base::Feature kSafeBrowsingSubresourceFilter; |
63 | 94 |
64 // Enables the new experimental UI for the Subresource Filter. | 95 // Enables the new experimental UI for the Subresource Filter. |
65 extern const base::Feature kSafeBrowsingSubresourceFilterExperimentalUI; | 96 extern const base::Feature kSafeBrowsingSubresourceFilterExperimentalUI; |
66 | 97 |
67 // Name/values of the variation parameter controlling maximum activation level. | 98 // Name/values of the variation parameter controlling maximum activation level. |
(...skipping 16 matching lines...) Expand all Loading... | |
84 | 115 |
85 extern const char kPerformanceMeasurementRateParameterName[]; | 116 extern const char kPerformanceMeasurementRateParameterName[]; |
86 | 117 |
87 extern const char kSuppressNotificationsParameterName[]; | 118 extern const char kSuppressNotificationsParameterName[]; |
88 | 119 |
89 extern const char kWhitelistSiteOnReloadParameterName[]; | 120 extern const char kWhitelistSiteOnReloadParameterName[]; |
90 | 121 |
91 } // namespace subresource_filter | 122 } // namespace subresource_filter |
92 | 123 |
93 #endif // COMPONENTS_SUBRESOURCE_FILTER_CORE_BROWSER_SUBRESOURCE_FILTER_FEATURE S_H_ | 124 #endif // COMPONENTS_SUBRESOURCE_FILTER_CORE_BROWSER_SUBRESOURCE_FILTER_FEATURE S_H_ |
OLD | NEW |