| 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 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 const AnyVector& conditions, | 292 const AnyVector& conditions, |
| 293 std::string* error) { | 293 std::string* error) { |
| 294 Conditions result; | 294 Conditions result; |
| 295 | 295 |
| 296 for (AnyVector::const_iterator i = conditions.begin(); | 296 for (AnyVector::const_iterator i = conditions.begin(); |
| 297 i != conditions.end(); ++i) { | 297 i != conditions.end(); ++i) { |
| 298 CHECK(i->get()); | 298 CHECK(i->get()); |
| 299 scoped_ptr<ConditionT> condition = | 299 scoped_ptr<ConditionT> condition = |
| 300 ConditionT::Create(url_matcher_condition_factory, **i, error); | 300 ConditionT::Create(url_matcher_condition_factory, **i, error); |
| 301 if (!error->empty()) | 301 if (!error->empty()) |
| 302 return scoped_ptr<DeclarativeConditionSet>(NULL); | 302 return scoped_ptr<DeclarativeConditionSet>(); |
| 303 result.push_back(make_linked_ptr(condition.release())); | 303 result.push_back(make_linked_ptr(condition.release())); |
| 304 } | 304 } |
| 305 | 305 |
| 306 URLMatcherIdToCondition match_id_to_condition; | 306 URLMatcherIdToCondition match_id_to_condition; |
| 307 std::vector<const ConditionT*> conditions_without_urls; | 307 std::vector<const ConditionT*> conditions_without_urls; |
| 308 URLMatcherConditionSet::Vector condition_sets; | 308 URLMatcherConditionSet::Vector condition_sets; |
| 309 | 309 |
| 310 for (typename Conditions::const_iterator i = result.begin(); | 310 for (typename Conditions::const_iterator i = result.begin(); |
| 311 i != result.end(); ++i) { | 311 i != result.end(); ++i) { |
| 312 condition_sets.clear(); | 312 condition_sets.clear(); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 352 *error = ""; | 352 *error = ""; |
| 353 *bad_message = false; | 353 *bad_message = false; |
| 354 Actions result; | 354 Actions result; |
| 355 | 355 |
| 356 for (AnyVector::const_iterator i = actions.begin(); | 356 for (AnyVector::const_iterator i = actions.begin(); |
| 357 i != actions.end(); ++i) { | 357 i != actions.end(); ++i) { |
| 358 CHECK(i->get()); | 358 CHECK(i->get()); |
| 359 scoped_refptr<const ActionT> action = | 359 scoped_refptr<const ActionT> action = |
| 360 ActionT::Create(**i, error, bad_message); | 360 ActionT::Create(**i, error, bad_message); |
| 361 if (!error->empty() || *bad_message) | 361 if (!error->empty() || *bad_message) |
| 362 return scoped_ptr<DeclarativeActionSet>(NULL); | 362 return scoped_ptr<DeclarativeActionSet>(); |
| 363 result.push_back(action); | 363 result.push_back(action); |
| 364 } | 364 } |
| 365 | 365 |
| 366 return scoped_ptr<DeclarativeActionSet>(new DeclarativeActionSet(result)); | 366 return scoped_ptr<DeclarativeActionSet>(new DeclarativeActionSet(result)); |
| 367 } | 367 } |
| 368 | 368 |
| 369 template<typename ActionT> | 369 template<typename ActionT> |
| 370 void DeclarativeActionSet<ActionT>::Apply( | 370 void DeclarativeActionSet<ActionT>::Apply( |
| 371 const std::string& extension_id, | 371 const std::string& extension_id, |
| 372 const base::Time& extension_install_time, | 372 const base::Time& extension_install_time, |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 475 } | 475 } |
| 476 | 476 |
| 477 template<typename ConditionT, typename ActionT> | 477 template<typename ConditionT, typename ActionT> |
| 478 int DeclarativeRule<ConditionT, ActionT>::GetMinimumPriority() const { | 478 int DeclarativeRule<ConditionT, ActionT>::GetMinimumPriority() const { |
| 479 return actions_->GetMinimumPriority(); | 479 return actions_->GetMinimumPriority(); |
| 480 } | 480 } |
| 481 | 481 |
| 482 } // namespace extensions | 482 } // namespace extensions |
| 483 | 483 |
| 484 #endif // CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_DECLARATIVE_RULE_H__ | 484 #endif // CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_DECLARATIVE_RULE_H__ |
| OLD | NEW |