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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_EXTENSIONS_PLUGIN_MANAGER_H_
6 #define CHROME_BROWSER_EXTENSIONS_PLUGIN_MANAGER_H_
8 #include "base/scoped_observer.h"
9 #include "chrome/common/extensions/manifest_handlers/nacl_modules_handler.h"
10 #include "extensions/browser/browser_context_keyed_api_factory.h"
11 #include "extensions/browser/extension_registry_observer.h"
20 namespace extensions
{
21 class ExtensionRegistry
;
23 class PluginManager
: public BrowserContextKeyedAPI
,
24 public ExtensionRegistryObserver
{
26 explicit PluginManager(content::BrowserContext
* context
);
27 virtual ~PluginManager();
29 // BrowserContextKeyedAPI implementation.
30 static BrowserContextKeyedAPIFactory
<PluginManager
>* GetFactoryInstance();
33 friend class BrowserContextKeyedAPIFactory
<PluginManager
>;
35 // We implement some Pepper plug-ins using NaCl to take advantage of NaCl's
36 // strong sandbox. Typically, these NaCl modules are stored in extensions
37 // and registered here. Not all NaCl modules need to register for a MIME
38 // type, just the ones that are responsible for rendering a particular MIME
39 // type, like application/pdf. Note: We only register NaCl modules in the
41 void RegisterNaClModule(const NaClModuleInfo
& info
);
42 void UnregisterNaClModule(const NaClModuleInfo
& info
);
44 // Call UpdatePluginListWithNaClModules() after registering or unregistering
45 // a NaCl module to see those changes reflected in the PluginList.
46 void UpdatePluginListWithNaClModules();
48 extensions::NaClModuleInfo::List::iterator
FindNaClModule(const GURL
& url
);
50 // ExtensionRegistryObserver implementation.
51 virtual void OnExtensionLoaded(content::BrowserContext
* browser_context
,
52 const Extension
* extension
) OVERRIDE
;
53 virtual void OnExtensionUnloaded(
54 content::BrowserContext
* browser_context
,
55 const Extension
* extension
,
56 UnloadedExtensionInfo::Reason reason
) OVERRIDE
;
58 // BrowserContextKeyedAPI implementation.
59 static const char* service_name() { return "PluginManager"; }
60 static const bool kServiceIsNULLWhileTesting
= true;
62 extensions::NaClModuleInfo::List nacl_module_list_
;
66 // Listen to extension load, unloaded notifications.
67 ScopedObserver
<ExtensionRegistry
, ExtensionRegistryObserver
>
68 extension_registry_observer_
;
71 } // namespace extensions
73 #endif // CHROME_BROWSER_EXTENSIONS_PLUGIN_MANAGER_H_