| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_RULES_REGISTRY_H__ |
| 6 #define CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_RULES_REGISTRY_H__ |
| 7 #pragma once |
| 8 |
| 9 #include <string> |
| 10 #include <vector> |
| 11 |
| 12 #include "base/values.h" |
| 13 |
| 14 namespace extensions { |
| 15 |
| 16 // Interface for rule registries. |
| 17 class RulesRegistry { |
| 18 public: |
| 19 virtual ~RulesRegistry() {} |
| 20 |
| 21 // Registers |rules|, owned by |extension_id| to this RulesRegistry. |
| 22 // If a concrete RuleRegistry does not support some of the rules, |
| 23 // it may ignore them. |
| 24 // |
| 25 // |rules| is a list of Rule instances following the definition of the |
| 26 // declarative extension APIs. It is guaranteed that each rule in |rules| has |
| 27 // a unique name within the scope of |extension_id| that has not been |
| 28 // registered before, unless it has been removed again. |
| 29 // The ownership of rules remains with the caller. |
| 30 // |
| 31 // Returns true if the function is successful. Otherwise, an error message |
| 32 // can be written into |error|. |
| 33 // |
| 34 // IMPORTANT: This function is atomic. Either all rules that are deemed |
| 35 // relevant are added or none. |
| 36 virtual bool AddRules(const std::string& extension_id, |
| 37 const std::vector<DictionaryValue*>& rules, |
| 38 std::string* error) = 0; |
| 39 |
| 40 // Unregisters all rules listed in |rule_identifiers| and owned by |
| 41 // |extension_id| from this RulesRegistry. If |rule_identifiers| is empty, all |
| 42 // rules of this extension will be unregistered. |
| 43 // Some or all IDs in |rule_identifiers| may not affect this RulesRegistry. |
| 44 // |
| 45 // Returns true if the function is successful. Otherwise, an error message |
| 46 // can be written into |error|. |
| 47 // |
| 48 // IMPORTANT: This function is atomic. Either all rules that are deemed |
| 49 // relevant are removed or none. |
| 50 virtual bool RemoveRules(const std::string& extension_id, |
| 51 const std::vector<std::string>& rule_identifiers, |
| 52 std::string* error) = 0; |
| 53 |
| 54 // Returns all rules listed in |rule_identifiers| and owned by |extension_id| |
| 55 // registered in this RuleRegistry. If |rule_identifiers| is empty, all rules |
| 56 // of |extension_id| are returned. |
| 57 // The returned rules are stored in |out|. Ownership is passed to the caller. |
| 58 virtual void GetRules(const std::string& extension_id, |
| 59 const std::vector<std::string>& rule_identifiers, |
| 60 std::vector<DictionaryValue*>* out) = 0; |
| 61 |
| 62 // Called to notify the RulesRegistry that an extension has been unloaded |
| 63 // and all rules of this extension need to be removed. |
| 64 virtual void OnExtensionUnloaded(const std::string& extension_id) = 0; |
| 65 }; |
| 66 |
| 67 } // namespace extensions |
| 68 |
| 69 #endif // CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_RULES_REGISTRY_H__ |
| OLD | NEW |