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

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

Issue 9315010: RulesRegistry for declarative APIs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed remaining comments 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_SERVICE_H__
6 #define CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_RULES_REGISTRY_SERVICE_H__
7 #pragma once
8
9 #include <map>
10 #include <string>
11 #include <vector>
12
13 #include "base/compiler_specific.h"
14 #include "base/memory/linked_ptr.h"
15 #include "base/memory/scoped_ptr.h"
16 #include "base/values.h"
17
18 namespace extensions {
19 class RulesRegistry;
20 }
21
22 namespace extensions {
23
24 // This is a dispatcher that delegates function calls to other RuleRegistries
25 // according to the names of events to which the RuleRegistries are mapped.
26 class RulesRegistryService {
27 public:
28 RulesRegistryService();
29 virtual ~RulesRegistryService();
30
31 // Registers a RulesRegistry such that all calls for |event_name| are
32 // dispatched to this RulesRegistry. The |rule_registry| is wrapped
33 // in an InitializingRulesRegistry.
34 void RegisterRulesRegistry(const std::string& event_name,
35 scoped_ptr<RulesRegistry> rule_registry);
36
37 // For testing:
38 void UnregisterAllRulesRegistries();
not at google - send to devlin 2012/02/07 03:25:10 it's unfortunate to need this; see comment in the
battre 2012/02/07 18:45:33 Done.
39
40 // RulesRegistry alike implementation. We add an additional |event_name|
41 // to each function, which represents the name of the JavaScript object
42 // on which the function was called.
not at google - send to devlin 2012/02/07 03:25:10 This interface could be cleaned up a lot by only h
battre 2012/02/07 18:45:33 Done.
43 bool AddRules(const std::string& event_name,
44 const std::string& extension_id,
45 const std::vector<DictionaryValue*>& rules,
46 std::string* error);
47 bool RemoveRules(const std::string& event_name,
48 const std::string& extension_id,
49 const std::vector<std::string>& rule_identifiers,
50 std::string* error);
51 void GetRules(const std::string& event_name,
52 const std::string& extension_id,
53 const std::vector<std::string>& rule_identifiers,
54 std::vector<DictionaryValue*>* out);
55 void OnExtensionUnloaded(const std::string& extension_id);
56
57 private:
58 // Maps event names to RuleRegistries that handle these events.
59 // Owns the RuleRegistry objects.
60 typedef std::map<std::string, linked_ptr<RulesRegistry> > RulesRegistryMap;
61 RulesRegistryMap rule_registries_;
62
63 DISALLOW_COPY_AND_ASSIGN(RulesRegistryService);
64 };
65
66 } // namespace extensions
67
68 #endif // CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_RULES_REGISTRY_SERVICE_H__
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698