Chromium Code Reviews| Index: chrome/browser/extensions/api/declarative/rules_registry_service.h |
| diff --git a/chrome/browser/extensions/api/declarative/rules_registry_service.h b/chrome/browser/extensions/api/declarative/rules_registry_service.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..fe8429f4c93f7015faafe2c43f1ca08f4de3f757 |
| --- /dev/null |
| +++ b/chrome/browser/extensions/api/declarative/rules_registry_service.h |
| @@ -0,0 +1,68 @@ |
| +// 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_RULES_REGISTRY_SERVICE_H__ |
| +#define CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_RULES_REGISTRY_SERVICE_H__ |
| +#pragma once |
| + |
| +#include <map> |
| +#include <string> |
| +#include <vector> |
| + |
| +#include "base/compiler_specific.h" |
| +#include "base/memory/linked_ptr.h" |
| +#include "base/memory/scoped_ptr.h" |
| +#include "base/values.h" |
| + |
| +namespace extensions { |
| +class RulesRegistry; |
| +} |
| + |
| +namespace extensions { |
| + |
| +// This is a dispatcher that delegates function calls to other RuleRegistries |
| +// according to the names of events to which the RuleRegistries are mapped. |
| +class RulesRegistryService { |
| + public: |
| + RulesRegistryService(); |
| + virtual ~RulesRegistryService(); |
| + |
| + // Registers a RulesRegistry such that all calls for |event_name| are |
| + // dispatched to this RulesRegistry. The |rule_registry| is wrapped |
| + // in an InitializingRulesRegistry. |
| + void RegisterRulesRegistry(const std::string& event_name, |
| + scoped_ptr<RulesRegistry> rule_registry); |
| + |
| + // For testing: |
| + 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.
|
| + |
| + // RulesRegistry alike implementation. We add an additional |event_name| |
| + // to each function, which represents the name of the JavaScript object |
| + // 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.
|
| + bool AddRules(const std::string& event_name, |
| + const std::string& extension_id, |
| + const std::vector<DictionaryValue*>& rules, |
| + std::string* error); |
| + bool RemoveRules(const std::string& event_name, |
| + const std::string& extension_id, |
| + const std::vector<std::string>& rule_identifiers, |
| + std::string* error); |
| + void GetRules(const std::string& event_name, |
| + const std::string& extension_id, |
| + const std::vector<std::string>& rule_identifiers, |
| + std::vector<DictionaryValue*>* out); |
| + void OnExtensionUnloaded(const std::string& extension_id); |
| + |
| + private: |
| + // Maps event names to RuleRegistries that handle these events. |
| + // Owns the RuleRegistry objects. |
| + typedef std::map<std::string, linked_ptr<RulesRegistry> > RulesRegistryMap; |
| + RulesRegistryMap rule_registries_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(RulesRegistryService); |
| +}; |
| + |
| +} // namespace extensions |
| + |
| +#endif // CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_RULES_REGISTRY_SERVICE_H__ |