[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 | |||||
Evan Stade | 75872a6 | 2019-09-06 21:17:38 | [diff] [blame] | 11 | #include "base/macros.h" |
[email protected] | 96ac596 | 2014-04-22 19:49:58 | [diff] [blame] | 12 | #include "base/scoped_observer.h" |
Scott Violet | 9ae8289 | 2018-03-01 18:38:12 | [diff] [blame] | 13 | #include "components/nacl/common/buildflags.h" |
[email protected] | 4bf3bed | 2014-03-05 10:21:02 | [diff] [blame] | 14 | #include "extensions/browser/browser_context_keyed_api_factory.h" |
Evan Stade | 75872a6 | 2019-09-06 21:17:38 | [diff] [blame] | 15 | #include "extensions/browser/extension_registry.h" |
[email protected] | 96ac596 | 2014-04-22 19:49:58 | [diff] [blame] | 16 | #include "extensions/browser/extension_registry_observer.h" |
[email protected] | b90f343 | 2014-08-07 20:40:07 | [diff] [blame] | 17 | #include "extensions/common/manifest_handlers/nacl_modules_handler.h" |
[email protected] | 3162254 | 2013-05-30 19:42:30 | [diff] [blame] | 18 | |
19 | class GURL; | ||||
20 | class Profile; | ||||
21 | |||||
[email protected] | c4b717a77 | 2014-02-25 19:24:41 | [diff] [blame] | 22 | namespace content { |
23 | class BrowserContext; | ||||
24 | } | ||||
25 | |||||
[email protected] | 3162254 | 2013-05-30 19:42:30 | [diff] [blame] | 26 | namespace extensions { |
[email protected] | 3162254 | 2013-05-30 19:42:30 | [diff] [blame] | 27 | |
[email protected] | 4bf3bed | 2014-03-05 10:21:02 | [diff] [blame] | 28 | class PluginManager : public BrowserContextKeyedAPI, |
[email protected] | 96ac596 | 2014-04-22 19:49:58 | [diff] [blame] | 29 | public ExtensionRegistryObserver { |
[email protected] | 3162254 | 2013-05-30 19:42:30 | [diff] [blame] | 30 | public: |
[email protected] | c4b717a77 | 2014-02-25 19:24:41 | [diff] [blame] | 31 | explicit PluginManager(content::BrowserContext* context); |
dcheng | ae36a4a | 2014-10-21 12:36:36 | [diff] [blame] | 32 | ~PluginManager() override; |
[email protected] | 3162254 | 2013-05-30 19:42:30 | [diff] [blame] | 33 | |
[email protected] | 4bf3bed | 2014-03-05 10:21:02 | [diff] [blame] | 34 | // BrowserContextKeyedAPI implementation. |
35 | static BrowserContextKeyedAPIFactory<PluginManager>* GetFactoryInstance(); | ||||
[email protected] | 3162254 | 2013-05-30 19:42:30 | [diff] [blame] | 36 | |
[email protected] | 3162254 | 2013-05-30 19:42:30 | [diff] [blame] | 37 | private: |
[email protected] | 4bf3bed | 2014-03-05 10:21:02 | [diff] [blame] | 38 | friend class BrowserContextKeyedAPIFactory<PluginManager>; |
[email protected] | 3162254 | 2013-05-30 19:42:30 | [diff] [blame] | 39 | |
Nico Weber | af3b00b | 2017-09-11 17:58:17 | [diff] [blame] | 40 | #if BUILDFLAG(ENABLE_NACL) |
[email protected] | 7b47431 | 2014-07-17 08:35:43 | [diff] [blame] | 41 | |
tommycli | e86b298 | 2015-03-16 20:16:45 | [diff] [blame] | 42 | // We implement some Pepper plugins using NaCl to take advantage of NaCl's |
[email protected] | 3162254 | 2013-05-30 19:42:30 | [diff] [blame] | 43 | // strong sandbox. Typically, these NaCl modules are stored in extensions |
44 | // and registered here. Not all NaCl modules need to register for a MIME | ||||
45 | // type, just the ones that are responsible for rendering a particular MIME | ||||
46 | // type, like application/pdf. Note: We only register NaCl modules in the | ||||
47 | // browser process. | ||||
48 | void RegisterNaClModule(const NaClModuleInfo& info); | ||||
49 | void UnregisterNaClModule(const NaClModuleInfo& info); | ||||
50 | |||||
51 | // Call UpdatePluginListWithNaClModules() after registering or unregistering | ||||
52 | // a NaCl module to see those changes reflected in the PluginList. | ||||
53 | void UpdatePluginListWithNaClModules(); | ||||
54 | |||||
55 | extensions::NaClModuleInfo::List::iterator FindNaClModule(const GURL& url); | ||||
56 | |||||
Nico Weber | af3b00b | 2017-09-11 17:58:17 | [diff] [blame] | 57 | #endif // BUILDFLAG(ENABLE_NACL) |
[email protected] | 7b47431 | 2014-07-17 08:35:43 | [diff] [blame] | 58 | |
[email protected] | 96ac596 | 2014-04-22 19:49:58 | [diff] [blame] | 59 | // ExtensionRegistryObserver implementation. |
dcheng | ae36a4a | 2014-10-21 12:36:36 | [diff] [blame] | 60 | void OnExtensionLoaded(content::BrowserContext* browser_context, |
61 | const Extension* extension) override; | ||||
62 | void OnExtensionUnloaded(content::BrowserContext* browser_context, | ||||
63 | const Extension* extension, | ||||
limasdf | 0deef204 | 2017-05-03 19:17:17 | [diff] [blame] | 64 | UnloadedExtensionReason reason) override; |
[email protected] | 96ac596 | 2014-04-22 19:49:58 | [diff] [blame] | 65 | |
[email protected] | 4bf3bed | 2014-03-05 10:21:02 | [diff] [blame] | 66 | // BrowserContextKeyedAPI implementation. |
[email protected] | 3162254 | 2013-05-30 19:42:30 | [diff] [blame] | 67 | static const char* service_name() { return "PluginManager"; } |
68 | static const bool kServiceIsNULLWhileTesting = true; | ||||
69 | |||||
70 | extensions::NaClModuleInfo::List nacl_module_list_; | ||||
71 | |||||
[email protected] | 3162254 | 2013-05-30 19:42:30 | [diff] [blame] | 72 | Profile* profile_; |
[email protected] | 96ac596 | 2014-04-22 19:49:58 | [diff] [blame] | 73 | |
74 | // Listen to extension load, unloaded notifications. | ||||
75 | ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver> | ||||
Evan Stade | 75872a6 | 2019-09-06 21:17:38 | [diff] [blame] | 76 | extension_registry_observer_{this}; |
77 | |||||
78 | DISALLOW_COPY_AND_ASSIGN(PluginManager); | ||||
[email protected] | 3162254 | 2013-05-30 19:42:30 | [diff] [blame] | 79 | }; |
80 | |||||
81 | } // namespace extensions | ||||
82 | |||||
83 | #endif // CHROME_BROWSER_EXTENSIONS_PLUGIN_MANAGER_H_ |