Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(122)

Side by Side Diff: chrome/browser/extensions/api/declarative/rules_registry.h

Issue 9315010: RulesRegistry for declarative APIs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Removed a CHECK Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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 an empty string if the function is successful or an error
32 // message otherwise.
33 //
34 // IMPORTANT: This function is atomic. Either all rules that are deemed
35 // relevant are added or none.
36 virtual std::string AddRules(
37 const std::string& extension_id,
38 const std::vector<DictionaryValue*>& rules) = 0;
39
40 // Unregisters all rules listed in |rule_identifiers| and owned by
41 // |extension_id| from this RulesRegistry.
42 // Some or all IDs in |rule_identifiers| may not affect this RulesRegistry.
43 //
44 // Returns an empty string if the function is successful or an error
45 // message otherwise.
46 //
47 // IMPORTANT: This function is atomic. Either all rules that are deemed
48 // relevant are removed or none.
49 virtual std::string RemoveRules(
50 const std::string& extension_id,
51 const std::vector<std::string>& rule_identifiers) = 0;
52
53 // Same as RemoveAllRules but acts on all rules owned by |extension_id|.
54 virtual std::string RemoveAllRules(const std::string& extension_id) = 0;
55
56 // Returns all rules listed in |rule_identifiers| and owned by |extension_id|
57 // registered in this RuleRegistry.
58 //
59 // The returned rules are stored in |out|. Ownership is passed to the caller.
60 //
61 // Returns an empty string if the function is successful or an error
62 // message otherwise.
63 virtual std::string GetRules(const std::string& extension_id,
64 const std::vector<std::string>& rule_identifiers,
65 std::vector<DictionaryValue*>* out) = 0;
66
67 // Same as GetRules but returns all rules owned by |extension_id|.
68 virtual std::string GetAllRules(const std::string& extension_id,
69 std::vector<DictionaryValue*>* out) = 0;
70
71 // Called to notify the RulesRegistry that an extension has been unloaded
72 // and all rules of this extension need to be removed.
73 virtual void OnExtensionUnloaded(const std::string& extension_id) = 0;
74 };
75
76 } // namespace extensions
77
78 #endif // CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_RULES_REGISTRY_H__
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698