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

Unified 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: Fixed comiler errors 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/api/declarative/test_rules_registry.h
diff --git a/chrome/browser/extensions/api/declarative/test_rules_registry.h b/chrome/browser/extensions/api/declarative/test_rules_registry.h
new file mode 100644
index 0000000000000000000000000000000000000000..4100587bc85cc0990a03a591a182f9b2c7824cd5
--- /dev/null
+++ b/chrome/browser/extensions/api/declarative/test_rules_registry.h
@@ -0,0 +1,57 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_TEST_RULES_REGISTRY_H__
+#define CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_TEST_RULES_REGISTRY_H__
+#pragma once
+
+#include "chrome/browser/extensions/api/declarative/rules_registry.h"
+
+#include <map>
+#include <string>
+
+#include "base/compiler_specific.h"
+#include "base/memory/linked_ptr.h"
+
+namespace extensions {
+
+// This is currently a trivial stub that can only store and retrieve rules.
+//
+// TODO(battre): Generalize this into a StoringRulesRegistry from which
+// other concrete RulesRegistries can derive. The purpose of this class
+// would then be to handle just the storage of rules.
+class TestRulesRegistry : public RulesRegistry {
+ public:
+ TestRulesRegistry();
+ virtual ~TestRulesRegistry();
+
+ // RulesRegistry implementation:
+ virtual std::string AddRules(
+ const std::string& extension_id,
+ const std::vector<base::DictionaryValue*>& rules) OVERRIDE;
+ virtual std::string RemoveRules(
+ const std::string& extension_id,
+ const std::vector<std::string>& rule_identifiers) OVERRIDE;
+ virtual std::string RemoveAllRules(
+ const std::string& extension_id) OVERRIDE;
+ virtual std::string GetRules(
+ const std::string& extension_id,
+ const std::vector<std::string>& rule_identifiers,
+ std::vector<base::DictionaryValue*>* out) OVERRIDE;
+ virtual std::string GetAllRules(
+ const std::string& extension_id,
+ std::vector<base::DictionaryValue*>* out) OVERRIDE;
+ virtual void OnExtensionUnloaded(const std::string& extension_id) OVERRIDE;
+
+ private:
+ // Map of rule identifier to actual rule.
+ // TODO(battre): consider the extension_ids as part of the key.
+ typedef std::map<std::string, linked_ptr<base::DictionaryValue> >
+ RulesDictionary;
+ RulesDictionary rules_;
+};
+
+} // namespace extensions
+
+#endif // CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_TEST_RULES_REGISTRY_H__

Powered by Google App Engine
This is Rietveld 408576698