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

Side by Side Diff: extensions/browser/api/declarative/rules_registry_service.h

Issue 1158693006: Create a mechanism define declarative rules via the extension manifest. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add thread safety to extensionregistry notifications Created 5 years, 6 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
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 EXTENSIONS_BROWSER_API_DECLARATIVE_RULES_REGISTRY_SERVICE_H__ 5 #ifndef EXTENSIONS_BROWSER_API_DECLARATIVE_RULES_REGISTRY_SERVICE_H__
6 #define EXTENSIONS_BROWSER_API_DECLARATIVE_RULES_REGISTRY_SERVICE_H__ 6 #define EXTENSIONS_BROWSER_API_DECLARATIVE_RULES_REGISTRY_SERVICE_H__
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 // Remove all rules registries of the given rules_registry_id. 81 // Remove all rules registries of the given rules_registry_id.
82 void RemoveRulesRegistriesByID(int rules_registry_id); 82 void RemoveRulesRegistriesByID(int rules_registry_id);
83 83
84 // Accessors for each type of rules registry. 84 // Accessors for each type of rules registry.
85 ContentRulesRegistry* content_rules_registry() const { 85 ContentRulesRegistry* content_rules_registry() const {
86 CHECK(content_rules_registry_); 86 CHECK(content_rules_registry_);
87 return content_rules_registry_; 87 return content_rules_registry_;
88 } 88 }
89 89
90 // For testing. 90 // For testing.
91 void SimulateExtensionUninstalled(const std::string& extension_id); 91 void SimulateExtensionUninstalled(const Extension* extension);
92 92
93 private: 93 private:
94 friend class BrowserContextKeyedAPIFactory<RulesRegistryService>; 94 friend class BrowserContextKeyedAPIFactory<RulesRegistryService>;
95 95
96 // Maps <event name, rules registry ID> to RuleRegistries that handle these 96 // Maps <event name, rules registry ID> to RuleRegistries that handle these
97 // events. 97 // events.
98 typedef std::map<RulesRegistryKey, scoped_refptr<RulesRegistry> > 98 typedef std::map<RulesRegistryKey, scoped_refptr<RulesRegistry> >
99 RulesRegistryMap; 99 RulesRegistryMap;
100 100
101 // ExtensionRegistryObserver implementation. 101 // ExtensionRegistryObserver implementation.
102 void OnExtensionLoaded(content::BrowserContext* browser_context, 102 void OnExtensionLoaded(content::BrowserContext* browser_context,
103 const Extension* extension) override; 103 const Extension* extension) override;
104 void OnExtensionUnloaded(content::BrowserContext* browser_context, 104 void OnExtensionUnloaded(content::BrowserContext* browser_context,
105 const Extension* extension, 105 const Extension* extension,
106 UnloadedExtensionInfo::Reason reason) override; 106 UnloadedExtensionInfo::Reason reason) override;
107 void OnExtensionUninstalled(content::BrowserContext* browser_context, 107 void OnExtensionUninstalled(content::BrowserContext* browser_context,
108 const Extension* extension, 108 const Extension* extension,
109 extensions::UninstallReason reason) override; 109 extensions::UninstallReason reason) override;
110 110
111 // Iterates over all registries, and calls |notification_callback| on them 111 // Iterates over all registries, and calls |notification_callback| on them
112 // with |extension_id| as the argument. If a registry lives on a different 112 // with |extension| as the argument. If a registry lives on a different
113 // thread, the call is posted to that thread, so no guarantee of synchronous 113 // thread, the call is posted to that thread, so no guarantee of synchronous
114 // processing. 114 // processing.
115 void NotifyRegistriesHelper( 115 void NotifyRegistriesHelper(
116 void (RulesRegistry::*notification_callback)(const std::string&), 116 void (RulesRegistry::*notification_callback)(const Extension*),
117 const std::string& extension_id); 117 const Extension* extension);
118 118
119 // BrowserContextKeyedAPI implementation. 119 // BrowserContextKeyedAPI implementation.
120 static const char* service_name() { 120 static const char* service_name() {
121 return "RulesRegistryService"; 121 return "RulesRegistryService";
122 } 122 }
123 static const bool kServiceHasOwnInstanceInIncognito = true; 123 static const bool kServiceHasOwnInstanceInIncognito = true;
124 static const bool kServiceIsNULLWhileTesting = true; 124 static const bool kServiceIsNULLWhileTesting = true;
125 125
126 int current_rules_registry_id_; 126 int current_rules_registry_id_;
127 127
(...skipping 11 matching lines...) Expand all
139 extension_registry_observer_; 139 extension_registry_observer_;
140 140
141 content::BrowserContext* browser_context_; 141 content::BrowserContext* browser_context_;
142 142
143 DISALLOW_COPY_AND_ASSIGN(RulesRegistryService); 143 DISALLOW_COPY_AND_ASSIGN(RulesRegistryService);
144 }; 144 };
145 145
146 } // namespace extensions 146 } // namespace extensions
147 147
148 #endif // EXTENSIONS_BROWSER_API_DECLARATIVE_RULES_REGISTRY_SERVICE_H__ 148 #endif // EXTENSIONS_BROWSER_API_DECLARATIVE_RULES_REGISTRY_SERVICE_H__
OLDNEW
« no previous file with comments | « extensions/browser/api/declarative/rules_registry.cc ('k') | extensions/browser/api/declarative/rules_registry_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698