| OLD | NEW |
| (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 namespace extensions { |
| 18 |
| 19 // This is currently a trivial stub that can only store and retrieve rules. |
| 20 // |
| 21 // TODO(battre): Generalize this into a StoringRulesRegistry from which |
| 22 // other concrete RulesRegistries can derive. The purpose of this class |
| 23 // would then be to handle just the storage of rules. |
| 24 class TestRulesRegistry : public RulesRegistry { |
| 25 public: |
| 26 TestRulesRegistry(); |
| 27 virtual ~TestRulesRegistry(); |
| 28 |
| 29 // RulesRegistry implementation: |
| 30 virtual std::string AddRules( |
| 31 const std::string& extension_id, |
| 32 const std::vector<base::DictionaryValue*>& rules) OVERRIDE; |
| 33 virtual std::string RemoveRules( |
| 34 const std::string& extension_id, |
| 35 const std::vector<std::string>& rule_identifiers) OVERRIDE; |
| 36 virtual std::string RemoveAllRules( |
| 37 const std::string& extension_id) OVERRIDE; |
| 38 virtual std::string GetRules( |
| 39 const std::string& extension_id, |
| 40 const std::vector<std::string>& rule_identifiers, |
| 41 std::vector<base::DictionaryValue*>* out) OVERRIDE; |
| 42 virtual std::string GetAllRules( |
| 43 const std::string& extension_id, |
| 44 std::vector<base::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<base::DictionaryValue> > |
| 51 RulesDictionary; |
| 52 RulesDictionary rules_; |
| 53 }; |
| 54 |
| 55 } // namespace extensions |
| 56 |
| 57 #endif // CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_TEST_RULES_REGISTRY_H__ |
| OLD | NEW |