OLD | NEW |
---|---|
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 // DeclarativeRule<>, DeclarativeConditionSet<>, and DeclarativeActionSet<> | 5 // DeclarativeRule<>, DeclarativeConditionSet<>, and DeclarativeActionSet<> |
6 // templates usable with multiple different declarativeFoo systems. These are | 6 // templates usable with multiple different declarativeFoo systems. These are |
7 // templated on the Condition and Action types that define the behavior of a | 7 // templated on the Condition and Action types that define the behavior of a |
8 // particular declarative event. | 8 // particular declarative event. |
9 | 9 |
10 #ifndef EXTENSIONS_BROWSER_API_DECLARATIVE_DECLARATIVE_RULE_H__ | 10 #ifndef EXTENSIONS_BROWSER_API_DECLARATIVE_DECLARATIVE_RULE_H__ |
11 #define EXTENSIONS_BROWSER_API_DECLARATIVE_DECLARATIVE_RULE_H__ | 11 #define EXTENSIONS_BROWSER_API_DECLARATIVE_DECLARATIVE_RULE_H__ |
12 | 12 |
13 #include <limits> | 13 #include <limits> |
14 #include <set> | 14 #include <set> |
15 #include <string> | 15 #include <string> |
16 #include <utility> | 16 #include <utility> |
17 #include <vector> | 17 #include <vector> |
18 | 18 |
19 #include "base/callback.h" | 19 #include "base/callback.h" |
20 #include "base/macros.h" | 20 #include "base/macros.h" |
21 #include "base/memory/linked_ptr.h" | 21 #include "base/memory/linked_ptr.h" |
22 #include "base/memory/ptr_util.h" | 22 #include "base/memory/ptr_util.h" |
23 #include "base/stl_util.h" | 23 #include "base/stl_util.h" |
24 #include "base/time/time.h" | 24 #include "base/time/time.h" |
25 #include "components/url_matcher/url_matcher.h" | 25 #include "components/url_matcher/url_matcher.h" |
26 #include "extensions/common/api/events.h" | 26 #include "extensions/common/api/events.h" |
27 #include "extensions/common/extension.h" | 27 #include "extensions/common/extension.h" |
Devlin
2016/11/11 23:10:06
#include extension_id
lazyboy
2016/11/12 00:13:16
Done.
| |
28 | 28 |
29 namespace base { | 29 namespace base { |
30 class Time; | 30 class Time; |
31 class Value; | 31 class Value; |
32 } | 32 } |
33 | 33 |
34 namespace content { | 34 namespace content { |
35 class BrowserContext; | 35 class BrowserContext; |
36 } | 36 } |
37 | 37 |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
192 // Representation of a rule of a declarative API: | 192 // Representation of a rule of a declarative API: |
193 // https://developer.chrome.com/beta/extensions/events.html#declarative. | 193 // https://developer.chrome.com/beta/extensions/events.html#declarative. |
194 // Generally a RulesRegistry will hold a collection of Rules for a given | 194 // Generally a RulesRegistry will hold a collection of Rules for a given |
195 // declarative API and contain the logic for matching and applying them. | 195 // declarative API and contain the logic for matching and applying them. |
196 // | 196 // |
197 // See DeclarativeConditionSet and DeclarativeActionSet for the requirements on | 197 // See DeclarativeConditionSet and DeclarativeActionSet for the requirements on |
198 // ConditionT and ActionT. | 198 // ConditionT and ActionT. |
199 template<typename ConditionT, typename ActionT> | 199 template<typename ConditionT, typename ActionT> |
200 class DeclarativeRule { | 200 class DeclarativeRule { |
201 public: | 201 public: |
202 typedef std::string ExtensionId; | |
203 typedef std::string RuleId; | 202 typedef std::string RuleId; |
204 typedef std::pair<ExtensionId, RuleId> GlobalRuleId; | 203 typedef std::pair<ExtensionId, RuleId> GlobalRuleId; |
205 typedef int Priority; | 204 typedef int Priority; |
206 typedef DeclarativeConditionSet<ConditionT> ConditionSet; | 205 typedef DeclarativeConditionSet<ConditionT> ConditionSet; |
207 typedef DeclarativeActionSet<ActionT> ActionSet; | 206 typedef DeclarativeActionSet<ActionT> ActionSet; |
208 typedef extensions::api::events::Rule JsonRule; | 207 typedef extensions::api::events::Rule JsonRule; |
209 typedef std::vector<std::string> Tags; | 208 typedef std::vector<std::string> Tags; |
210 | 209 |
211 // Checks whether the set of |conditions| and |actions| are consistent. | 210 // Checks whether the set of |conditions| and |actions| are consistent. |
212 // Returns true in case of consistency and MUST set |error| otherwise. | 211 // Returns true in case of consistency and MUST set |error| otherwise. |
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
498 } | 497 } |
499 | 498 |
500 template<typename ConditionT, typename ActionT> | 499 template<typename ConditionT, typename ActionT> |
501 int DeclarativeRule<ConditionT, ActionT>::GetMinimumPriority() const { | 500 int DeclarativeRule<ConditionT, ActionT>::GetMinimumPriority() const { |
502 return actions_->GetMinimumPriority(); | 501 return actions_->GetMinimumPriority(); |
503 } | 502 } |
504 | 503 |
505 } // namespace extensions | 504 } // namespace extensions |
506 | 505 |
507 #endif // EXTENSIONS_BROWSER_API_DECLARATIVE_DECLARATIVE_RULE_H__ | 506 #endif // EXTENSIONS_BROWSER_API_DECLARATIVE_DECLARATIVE_RULE_H__ |
OLD | NEW |