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

Unified Diff: chrome/browser/extensions/api/declarative/rules_registry_service.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/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..e14904dded50619071a58d5682014f9445a63e8b
--- /dev/null
+++ b/chrome/browser/extensions/api/declarative/rules_registry_service.h
@@ -0,0 +1,66 @@
+// 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/memory/linked_ptr.h"
+#include "base/memory/scoped_ptr.h"
+#include "content/public/browser/notification_observer.h"
+#include "content/public/browser/notification_registrar.h"
+
+class Profile;
+
+namespace content {
+class NotificationSource;
+class NotificationSource;
+}
+
+namespace extensions {
+class RulesRegistry;
+}
+
+namespace extensions {
+
+// This class owns all RulesRegistries implementations of an ExtensionService.
+class RulesRegistryService : public content::NotificationObserver {
+ public:
+ explicit RulesRegistryService(Profile* profile);
+ virtual ~RulesRegistryService();
+
+ // Registers a RulesRegistry and wraps it in an InitializingRulesRegistry.
+ void RegisterRulesRegistry(const std::string& event_name,
+ scoped_ptr<RulesRegistry> rule_registry);
+
+ // Returns the RulesRegistry for |event_name| or NULL if no such registry
+ // has been registered.
+ RulesRegistry* GetRulesRegistry(const std::string& event_name) const;
+
+ private:
+ // Maps event names to RuleRegistries that handle these events.
+ typedef std::map<std::string, linked_ptr<RulesRegistry> > RulesRegistryMap;
+
+ // Notifies all RulesRegistries that |extension_id| was unloaded.
+ void OnExtensionUnloaded(const std::string& extension_id);
+
+ // Implementation of content::NotificationObserver.
+ virtual void Observe(int type,
+ const content::NotificationSource& source,
+ const content::NotificationDetails& details) OVERRIDE;
+
+ RulesRegistryMap rule_registries_;
+
+ content::NotificationRegistrar registrar_;
+
+ DISALLOW_COPY_AND_ASSIGN(RulesRegistryService);
+};
+
+} // namespace extensions
+
+#endif // CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_RULES_REGISTRY_SERVICE_H__

Powered by Google App Engine
This is Rietveld 408576698