Chromium Code Reviews| 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/callback_forward.h" | |
| 13 #include "base/values.h" | |
| 14 | |
| 15 namespace extensions { | |
| 16 | |
| 17 // Interface for rule registries. | |
| 18 class RulesRegistry { | |
| 19 public: | |
| 20 typedef base::Callback<void(const std::string&)> SetErrorCallback; | |
| 21 | |
| 22 virtual ~RulesRegistry() {} | |
| 23 | |
| 24 // Registers |rules|, owned by |extension_id| to this RulesRegistry. | |
| 25 // If a concrete RuleRegistry does not support some of the rules, | |
| 26 // it may ignore them. | |
| 27 // | |
| 28 // |rules| is a list of Rule instances following the definition of the | |
| 29 // declarative extension APIs. It is guaranteed that each rule in |rules| has | |
| 30 // a unique name within the scope of |extension_id| that has not been | |
| 31 // registered before, unless it has been removed again. | |
| 32 // The ownership of rules remains with the caller. | |
| 33 // |set_error_callback| can be called to relay an error message. | |
| 34 // | |
| 35 // Returns true if the function is successful. | |
| 36 // | |
| 37 // IMPORTANT: This function is atomic. Either all rules that are deemed | |
| 38 // relevant are added or none. | |
| 39 virtual bool AddRules(const std::string& extension_id, | |
| 40 const std::vector<DictionaryValue*>& rules, | |
| 41 SetErrorCallback set_error_callback) = 0; | |
|
not at google - send to devlin
2012/02/02 11:59:16
I don't understand why errors communicated via a c
battre
2012/02/02 19:12:36
Done.
| |
| 42 | |
| 43 // Unregisters all rules listed in |rule_identifiers| and owned by | |
| 44 // |extension_id| from this RulesRegistry. If |rule_identifiers| is empty, all | |
| 45 // rules of this extension will be unregistered. | |
| 46 // Some or all IDs in |rule_identifiers| may not affect this RulesRegistry. | |
| 47 // |set_error_callback| can be called to relay an error message. | |
| 48 // | |
| 49 // Returns true if the function is successful. | |
| 50 // | |
| 51 // IMPORTANT: This function is atomic. Either all rules that are deemed | |
| 52 // relevant are removed or none. | |
| 53 virtual bool RemoveRules(const std::string& extension_id, | |
| 54 const std::vector<std::string>& rule_identifiers, | |
| 55 SetErrorCallback set_error_callback) = 0; | |
| 56 | |
| 57 // Returns all rules listed in |rule_identifiers| and owned by |extension_id| | |
| 58 // registered in this RuleRegistry. If |rule_identifiers| is empty, all rules | |
| 59 // of |extension_id| are returned. | |
| 60 // The returned rules are stored in |out|. Ownership is passed to the caller. | |
| 61 virtual void GetRules(const std::string& extension_id, | |
| 62 const std::vector<std::string>& rule_identifiers, | |
| 63 std::vector<DictionaryValue*>* out) = 0; | |
| 64 | |
| 65 // Called to notify the RulesRegistry that an extension has been unloaded | |
| 66 // and all rules of this extension need to be removed. | |
| 67 virtual void OnExtensionUnloaded(const std::string& extension_id) = 0; | |
| 68 }; | |
| 69 | |
| 70 } // namespace extensions | |
| 71 | |
| 72 #endif // CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_RULES_REGISTRY_H__ | |
| OLD | NEW |