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

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

Issue 9422003: Migrate Declarative API bindings to new JSON objects generated by JSON compiler (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed comments and fixed some stuff 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
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_RULES_REGISTRY_H__ 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_RULES_REGISTRY_H__
6 #define CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_RULES_REGISTRY_H__ 6 #define CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_RULES_REGISTRY_H__
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "chrome/common/extensions/api/experimental.declarative.h"
13 #include "content/public/browser/browser_thread.h"
14
12 namespace base { 15 namespace base {
13 class DictionaryValue; 16 class DictionaryValue;
14 } 17 }
15 18
16 namespace extensions { 19 namespace extensions {
17 20
18 // Interface for rule registries. 21 // Interface for rule registries.
19 class RulesRegistry { 22 class RulesRegistry {
20 public: 23 public:
24 typedef extensions::api::experimental_declarative::Rule Rule;
Matt Perry 2012/02/21 23:43:42 I believe "using extensions::api::experimental_dec
battre 2012/02/28 22:29:18 This does not work.
25
21 virtual ~RulesRegistry() {} 26 virtual ~RulesRegistry() {}
22 27
23 // Registers |rules|, owned by |extension_id| to this RulesRegistry. 28 // Registers |rules|, owned by |extension_id| to this RulesRegistry.
24 // If a concrete RuleRegistry does not support some of the rules, 29 // If a concrete RuleRegistry does not support some of the rules,
25 // it may ignore them. 30 // it may ignore them.
26 // 31 //
27 // |rules| is a list of Rule instances following the definition of the 32 // |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 33 // 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 34 // a unique name within the scope of |extension_id| that has not been
30 // registered before, unless it has been removed again. 35 // registered before, unless it has been removed again.
31 // The ownership of rules remains with the caller. 36 // The ownership of rules remains with the caller.
32 // 37 //
33 // Returns an empty string if the function is successful or an error 38 // Returns an empty string if the function is successful or an error
34 // message otherwise. 39 // message otherwise.
35 // 40 //
36 // IMPORTANT: This function is atomic. Either all rules that are deemed 41 // IMPORTANT: This function is atomic. Either all rules that are deemed
37 // relevant are added or none. 42 // relevant are added or none.
38 virtual std::string AddRules( 43 virtual std::string AddRules(
39 const std::string& extension_id, 44 const std::string& extension_id,
40 const std::vector<base::DictionaryValue*>& rules) = 0; 45 const std::vector<linked_ptr<Rule> >& rules) = 0;
41 46
42 // Unregisters all rules listed in |rule_identifiers| and owned by 47 // Unregisters all rules listed in |rule_identifiers| and owned by
43 // |extension_id| from this RulesRegistry. 48 // |extension_id| from this RulesRegistry.
44 // Some or all IDs in |rule_identifiers| may not affect this RulesRegistry. 49 // Some or all IDs in |rule_identifiers| may not affect this RulesRegistry.
45 // 50 //
46 // Returns an empty string if the function is successful or an error 51 // Returns an empty string if the function is successful or an error
47 // message otherwise. 52 // message otherwise.
48 // 53 //
49 // IMPORTANT: This function is atomic. Either all rules that are deemed 54 // IMPORTANT: This function is atomic. Either all rules that are deemed
50 // relevant are removed or none. 55 // relevant are removed or none.
51 virtual std::string RemoveRules( 56 virtual std::string RemoveRules(
52 const std::string& extension_id, 57 const std::string& extension_id,
53 const std::vector<std::string>& rule_identifiers) = 0; 58 const std::vector<std::string>& rule_identifiers) = 0;
54 59
55 // Same as RemoveAllRules but acts on all rules owned by |extension_id|. 60 // Same as RemoveAllRules but acts on all rules owned by |extension_id|.
56 virtual std::string RemoveAllRules(const std::string& extension_id) = 0; 61 virtual std::string RemoveAllRules(const std::string& extension_id) = 0;
57 62
58 // Returns all rules listed in |rule_identifiers| and owned by |extension_id| 63 // Returns all rules listed in |rule_identifiers| and owned by |extension_id|
59 // registered in this RuleRegistry. 64 // registered in this RuleRegistry.
60 // 65 //
61 // The returned rules are stored in |out|. Ownership is passed to the caller. 66 // The returned rules are stored in |out|. Ownership is passed to the caller.
62 // 67 //
63 // Returns an empty string if the function is successful or an error 68 // Returns an empty string if the function is successful or an error
64 // message otherwise. 69 // message otherwise.
65 virtual std::string GetRules(const std::string& extension_id, 70 virtual std::string GetRules(const std::string& extension_id,
66 const std::vector<std::string>& rule_identifiers, 71 const std::vector<std::string>& rule_identifiers,
67 std::vector<base::DictionaryValue*>* out) = 0; 72 std::vector<linked_ptr<Rule> >* out) = 0;
68 73
69 // Same as GetRules but returns all rules owned by |extension_id|. 74 // Same as GetRules but returns all rules owned by |extension_id|.
70 virtual std::string GetAllRules(const std::string& extension_id, 75 virtual std::string GetAllRules(const std::string& extension_id,
71 std::vector<base::DictionaryValue*>* out) = 0; 76 std::vector<linked_ptr<Rule> >* out) = 0;
72 77
73 // Called to notify the RulesRegistry that an extension has been unloaded 78 // Called to notify the RulesRegistry that an extension has been unloaded
74 // and all rules of this extension need to be removed. 79 // and all rules of this extension need to be removed.
75 virtual void OnExtensionUnloaded(const std::string& extension_id) = 0; 80 virtual void OnExtensionUnloaded(const std::string& extension_id) = 0;
81
82 // Returns the ID of the thread on which the rules registry lives.
83 virtual content::BrowserThread::ID GetOwnerThread() = 0;
76 }; 84 };
77 85
78 } // namespace extensions 86 } // namespace extensions
79 87
80 #endif // CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_RULES_REGISTRY_H__ 88 #endif // CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_RULES_REGISTRY_H__
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698