| Index: chrome/browser/extensions/api/declarative/declarative_rule.h
|
| diff --git a/chrome/browser/extensions/api/declarative/declarative_rule.h b/chrome/browser/extensions/api/declarative/declarative_rule.h
|
| index b06ae7004eca48dc190a61cafb20a18592d2b422..76e67387430e0d31133e9a6eca1f8a544078e506 100644
|
| --- a/chrome/browser/extensions/api/declarative/declarative_rule.h
|
| +++ b/chrome/browser/extensions/api/declarative/declarative_rule.h
|
| @@ -29,6 +29,8 @@ class Time;
|
| class Value;
|
| }
|
|
|
| +class Profile;
|
| +
|
| namespace extensions {
|
|
|
| // This class stores a set of conditions that may be part of a DeclarativeRule.
|
| @@ -146,7 +148,8 @@ class DeclarativeActionSet {
|
| // Factory method that instantiates a DeclarativeActionSet for |extension|
|
| // according to |actions| which represents the array of actions received from
|
| // the extension API.
|
| - static scoped_ptr<DeclarativeActionSet> Create(const Extension* extension,
|
| + static scoped_ptr<DeclarativeActionSet> Create(Profile* profile,
|
| + const Extension* extension,
|
| const AnyVector& actions,
|
| std::string* error,
|
| bool* bad_message);
|
| @@ -163,6 +166,12 @@ class DeclarativeActionSet {
|
| const base::Time& extension_install_time,
|
| typename ActionT::ApplyInfo* apply_info) const;
|
|
|
| + // Rules call this method when their conditions are checked and were already
|
| + // fulfilled previously.
|
| + void Reapply(const std::string& extension_id,
|
| + const base::Time& extension_install_time,
|
| + typename ActionT::ApplyInfo* apply_info) const;
|
| +
|
| // Returns the minimum priority of rules that may be evaluated after
|
| // this rule. Defaults to MIN_INT.
|
| int GetMinimumPriority() const;
|
| @@ -217,6 +226,7 @@ class DeclarativeRule {
|
| // the returned rule is internally consistent.
|
| static scoped_ptr<DeclarativeRule> Create(
|
| url_matcher::URLMatcherConditionFactory* url_matcher_condition_factory,
|
| + Profile* profile,
|
| const Extension* extension,
|
| base::Time extension_installation_time,
|
| linked_ptr<JsonRule> rule,
|
| @@ -352,6 +362,7 @@ DeclarativeActionSet<ActionT>::DeclarativeActionSet(const Actions& actions)
|
| template<typename ActionT>
|
| scoped_ptr<DeclarativeActionSet<ActionT> >
|
| DeclarativeActionSet<ActionT>::Create(
|
| + Profile* profile,
|
| const Extension* extension,
|
| const AnyVector& actions,
|
| std::string* error,
|
| @@ -364,7 +375,7 @@ DeclarativeActionSet<ActionT>::Create(
|
| i != actions.end(); ++i) {
|
| CHECK(i->get());
|
| scoped_refptr<const ActionT> action =
|
| - ActionT::Create(extension, **i, error, bad_message);
|
| + ActionT::Create(profile, extension, **i, error, bad_message);
|
| if (!error->empty() || *bad_message)
|
| return scoped_ptr<DeclarativeActionSet>();
|
| result.push_back(action);
|
| @@ -394,6 +405,16 @@ void DeclarativeActionSet<ActionT>::Revert(
|
| }
|
|
|
| template<typename ActionT>
|
| +void DeclarativeActionSet<ActionT>::Reapply(
|
| + const std::string& extension_id,
|
| + const base::Time& extension_install_time,
|
| + typename ActionT::ApplyInfo* apply_info) const {
|
| + for (typename Actions::const_iterator i = actions_.begin();
|
| + i != actions_.end(); ++i)
|
| + (*i)->Reapply(extension_id, extension_install_time, apply_info);
|
| +}
|
| +
|
| +template<typename ActionT>
|
| int DeclarativeActionSet<ActionT>::GetMinimumPriority() const {
|
| int minimum_priority = std::numeric_limits<int>::min();
|
| for (typename Actions::const_iterator i = actions_.begin();
|
| @@ -430,6 +451,7 @@ template<typename ConditionT, typename ActionT>
|
| scoped_ptr<DeclarativeRule<ConditionT, ActionT> >
|
| DeclarativeRule<ConditionT, ActionT>::Create(
|
| url_matcher::URLMatcherConditionFactory* url_matcher_condition_factory,
|
| + Profile* profile,
|
| const Extension* extension,
|
| base::Time extension_installation_time,
|
| linked_ptr<JsonRule> rule,
|
| @@ -445,7 +467,7 @@ DeclarativeRule<ConditionT, ActionT>::Create(
|
|
|
| bool bad_message = false;
|
| scoped_ptr<ActionSet> actions =
|
| - ActionSet::Create(extension, rule->actions, error, &bad_message);
|
| + ActionSet::Create(profile, extension, rule->actions, error, &bad_message);
|
| if (bad_message) {
|
| // TODO(battre) Export concept of bad_message to caller, the extension
|
| // should be killed in case it is true.
|
|
|