[email protected] | 3162254 | 2013-05-30 19:42:30 | [diff] [blame] | 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. | ||||
4 | |||||
5 | #ifndef CHROME_BROWSER_EXTENSIONS_PLUGIN_MANAGER_H_ | ||||
6 | #define CHROME_BROWSER_EXTENSIONS_PLUGIN_MANAGER_H_ | ||||
7 | |||||
[email protected] | 6edb6488 | 2014-06-12 22:57:54 | [diff] [blame] | 8 | #include <set> |
9 | #include <string> | ||||
10 | |||||
[email protected] | 96ac596 | 2014-04-22 19:49:58 | [diff] [blame] | 11 | #include "base/scoped_observer.h" |
[email protected] | 4bf3bed | 2014-03-05 10:21:02 | [diff] [blame] | 12 | #include "extensions/browser/browser_context_keyed_api_factory.h" |
[email protected] | 96ac596 | 2014-04-22 19:49:58 | [diff] [blame] | 13 | #include "extensions/browser/extension_registry_observer.h" |
[email protected] | b90f343 | 2014-08-07 20:40:07 | [diff] [blame^] | 14 | #include "extensions/common/manifest_handlers/nacl_modules_handler.h" |
[email protected] | 3162254 | 2013-05-30 19:42:30 | [diff] [blame] | 15 | |
16 | class GURL; | ||||
17 | class Profile; | ||||
18 | |||||
[email protected] | c4b717a77 | 2014-02-25 19:24:41 | [diff] [blame] | 19 | namespace content { |
20 | class BrowserContext; | ||||
21 | } | ||||
22 | |||||
[email protected] | 3162254 | 2013-05-30 19:42:30 | [diff] [blame] | 23 | namespace extensions { |
[email protected] | 96ac596 | 2014-04-22 19:49:58 | [diff] [blame] | 24 | class ExtensionRegistry; |
[email protected] | 3162254 | 2013-05-30 19:42:30 | [diff] [blame] | 25 | |
[email protected] | 4bf3bed | 2014-03-05 10:21:02 | [diff] [blame] | 26 | class PluginManager : public BrowserContextKeyedAPI, |
[email protected] | 96ac596 | 2014-04-22 19:49:58 | [diff] [blame] | 27 | public ExtensionRegistryObserver { |
[email protected] | 3162254 | 2013-05-30 19:42:30 | [diff] [blame] | 28 | public: |
[email protected] | c4b717a77 | 2014-02-25 19:24:41 | [diff] [blame] | 29 | explicit PluginManager(content::BrowserContext* context); |
[email protected] | 3162254 | 2013-05-30 19:42:30 | [diff] [blame] | 30 | virtual ~PluginManager(); |
31 | |||||
[email protected] | 4bf3bed | 2014-03-05 10:21:02 | [diff] [blame] | 32 | // BrowserContextKeyedAPI implementation. |
33 | static BrowserContextKeyedAPIFactory<PluginManager>* GetFactoryInstance(); | ||||
[email protected] | 3162254 | 2013-05-30 19:42:30 | [diff] [blame] | 34 | |
[email protected] | 3162254 | 2013-05-30 19:42:30 | [diff] [blame] | 35 | private: |
[email protected] | 4bf3bed | 2014-03-05 10:21:02 | [diff] [blame] | 36 | friend class BrowserContextKeyedAPIFactory<PluginManager>; |
[email protected] | 3162254 | 2013-05-30 19:42:30 | [diff] [blame] | 37 | |
[email protected] | 7b47431 | 2014-07-17 08:35:43 | [diff] [blame] | 38 | #if !defined(DISABLE_NACL) |
39 | |||||
[email protected] | 3162254 | 2013-05-30 19:42:30 | [diff] [blame] | 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 | ||||
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 | ||||
44 | // type, like application/pdf. Note: We only register NaCl modules in the | ||||
45 | // browser process. | ||||
46 | void RegisterNaClModule(const NaClModuleInfo& info); | ||||
47 | void UnregisterNaClModule(const NaClModuleInfo& info); | ||||
48 | |||||
[email protected] | 3162254 | 2013-05-30 19:42:30 | [diff] [blame] | 49 | // Call UpdatePluginListWithNaClModules() after registering or unregistering |
50 | // a NaCl module to see those changes reflected in the PluginList. | ||||
51 | void UpdatePluginListWithNaClModules(); | ||||
52 | |||||
53 | extensions::NaClModuleInfo::List::iterator FindNaClModule(const GURL& url); | ||||
54 | |||||
[email protected] | 7b47431 | 2014-07-17 08:35:43 | [diff] [blame] | 55 | #endif // !defined(DISABLE_NACL) |
56 | |||||
[email protected] | 96ac596 | 2014-04-22 19:49:58 | [diff] [blame] | 57 | // ExtensionRegistryObserver implementation. |
58 | virtual void OnExtensionLoaded(content::BrowserContext* browser_context, | ||||
59 | const Extension* extension) OVERRIDE; | ||||
60 | virtual void OnExtensionUnloaded( | ||||
61 | content::BrowserContext* browser_context, | ||||
62 | const Extension* extension, | ||||
63 | UnloadedExtensionInfo::Reason reason) OVERRIDE; | ||||
64 | |||||
[email protected] | 4bf3bed | 2014-03-05 10:21:02 | [diff] [blame] | 65 | // BrowserContextKeyedAPI implementation. |
[email protected] | 3162254 | 2013-05-30 19:42:30 | [diff] [blame] | 66 | static const char* service_name() { return "PluginManager"; } |
67 | static const bool kServiceIsNULLWhileTesting = true; | ||||
68 | |||||
69 | extensions::NaClModuleInfo::List nacl_module_list_; | ||||
70 | |||||
[email protected] | 3162254 | 2013-05-30 19:42:30 | [diff] [blame] | 71 | Profile* profile_; |
[email protected] | 96ac596 | 2014-04-22 19:49:58 | [diff] [blame] | 72 | |
73 | // Listen to extension load, unloaded notifications. | ||||
74 | ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver> | ||||
75 | extension_registry_observer_; | ||||
[email protected] | 3162254 | 2013-05-30 19:42:30 | [diff] [blame] | 76 | }; |
77 | |||||
78 | } // namespace extensions | ||||
79 | |||||
80 | #endif // CHROME_BROWSER_EXTENSIONS_PLUGIN_MANAGER_H_ |