| 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 CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_DECLARATIVE_RULE_H__ | 10 #ifndef EXTENSIONS_BROWSER_API_DECLARATIVE_DECLARATIVE_RULE_H__ |
| 11 #define CHROME_BROWSER_EXTENSIONS_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 <vector> | 16 #include <vector> |
| 17 | 17 |
| 18 #include "base/callback.h" | 18 #include "base/callback.h" |
| 19 #include "base/memory/linked_ptr.h" | 19 #include "base/memory/linked_ptr.h" |
| 20 #include "base/memory/scoped_vector.h" | 20 #include "base/memory/scoped_vector.h" |
| 21 #include "base/stl_util.h" | 21 #include "base/stl_util.h" |
| 22 #include "base/time/time.h" | 22 #include "base/time/time.h" |
| 23 #include "chrome/common/extensions/api/events.h" | |
| 24 #include "components/url_matcher/url_matcher.h" | 23 #include "components/url_matcher/url_matcher.h" |
| 24 #include "extensions/common/api/events.h" |
| 25 #include "extensions/common/extension.h" | 25 #include "extensions/common/extension.h" |
| 26 | 26 |
| 27 namespace base { | 27 namespace base { |
| 28 class Time; | 28 class Time; |
| 29 class Value; | 29 class Value; |
| 30 } | 30 } |
| 31 | 31 |
| 32 namespace content { | 32 namespace content { |
| 33 class BrowserContext; | 33 class BrowserContext; |
| 34 } | 34 } |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 // ConditionT and ActionT. | 196 // ConditionT and ActionT. |
| 197 template<typename ConditionT, typename ActionT> | 197 template<typename ConditionT, typename ActionT> |
| 198 class DeclarativeRule { | 198 class DeclarativeRule { |
| 199 public: | 199 public: |
| 200 typedef std::string ExtensionId; | 200 typedef std::string ExtensionId; |
| 201 typedef std::string RuleId; | 201 typedef std::string RuleId; |
| 202 typedef std::pair<ExtensionId, RuleId> GlobalRuleId; | 202 typedef std::pair<ExtensionId, RuleId> GlobalRuleId; |
| 203 typedef int Priority; | 203 typedef int Priority; |
| 204 typedef DeclarativeConditionSet<ConditionT> ConditionSet; | 204 typedef DeclarativeConditionSet<ConditionT> ConditionSet; |
| 205 typedef DeclarativeActionSet<ActionT> ActionSet; | 205 typedef DeclarativeActionSet<ActionT> ActionSet; |
| 206 typedef extensions::api::events::Rule JsonRule; | 206 typedef extensions::core_api::events::Rule JsonRule; |
| 207 typedef std::vector<std::string> Tags; | 207 typedef std::vector<std::string> Tags; |
| 208 | 208 |
| 209 // Checks whether the set of |conditions| and |actions| are consistent. | 209 // Checks whether the set of |conditions| and |actions| are consistent. |
| 210 // Returns true in case of consistency and MUST set |error| otherwise. | 210 // Returns true in case of consistency and MUST set |error| otherwise. |
| 211 typedef base::Callback<bool(const ConditionSet* conditions, | 211 typedef base::Callback<bool(const ConditionSet* conditions, |
| 212 const ActionSet* actions, | 212 const ActionSet* actions, |
| 213 std::string* error)> ConsistencyChecker; | 213 std::string* error)> ConsistencyChecker; |
| 214 | 214 |
| 215 DeclarativeRule(const GlobalRuleId& id, | 215 DeclarativeRule(const GlobalRuleId& id, |
| 216 const Tags& tags, | 216 const Tags& tags, |
| (...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 507 apply_info); | 507 apply_info); |
| 508 } | 508 } |
| 509 | 509 |
| 510 template<typename ConditionT, typename ActionT> | 510 template<typename ConditionT, typename ActionT> |
| 511 int DeclarativeRule<ConditionT, ActionT>::GetMinimumPriority() const { | 511 int DeclarativeRule<ConditionT, ActionT>::GetMinimumPriority() const { |
| 512 return actions_->GetMinimumPriority(); | 512 return actions_->GetMinimumPriority(); |
| 513 } | 513 } |
| 514 | 514 |
| 515 } // namespace extensions | 515 } // namespace extensions |
| 516 | 516 |
| 517 #endif // CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_DECLARATIVE_RULE_H__ | 517 #endif // EXTENSIONS_BROWSER_API_DECLARATIVE_DECLARATIVE_RULE_H__ |
| OLD | NEW |