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

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: Merged with ToT for trybot testing 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 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;
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.
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;
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.
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__
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698