Chromium Code Reviews| Index: chrome/browser/extensions/api/declarative/rules_registry.h |
| diff --git a/chrome/browser/extensions/api/declarative/rules_registry.h b/chrome/browser/extensions/api/declarative/rules_registry.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..0bd99370e8539824c6861ad5dd87be381c072087 |
| --- /dev/null |
| +++ b/chrome/browser/extensions/api/declarative/rules_registry.h |
| @@ -0,0 +1,69 @@ |
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_RULES_REGISTRY_H__ |
| +#define CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_RULES_REGISTRY_H__ |
| +#pragma once |
| + |
| +#include <string> |
| +#include <vector> |
| + |
| +#include "base/values.h" |
| + |
| +namespace extensions { |
| + |
| +// Interface for rule registries. |
| +class RulesRegistry { |
| + public: |
| + virtual ~RulesRegistry() {} |
| + |
| + // Registers |rules|, owned by |extension_id| to this RulesRegistry. |
| + // If a concrete RuleRegistry does not support some of the rules, |
| + // it may ignore them. |
| + // |
| + // |rules| is a list of Rule instances following the definition of the |
| + // declarative extension APIs. It is guaranteed that each rule in |rules| has |
| + // a unique name within the scope of |extension_id| that has not been |
| + // registered before, unless it has been removed again. |
| + // The ownership of rules remains with the caller. |
| + // |
| + // Returns true if the function is successful. Otherwise, an error message |
| + // can be written into |error|. |
| + // |
| + // IMPORTANT: This function is atomic. Either all rules that are deemed |
| + // relevant are added or none. |
| + virtual bool AddRules(const std::string& extension_id, |
| + const std::vector<DictionaryValue*>& rules, |
| + std::string* error) = 0; |
| + |
| + // Unregisters all rules listed in |rule_identifiers| and owned by |
| + // |extension_id| from this RulesRegistry. If |rule_identifiers| is empty, all |
| + // rules of this extension will be unregistered. |
| + // Some or all IDs in |rule_identifiers| may not affect this RulesRegistry. |
| + // |
| + // Returns true if the function is successful. Otherwise, an error message |
| + // can be written into |error|. |
| + // |
| + // IMPORTANT: This function is atomic. Either all rules that are deemed |
| + // relevant are removed or none. |
| + virtual bool RemoveRules(const std::string& extension_id, |
| + const std::vector<std::string>& rule_identifiers, |
| + std::string* error) = 0; |
|
not at google - send to devlin
2012/02/07 03:25:10
I think it's possible/simpler to return a std::str
battre
2012/02/07 18:45:33
We need to change the interface to be asynchronous
not at google - send to devlin
2012/02/07 23:54:57
Do you mean the FILE thread? IO thread is for IPC
battre
2012/02/08 12:49:54
The network stack lives on the IO thread. For the
not at google - send to devlin
2012/02/08 22:31:18
Cool, sounds good.
|
| + |
| + // Returns all rules listed in |rule_identifiers| and owned by |extension_id| |
| + // registered in this RuleRegistry. If |rule_identifiers| is empty, all rules |
| + // of |extension_id| are returned. |
| + // The returned rules are stored in |out|. Ownership is passed to the caller. |
| + virtual void GetRules(const std::string& extension_id, |
| + const std::vector<std::string>& rule_identifiers, |
| + std::vector<DictionaryValue*>* out) = 0; |
|
not at google - send to devlin
2012/02/07 23:54:57
Should GetRules have the ability to report errors?
battre
2012/02/08 12:49:54
Done.
|
| + |
| + // Called to notify the RulesRegistry that an extension has been unloaded |
| + // and all rules of this extension need to be removed. |
| + virtual void OnExtensionUnloaded(const std::string& extension_id) = 0; |
| +}; |
| + |
| +} // namespace extensions |
| + |
| +#endif // CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_RULES_REGISTRY_H__ |