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

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: Removed a CHECK 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 std::string AddRules(
33 const std::string& extension_id,
34 const std::vector<DictionaryValue*>& rules) OVERRIDE;
35 virtual std::string RemoveRules(
36 const std::string& extension_id,
37 const std::vector<std::string>& rule_identifiers) OVERRIDE;
38 virtual std::string RemoveAllRules(
39 const std::string& extension_id) OVERRIDE;
40 virtual std::string GetRules(
41 const std::string& extension_id,
42 const std::vector<std::string>& rule_identifiers,
43 std::vector<DictionaryValue*>* out) OVERRIDE;
44 virtual std::string GetAllRules(
45 const std::string& extension_id,
46 std::vector<DictionaryValue*>* out) OVERRIDE;
47 virtual void OnExtensionUnloaded(const std::string& extension_id) OVERRIDE;
48
49 private:
50 // Map of rule identifier to actual rule.
51 // TODO(battre): consider the extension_ids as part of the key.
52 typedef std::map<std::string, linked_ptr<DictionaryValue> > RulesDictionary;
53 RulesDictionary rules_;
54 };
55
56 } // namespace extensions
57
58 #endif // CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_TEST_RULES_REGISTRY_H__
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698