| 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_RULES_REGISTRY_SERVICE_H__ |
| 6 #define CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_RULES_REGISTRY_SERVICE_H__ |
| 7 #pragma once |
| 8 |
| 9 #include <map> |
| 10 #include <string> |
| 11 #include <vector> |
| 12 |
| 13 #include "base/memory/linked_ptr.h" |
| 14 #include "base/memory/scoped_ptr.h" |
| 15 #include "content/public/browser/notification_observer.h" |
| 16 #include "content/public/browser/notification_registrar.h" |
| 17 |
| 18 class Profile; |
| 19 |
| 20 namespace content { |
| 21 class NotificationSource; |
| 22 class NotificationSource; |
| 23 } |
| 24 |
| 25 namespace extensions { |
| 26 class RulesRegistry; |
| 27 } |
| 28 |
| 29 namespace extensions { |
| 30 |
| 31 // This class owns all RulesRegistries implementations of an ExtensionService. |
| 32 class RulesRegistryService : public content::NotificationObserver { |
| 33 public: |
| 34 explicit RulesRegistryService(Profile* profile); |
| 35 virtual ~RulesRegistryService(); |
| 36 |
| 37 // Registers a RulesRegistry and wraps it in an InitializingRulesRegistry. |
| 38 void RegisterRulesRegistry(const std::string& event_name, |
| 39 scoped_ptr<RulesRegistry> rule_registry); |
| 40 |
| 41 // Returns the RulesRegistry for |event_name| or NULL if no such registry |
| 42 // has been registered. |
| 43 RulesRegistry* GetRulesRegistry(const std::string& event_name) const; |
| 44 |
| 45 private: |
| 46 // Maps event names to RuleRegistries that handle these events. |
| 47 typedef std::map<std::string, linked_ptr<RulesRegistry> > RulesRegistryMap; |
| 48 |
| 49 // Notifies all RulesRegistries that |extension_id| was unloaded. |
| 50 void OnExtensionUnloaded(const std::string& extension_id); |
| 51 |
| 52 // Implementation of content::NotificationObserver. |
| 53 virtual void Observe(int type, |
| 54 const content::NotificationSource& source, |
| 55 const content::NotificationDetails& details) OVERRIDE; |
| 56 |
| 57 RulesRegistryMap rule_registries_; |
| 58 |
| 59 content::NotificationRegistrar registrar_; |
| 60 |
| 61 DISALLOW_COPY_AND_ASSIGN(RulesRegistryService); |
| 62 }; |
| 63 |
| 64 } // namespace extensions |
| 65 |
| 66 #endif // CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_RULES_REGISTRY_SERVICE_H__ |
| OLD | NEW |