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

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

Issue 9315010: RulesRegistry for declarative APIs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed 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_TEST_RULES_REGISTRY_H__
6 #define CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_TEST_RULES_REGISTRY_H__
7 #pragma once
8
9 #include "chrome/browser/extensions/api/declarative/rules_registry.h"
10
11 #include <map>
12 #include <string>
13
14 #include "base/compiler_specific.h"
15 #include "base/memory/linked_ptr.h"
16
17 class DictionaryValue;
18
19 namespace extensions {
20
21 // This is currently a trivial stub that can only store and retrieve rules.
22 //
23 // TODO(battre): Generalize this into a StoringRulesRegistry from which
24 // other concrete RulesRegistries can derive. The purpose of this class
25 // would then be to handle just the storage of rules.
26 class TestRulesRegistry : public RulesRegistry {
27 public:
28 TestRulesRegistry();
29 virtual ~TestRulesRegistry();
30
31 // RulesRegistry implementation:
32 virtual bool AddRules(const std::string& extension_id,
33 const std::vector<DictionaryValue*>& rules,
34 std::string* error) OVERRIDE;
35 virtual bool RemoveRules(const std::string& extension_id,
36 const std::vector<std::string>& rule_identifiers,
37 std::string* error) OVERRIDE;
38 virtual bool RemoveAllRules(const std::string& extension_id,
39 std::string* error) OVERRIDE;
40 virtual void GetRules(const std::string& extension_id,
41 const std::vector<std::string>& rule_identifiers,
42 std::vector<DictionaryValue*>* out) OVERRIDE;
43 virtual void GetAllRules(const std::string& extension_id,
44 std::vector<DictionaryValue*>* out) OVERRIDE;
45 virtual void OnExtensionUnloaded(const std::string& extension_id) OVERRIDE;
46
47 private:
48 // Map of rule identifier to actual rule.
49 // TODO(battre): consider the extension_ids as part of the key.
50 typedef std::map<std::string, linked_ptr<DictionaryValue> > RulesDictionary;
51 RulesDictionary rules_;
52 };
53
54 } // namespace extensions
55
56 #endif // CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_TEST_RULES_REGISTRY_H__
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698