| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_EXTENSIONS_PLUGIN_MANAGER_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_PLUGIN_MANAGER_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_PLUGIN_MANAGER_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_PLUGIN_MANAGER_H_ |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/scoped_observer.h" | 11 #include "base/scoped_observer.h" |
| 12 #include "extensions/browser/browser_context_keyed_api_factory.h" | 12 #include "extensions/browser/browser_context_keyed_api_factory.h" |
| 13 #include "extensions/browser/extension_registry_observer.h" | 13 #include "extensions/browser/extension_registry_observer.h" |
| 14 #include "extensions/common/manifest_handlers/nacl_modules_handler.h" | 14 #include "extensions/common/manifest_handlers/nacl_modules_handler.h" |
| 15 | 15 |
| 16 class GURL; | 16 class GURL; |
| 17 class Profile; | 17 class Profile; |
| 18 | 18 |
| 19 namespace content { | 19 namespace content { |
| 20 class BrowserContext; | 20 class BrowserContext; |
| 21 } | 21 } |
| 22 | 22 |
| 23 namespace extensions { | 23 namespace extensions { |
| 24 class ExtensionRegistry; | 24 class ExtensionRegistry; |
| 25 | 25 |
| 26 class PluginManager : public BrowserContextKeyedAPI, | 26 class PluginManager : public BrowserContextKeyedAPI, |
| 27 public ExtensionRegistryObserver { | 27 public ExtensionRegistryObserver { |
| 28 public: | 28 public: |
| 29 explicit PluginManager(content::BrowserContext* context); | 29 explicit PluginManager(content::BrowserContext* context); |
| 30 virtual ~PluginManager(); | 30 ~PluginManager() override; |
| 31 | 31 |
| 32 // BrowserContextKeyedAPI implementation. | 32 // BrowserContextKeyedAPI implementation. |
| 33 static BrowserContextKeyedAPIFactory<PluginManager>* GetFactoryInstance(); | 33 static BrowserContextKeyedAPIFactory<PluginManager>* GetFactoryInstance(); |
| 34 | 34 |
| 35 private: | 35 private: |
| 36 friend class BrowserContextKeyedAPIFactory<PluginManager>; | 36 friend class BrowserContextKeyedAPIFactory<PluginManager>; |
| 37 | 37 |
| 38 #if !defined(DISABLE_NACL) | 38 #if !defined(DISABLE_NACL) |
| 39 | 39 |
| 40 // We implement some Pepper plug-ins using NaCl to take advantage of NaCl's | 40 // We implement some Pepper plug-ins using NaCl to take advantage of NaCl's |
| 41 // strong sandbox. Typically, these NaCl modules are stored in extensions | 41 // strong sandbox. Typically, these NaCl modules are stored in extensions |
| 42 // and registered here. Not all NaCl modules need to register for a MIME | 42 // and registered here. Not all NaCl modules need to register for a MIME |
| 43 // type, just the ones that are responsible for rendering a particular MIME | 43 // type, just the ones that are responsible for rendering a particular MIME |
| 44 // type, like application/pdf. Note: We only register NaCl modules in the | 44 // type, like application/pdf. Note: We only register NaCl modules in the |
| 45 // browser process. | 45 // browser process. |
| 46 void RegisterNaClModule(const NaClModuleInfo& info); | 46 void RegisterNaClModule(const NaClModuleInfo& info); |
| 47 void UnregisterNaClModule(const NaClModuleInfo& info); | 47 void UnregisterNaClModule(const NaClModuleInfo& info); |
| 48 | 48 |
| 49 // Call UpdatePluginListWithNaClModules() after registering or unregistering | 49 // Call UpdatePluginListWithNaClModules() after registering or unregistering |
| 50 // a NaCl module to see those changes reflected in the PluginList. | 50 // a NaCl module to see those changes reflected in the PluginList. |
| 51 void UpdatePluginListWithNaClModules(); | 51 void UpdatePluginListWithNaClModules(); |
| 52 | 52 |
| 53 extensions::NaClModuleInfo::List::iterator FindNaClModule(const GURL& url); | 53 extensions::NaClModuleInfo::List::iterator FindNaClModule(const GURL& url); |
| 54 | 54 |
| 55 #endif // !defined(DISABLE_NACL) | 55 #endif // !defined(DISABLE_NACL) |
| 56 | 56 |
| 57 // ExtensionRegistryObserver implementation. | 57 // ExtensionRegistryObserver implementation. |
| 58 virtual void OnExtensionLoaded(content::BrowserContext* browser_context, | 58 void OnExtensionLoaded(content::BrowserContext* browser_context, |
| 59 const Extension* extension) override; | 59 const Extension* extension) override; |
| 60 virtual void OnExtensionUnloaded( | 60 void OnExtensionUnloaded(content::BrowserContext* browser_context, |
| 61 content::BrowserContext* browser_context, | 61 const Extension* extension, |
| 62 const Extension* extension, | 62 UnloadedExtensionInfo::Reason reason) override; |
| 63 UnloadedExtensionInfo::Reason reason) override; | |
| 64 | 63 |
| 65 // BrowserContextKeyedAPI implementation. | 64 // BrowserContextKeyedAPI implementation. |
| 66 static const char* service_name() { return "PluginManager"; } | 65 static const char* service_name() { return "PluginManager"; } |
| 67 static const bool kServiceIsNULLWhileTesting = true; | 66 static const bool kServiceIsNULLWhileTesting = true; |
| 68 | 67 |
| 69 extensions::NaClModuleInfo::List nacl_module_list_; | 68 extensions::NaClModuleInfo::List nacl_module_list_; |
| 70 | 69 |
| 71 Profile* profile_; | 70 Profile* profile_; |
| 72 | 71 |
| 73 // Listen to extension load, unloaded notifications. | 72 // Listen to extension load, unloaded notifications. |
| 74 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver> | 73 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver> |
| 75 extension_registry_observer_; | 74 extension_registry_observer_; |
| 76 }; | 75 }; |
| 77 | 76 |
| 78 } // namespace extensions | 77 } // namespace extensions |
| 79 | 78 |
| 80 #endif // CHROME_BROWSER_EXTENSIONS_PLUGIN_MANAGER_H_ | 79 #endif // CHROME_BROWSER_EXTENSIONS_PLUGIN_MANAGER_H_ |
| OLD | NEW |