| 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 CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_DECLARATIVE_RULE_H__ |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 static scoped_ptr<DeclarativeActionSet> Create(const Extension* extension, | 149 static scoped_ptr<DeclarativeActionSet> Create(const Extension* extension, |
| 150 const AnyVector& actions, | 150 const AnyVector& actions, |
| 151 std::string* error, | 151 std::string* error, |
| 152 bool* bad_message); | 152 bool* bad_message); |
| 153 | 153 |
| 154 // Rules call this method when their conditions are fulfilled. | 154 // Rules call this method when their conditions are fulfilled. |
| 155 void Apply(const std::string& extension_id, | 155 void Apply(const std::string& extension_id, |
| 156 const base::Time& extension_install_time, | 156 const base::Time& extension_install_time, |
| 157 typename ActionT::ApplyInfo* apply_info) const; | 157 typename ActionT::ApplyInfo* apply_info) const; |
| 158 | 158 |
| 159 // Rules call this method when their conditions are fulfilled, but Apply has |
| 160 // already been called. |
| 161 void Reapply(const std::string& extension_id, |
| 162 const base::Time& extension_install_time, |
| 163 typename ActionT::ApplyInfo* apply_info) const; |
| 164 |
| 159 // Rules call this method when they have stateful conditions, and those | 165 // Rules call this method when they have stateful conditions, and those |
| 160 // conditions stop being fulfilled. Rules with event-based conditions (e.g. a | 166 // conditions stop being fulfilled. Rules with event-based conditions (e.g. a |
| 161 // network request happened) will never Revert() an action. | 167 // network request happened) will never Revert() an action. |
| 162 void Revert(const std::string& extension_id, | 168 void Revert(const std::string& extension_id, |
| 163 const base::Time& extension_install_time, | 169 const base::Time& extension_install_time, |
| 164 typename ActionT::ApplyInfo* apply_info) const; | 170 typename ActionT::ApplyInfo* apply_info) const; |
| 165 | 171 |
| 166 // Returns the minimum priority of rules that may be evaluated after | 172 // Returns the minimum priority of rules that may be evaluated after |
| 167 // this rule. Defaults to MIN_INT. | 173 // this rule. Defaults to MIN_INT. |
| 168 int GetMinimumPriority() const; | 174 int GetMinimumPriority() const; |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 377 void DeclarativeActionSet<ActionT>::Apply( | 383 void DeclarativeActionSet<ActionT>::Apply( |
| 378 const std::string& extension_id, | 384 const std::string& extension_id, |
| 379 const base::Time& extension_install_time, | 385 const base::Time& extension_install_time, |
| 380 typename ActionT::ApplyInfo* apply_info) const { | 386 typename ActionT::ApplyInfo* apply_info) const { |
| 381 for (typename Actions::const_iterator i = actions_.begin(); | 387 for (typename Actions::const_iterator i = actions_.begin(); |
| 382 i != actions_.end(); ++i) | 388 i != actions_.end(); ++i) |
| 383 (*i)->Apply(extension_id, extension_install_time, apply_info); | 389 (*i)->Apply(extension_id, extension_install_time, apply_info); |
| 384 } | 390 } |
| 385 | 391 |
| 386 template<typename ActionT> | 392 template<typename ActionT> |
| 393 void DeclarativeActionSet<ActionT>::Reapply( |
| 394 const std::string& extension_id, |
| 395 const base::Time& extension_install_time, |
| 396 typename ActionT::ApplyInfo* apply_info) const { |
| 397 for (typename Actions::const_iterator i = actions_.begin(); |
| 398 i != actions_.end(); ++i) |
| 399 (*i)->Reapply(extension_id, extension_install_time, apply_info); |
| 400 } |
| 401 |
| 402 template<typename ActionT> |
| 387 void DeclarativeActionSet<ActionT>::Revert( | 403 void DeclarativeActionSet<ActionT>::Revert( |
| 388 const std::string& extension_id, | 404 const std::string& extension_id, |
| 389 const base::Time& extension_install_time, | 405 const base::Time& extension_install_time, |
| 390 typename ActionT::ApplyInfo* apply_info) const { | 406 typename ActionT::ApplyInfo* apply_info) const { |
| 391 for (typename Actions::const_iterator i = actions_.begin(); | 407 for (typename Actions::const_iterator i = actions_.begin(); |
| 392 i != actions_.end(); ++i) | 408 i != actions_.end(); ++i) |
| 393 (*i)->Revert(extension_id, extension_install_time, apply_info); | 409 (*i)->Revert(extension_id, extension_install_time, apply_info); |
| 394 } | 410 } |
| 395 | 411 |
| 396 template<typename ActionT> | 412 template<typename ActionT> |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 482 } | 498 } |
| 483 | 499 |
| 484 template<typename ConditionT, typename ActionT> | 500 template<typename ConditionT, typename ActionT> |
| 485 int DeclarativeRule<ConditionT, ActionT>::GetMinimumPriority() const { | 501 int DeclarativeRule<ConditionT, ActionT>::GetMinimumPriority() const { |
| 486 return actions_->GetMinimumPriority(); | 502 return actions_->GetMinimumPriority(); |
| 487 } | 503 } |
| 488 | 504 |
| 489 } // namespace extensions | 505 } // namespace extensions |
| 490 | 506 |
| 491 #endif // CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_DECLARATIVE_RULE_H__ | 507 #endif // CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_DECLARATIVE_RULE_H__ |
| OLD | NEW |