OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 CONTENT_PUBLIC_BROWSER_PLUGIN_SERVICE_H_ | 5 #ifndef CONTENT_PUBLIC_BROWSER_PLUGIN_SERVICE_H_ |
6 #define CONTENT_PUBLIC_BROWSER_PLUGIN_SERVICE_H_ | 6 #define CONTENT_PUBLIC_BROWSER_PLUGIN_SERVICE_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/callback.h" | 11 #include "base/callback.h" |
12 #include "base/strings/string16.h" | 12 #include "base/strings/string16.h" |
13 #include "content/common/content_export.h" | 13 #include "content/common/content_export.h" |
14 | 14 |
15 class GURL; | 15 class GURL; |
16 | 16 |
17 namespace base { | 17 namespace base { |
18 class FilePath; | 18 class FilePath; |
19 } | 19 } |
20 | 20 |
21 namespace webkit { | |
22 struct WebPluginInfo; | |
23 } | |
24 | |
25 namespace content { | 21 namespace content { |
26 | 22 |
27 class BrowserContext; | 23 class BrowserContext; |
28 class PluginProcessHost; | 24 class PluginProcessHost; |
29 class PluginServiceFilter; | 25 class PluginServiceFilter; |
30 class ResourceContext; | 26 class ResourceContext; |
31 struct PepperPluginInfo; | 27 struct PepperPluginInfo; |
| 28 struct WebPluginInfo; |
32 | 29 |
33 // This must be created on the main thread but it's only called on the IO/file | 30 // This must be created on the main thread but it's only called on the IO/file |
34 // thread. This is an asynchronous wrapper around the PluginList interface for | 31 // thread. This is an asynchronous wrapper around the PluginList interface for |
35 // querying plugin information. This must be used instead of that to avoid | 32 // querying plugin information. This must be used instead of that to avoid |
36 // doing expensive disk operations on the IO/UI threads. | 33 // doing expensive disk operations on the IO/UI threads. |
37 class PluginService { | 34 class PluginService { |
38 public: | 35 public: |
39 typedef base::Callback<void(const std::vector<webkit::WebPluginInfo>&)> | 36 typedef base::Callback<void(const std::vector<WebPluginInfo>&)> |
40 GetPluginsCallback; | 37 GetPluginsCallback; |
41 | 38 |
42 // Returns the PluginService singleton. | 39 // Returns the PluginService singleton. |
43 CONTENT_EXPORT static PluginService* GetInstance(); | 40 CONTENT_EXPORT static PluginService* GetInstance(); |
44 | 41 |
45 // Tells all the renderer processes associated with the given browser context | 42 // Tells all the renderer processes associated with the given browser context |
46 // to throw away their cache of the plugin list, and optionally also reload | 43 // to throw away their cache of the plugin list, and optionally also reload |
47 // all the pages with plugins. If |browser_context| is NULL, purges the cache | 44 // all the pages with plugins. If |browser_context| is NULL, purges the cache |
48 // in all renderers. | 45 // in all renderers. |
49 // NOTE: can only be called on the UI thread. | 46 // NOTE: can only be called on the UI thread. |
50 CONTENT_EXPORT static void PurgePluginListCache( | 47 CONTENT_EXPORT static void PurgePluginListCache( |
51 BrowserContext* browser_context, | 48 BrowserContext* browser_context, |
52 bool reload_pages); | 49 bool reload_pages); |
53 | 50 |
54 virtual ~PluginService() {} | 51 virtual ~PluginService() {} |
55 | 52 |
56 // Must be called on the instance to finish initialization. | 53 // Must be called on the instance to finish initialization. |
57 virtual void Init() = 0; | 54 virtual void Init() = 0; |
58 | 55 |
59 // Starts watching for changes in the list of installed plug-ins. | 56 // Starts watching for changes in the list of installed plug-ins. |
60 virtual void StartWatchingPlugins() = 0; | 57 virtual void StartWatchingPlugins() = 0; |
61 | 58 |
62 // Gets the plugin in the list of plugins that matches the given url and mime | 59 // Gets the plugin in the list of plugins that matches the given url and mime |
63 // type. Returns true if the data is frome a stale plugin list, false if it | 60 // type. Returns true if the data is frome a stale plugin list, false if it |
64 // is up to date. This can be called from any thread. | 61 // is up to date. This can be called from any thread. |
65 virtual bool GetPluginInfoArray( | 62 virtual bool GetPluginInfoArray( |
66 const GURL& url, | 63 const GURL& url, |
67 const std::string& mime_type, | 64 const std::string& mime_type, |
68 bool allow_wildcard, | 65 bool allow_wildcard, |
69 std::vector<webkit::WebPluginInfo>* info, | 66 std::vector<WebPluginInfo>* info, |
70 std::vector<std::string>* actual_mime_types) = 0; | 67 std::vector<std::string>* actual_mime_types) = 0; |
71 | 68 |
72 // Gets plugin info for an individual plugin and filters the plugins using | 69 // Gets plugin info for an individual plugin and filters the plugins using |
73 // the |context| and renderer IDs. This will report whether the data is stale | 70 // the |context| and renderer IDs. This will report whether the data is stale |
74 // via |is_stale| and returns whether or not the plugin can be found. | 71 // via |is_stale| and returns whether or not the plugin can be found. |
75 virtual bool GetPluginInfo(int render_process_id, | 72 virtual bool GetPluginInfo(int render_process_id, |
76 int render_view_id, | 73 int render_view_id, |
77 ResourceContext* context, | 74 ResourceContext* context, |
78 const GURL& url, | 75 const GURL& url, |
79 const GURL& page_url, | 76 const GURL& page_url, |
80 const std::string& mime_type, | 77 const std::string& mime_type, |
81 bool allow_wildcard, | 78 bool allow_wildcard, |
82 bool* is_stale, | 79 bool* is_stale, |
83 webkit::WebPluginInfo* info, | 80 WebPluginInfo* info, |
84 std::string* actual_mime_type) = 0; | 81 std::string* actual_mime_type) = 0; |
85 | 82 |
86 // Get plugin info by plugin path (including disabled plugins). Returns true | 83 // Get plugin info by plugin path (including disabled plugins). Returns true |
87 // if the plugin is found and WebPluginInfo has been filled in |info|. This | 84 // if the plugin is found and WebPluginInfo has been filled in |info|. This |
88 // will use cached data in the plugin list. | 85 // will use cached data in the plugin list. |
89 virtual bool GetPluginInfoByPath(const base::FilePath& plugin_path, | 86 virtual bool GetPluginInfoByPath(const base::FilePath& plugin_path, |
90 webkit::WebPluginInfo* info) = 0; | 87 WebPluginInfo* info) = 0; |
91 | 88 |
92 // Returns the display name for the plugin identified by the given path. If | 89 // Returns the display name for the plugin identified by the given path. If |
93 // the path doesn't identify a plugin, or the plugin has no display name, | 90 // the path doesn't identify a plugin, or the plugin has no display name, |
94 // this will attempt to generate a display name from the path. | 91 // this will attempt to generate a display name from the path. |
95 virtual string16 GetPluginDisplayNameByPath( | 92 virtual string16 GetPluginDisplayNameByPath( |
96 const base::FilePath& plugin_path) = 0; | 93 const base::FilePath& plugin_path) = 0; |
97 | 94 |
98 // Asynchronously loads plugins if necessary and then calls back to the | 95 // Asynchronously loads plugins if necessary and then calls back to the |
99 // provided function on the calling MessageLoop on completion. | 96 // provided function on the calling MessageLoop on completion. |
100 virtual void GetPlugins(const GetPluginsCallback& callback) = 0; | 97 virtual void GetPlugins(const GetPluginsCallback& callback) = 0; |
(...skipping 24 matching lines...) Expand all Loading... |
125 virtual void RemoveExtraPluginPath(const base::FilePath& path) = 0; | 122 virtual void RemoveExtraPluginPath(const base::FilePath& path) = 0; |
126 | 123 |
127 // Same as above, but specifies a directory in which to search for plugins. | 124 // Same as above, but specifies a directory in which to search for plugins. |
128 virtual void AddExtraPluginDir(const base::FilePath& path) = 0; | 125 virtual void AddExtraPluginDir(const base::FilePath& path) = 0; |
129 | 126 |
130 // Register an internal plugin with the specified plugin information. | 127 // Register an internal plugin with the specified plugin information. |
131 // An internal plugin must be registered before it can | 128 // An internal plugin must be registered before it can |
132 // be loaded using PluginList::LoadPlugin(). | 129 // be loaded using PluginList::LoadPlugin(). |
133 // If |add_at_beginning| is true the plugin will be added earlier in | 130 // If |add_at_beginning| is true the plugin will be added earlier in |
134 // the list so that it can override the MIME types of older registrations. | 131 // the list so that it can override the MIME types of older registrations. |
135 virtual void RegisterInternalPlugin(const webkit::WebPluginInfo& info, | 132 virtual void RegisterInternalPlugin(const WebPluginInfo& info, |
136 bool add_at_beginning) = 0; | 133 bool add_at_beginning) = 0; |
137 | 134 |
138 // Removes a specified internal plugin from the list. The search will match | 135 // Removes a specified internal plugin from the list. The search will match |
139 // on the path from the version info previously registered. | 136 // on the path from the version info previously registered. |
140 virtual void UnregisterInternalPlugin(const base::FilePath& path) = 0; | 137 virtual void UnregisterInternalPlugin(const base::FilePath& path) = 0; |
141 | 138 |
142 // Gets a list of all the registered internal plugins. | 139 // Gets a list of all the registered internal plugins. |
143 virtual void GetInternalPlugins( | 140 virtual void GetInternalPlugins(std::vector<WebPluginInfo>* plugins) = 0; |
144 std::vector<webkit::WebPluginInfo>* plugins) = 0; | |
145 | 141 |
146 // Returns true iff NPAPI plugins are supported on the current platform. | 142 // Returns true iff NPAPI plugins are supported on the current platform. |
147 // This can be called from any thread. | 143 // This can be called from any thread. |
148 virtual bool NPAPIPluginsSupported() = 0; | 144 virtual bool NPAPIPluginsSupported() = 0; |
149 | 145 |
150 // This is equivalent to specifying kDisablePluginsDiscovery, but is useful | 146 // This is equivalent to specifying kDisablePluginsDiscovery, but is useful |
151 // for unittests. | 147 // for unittests. |
152 virtual void DisablePluginsDiscoveryForTesting() = 0; | 148 virtual void DisablePluginsDiscoveryForTesting() = 0; |
153 | 149 |
154 #if defined(OS_MACOSX) | 150 #if defined(OS_MACOSX) |
155 // Called when the application is made active so that modal plugin windows can | 151 // Called when the application is made active so that modal plugin windows can |
156 // be made forward too. | 152 // be made forward too. |
157 virtual void AppActivated() = 0; | 153 virtual void AppActivated() = 0; |
158 #elif defined(OS_WIN) | 154 #elif defined(OS_WIN) |
159 // Returns the name and version of a plugin HWND. If the HWND isn't a valid | 155 // Returns the name and version of a plugin HWND. If the HWND isn't a valid |
160 // plugin, returns false. | 156 // plugin, returns false. |
161 // This can be called from any thread. | 157 // This can be called from any thread. |
162 virtual bool GetPluginInfoFromWindow(HWND window, | 158 virtual bool GetPluginInfoFromWindow(HWND window, |
163 base::string16* plugin_name, | 159 base::string16* plugin_name, |
164 base::string16* plugin_version) = 0; | 160 base::string16* plugin_version) = 0; |
165 #endif | 161 #endif |
166 }; | 162 }; |
167 | 163 |
168 } // namespace content | 164 } // namespace content |
169 | 165 |
170 #endif // CONTENT_PUBLIC_BROWSER_PLUGIN_SERVICE_H_ | 166 #endif // CONTENT_PUBLIC_BROWSER_PLUGIN_SERVICE_H_ |
OLD | NEW |