| 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 namespace base { |
| 13 class DictionaryValue; |
| 14 } |
| 15 |
| 16 namespace extensions { |
| 17 |
| 18 // Interface for rule registries. |
| 19 class RulesRegistry { |
| 20 public: |
| 21 virtual ~RulesRegistry() {} |
| 22 |
| 23 // Registers |rules|, owned by |extension_id| to this RulesRegistry. |
| 24 // If a concrete RuleRegistry does not support some of the rules, |
| 25 // it may ignore them. |
| 26 // |
| 27 // |rules| is a list of Rule instances following the definition of the |
| 28 // declarative extension APIs. It is guaranteed that each rule in |rules| has |
| 29 // a unique name within the scope of |extension_id| that has not been |
| 30 // registered before, unless it has been removed again. |
| 31 // The ownership of rules remains with the caller. |
| 32 // |
| 33 // Returns an empty string if the function is successful or an error |
| 34 // message otherwise. |
| 35 // |
| 36 // IMPORTANT: This function is atomic. Either all rules that are deemed |
| 37 // relevant are added or none. |
| 38 virtual std::string AddRules( |
| 39 const std::string& extension_id, |
| 40 const std::vector<base::DictionaryValue*>& rules) = 0; |
| 41 |
| 42 // Unregisters all rules listed in |rule_identifiers| and owned by |
| 43 // |extension_id| from this RulesRegistry. |
| 44 // Some or all IDs in |rule_identifiers| may not affect this RulesRegistry. |
| 45 // |
| 46 // Returns an empty string if the function is successful or an error |
| 47 // message otherwise. |
| 48 // |
| 49 // IMPORTANT: This function is atomic. Either all rules that are deemed |
| 50 // relevant are removed or none. |
| 51 virtual std::string RemoveRules( |
| 52 const std::string& extension_id, |
| 53 const std::vector<std::string>& rule_identifiers) = 0; |
| 54 |
| 55 // Same as RemoveAllRules but acts on all rules owned by |extension_id|. |
| 56 virtual std::string RemoveAllRules(const std::string& extension_id) = 0; |
| 57 |
| 58 // Returns all rules listed in |rule_identifiers| and owned by |extension_id| |
| 59 // registered in this RuleRegistry. |
| 60 // |
| 61 // The returned rules are stored in |out|. Ownership is passed to the caller. |
| 62 // |
| 63 // Returns an empty string if the function is successful or an error |
| 64 // message otherwise. |
| 65 virtual std::string GetRules(const std::string& extension_id, |
| 66 const std::vector<std::string>& rule_identifiers, |
| 67 std::vector<base::DictionaryValue*>* out) = 0; |
| 68 |
| 69 // Same as GetRules but returns all rules owned by |extension_id|. |
| 70 virtual std::string GetAllRules(const std::string& extension_id, |
| 71 std::vector<base::DictionaryValue*>* out) = 0; |
| 72 |
| 73 // Called to notify the RulesRegistry that an extension has been unloaded |
| 74 // and all rules of this extension need to be removed. |
| 75 virtual void OnExtensionUnloaded(const std::string& extension_id) = 0; |
| 76 }; |
| 77 |
| 78 } // namespace extensions |
| 79 |
| 80 #endif // CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_RULES_REGISTRY_H__ |
| OLD | NEW |