| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // This class responds to requests from renderers for the list of plugins, and | 5 // This class responds to requests from renderers for the list of plugins, and |
| 6 // also a proxy object for plugin instances. | 6 // also a proxy object for plugin instances. |
| 7 | 7 |
| 8 #ifndef CONTENT_BROWSER_PLUGIN_SERVICE_H_ | 8 #ifndef CONTENT_BROWSER_PLUGIN_SERVICE_H_ |
| 9 #define CONTENT_BROWSER_PLUGIN_SERVICE_H_ | 9 #define CONTENT_BROWSER_PLUGIN_SERVICE_H_ |
| 10 #pragma once | 10 #pragma once |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 class ResourceContext; | 47 class ResourceContext; |
| 48 struct PepperPluginInfo; | 48 struct PepperPluginInfo; |
| 49 class PluginServiceFilter; | 49 class PluginServiceFilter; |
| 50 struct PluginServiceFilterParams; | 50 struct PluginServiceFilterParams; |
| 51 } | 51 } |
| 52 | 52 |
| 53 namespace webkit { | 53 namespace webkit { |
| 54 namespace npapi { | 54 namespace npapi { |
| 55 class PluginGroup; | 55 class PluginGroup; |
| 56 class PluginList; | 56 class PluginList; |
| 57 struct PluginEntryPoints; |
| 57 } | 58 } |
| 58 } | 59 } |
| 59 | 60 |
| 60 // This must be created on the main thread but it's only called on the IO/file | 61 // This must be created on the main thread but it's only called on the IO/file |
| 61 // thread. This is an asynchronous wrapper around the PluginList interface for | 62 // thread. This is an asynchronous wrapper around the PluginList interface for |
| 62 // querying plugin information. This must be used instead of that to avoid | 63 // querying plugin information. This must be used instead of that to avoid |
| 63 // doing expensive disk operations on the IO/UI threads. | 64 // doing expensive disk operations on the IO/UI threads. |
| 64 class CONTENT_EXPORT PluginService | 65 class CONTENT_EXPORT PluginService |
| 65 : public base::WaitableEventWatcher::Delegate, | 66 : public base::WaitableEventWatcher::Delegate, |
| 66 public content::NotificationObserver { | 67 public content::NotificationObserver { |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 bool* is_stale, | 145 bool* is_stale, |
| 145 webkit::WebPluginInfo* info, | 146 webkit::WebPluginInfo* info, |
| 146 std::string* actual_mime_type); | 147 std::string* actual_mime_type); |
| 147 | 148 |
| 148 // Get plugin info by plugin path (including disabled plugins). Returns true | 149 // Get plugin info by plugin path (including disabled plugins). Returns true |
| 149 // if the plugin is found and WebPluginInfo has been filled in |info|. This | 150 // if the plugin is found and WebPluginInfo has been filled in |info|. This |
| 150 // will use cached data in the plugin list. | 151 // will use cached data in the plugin list. |
| 151 bool GetPluginInfoByPath(const FilePath& plugin_path, | 152 bool GetPluginInfoByPath(const FilePath& plugin_path, |
| 152 webkit::WebPluginInfo* info); | 153 webkit::WebPluginInfo* info); |
| 153 | 154 |
| 154 // Marks the plugin list as dirty and will cause the plugins to be reloaded | |
| 155 // on the next access through GetPlugins() or GetPluginGroups(). | |
| 156 void RefreshPluginList(); | |
| 157 | |
| 158 // Asynchronously loads plugins if necessary and then calls back to the | 155 // Asynchronously loads plugins if necessary and then calls back to the |
| 159 // provided function on the calling MessageLoop on completion. | 156 // provided function on the calling MessageLoop on completion. |
| 160 void GetPlugins(const GetPluginsCallback& callback); | 157 void GetPlugins(const GetPluginsCallback& callback); |
| 161 | 158 |
| 162 // Asynchronously loads the list of plugin groups if necessary and then calls | 159 // Asynchronously loads the list of plugin groups if necessary and then calls |
| 163 // back to the provided function on the calling MessageLoop on completion. | 160 // back to the provided function on the calling MessageLoop on completion. |
| 164 void GetPluginGroups(const GetPluginGroupsCallback& callback); | 161 void GetPluginGroups(const GetPluginGroupsCallback& callback); |
| 165 | 162 |
| 166 // Tells all the renderer processes associated with the given browser context | 163 // Tells all the renderer processes associated with the given browser context |
| 167 // to throw away their cache of the plugin list, and optionally also reload | 164 // to throw away their cache of the plugin list, and optionally also reload |
| 168 // all the pages with plugins. If |browser_context| is NULL, purges the cache | 165 // all the pages with plugins. If |browser_context| is NULL, purges the cache |
| 169 // in all renderers. | 166 // in all renderers. |
| 170 // NOTE: can only be called on the UI thread. | 167 // NOTE: can only be called on the UI thread. |
| 171 static void PurgePluginListCache(content::BrowserContext* browser_context, | 168 static void PurgePluginListCache(content::BrowserContext* browser_context, |
| 172 bool reload_pages); | 169 bool reload_pages); |
| 173 | 170 |
| 174 void set_filter(content::PluginServiceFilter* filter) { | 171 void set_filter(content::PluginServiceFilter* filter) { |
| 175 filter_ = filter; | 172 filter_ = filter; |
| 176 } | 173 } |
| 177 content::PluginServiceFilter* filter() { return filter_; } | 174 content::PluginServiceFilter* filter() { return filter_; } |
| 178 | 175 |
| 176 |
| 177 // The following functions are wrappers around webkit::npapi::PluginList. |
| 178 // These must be used instead of those in order to ensure that we have a |
| 179 // single global list in the component build and so that we don't |
| 180 // accidentally load plugins in the wrong process or thread. Refer to |
| 181 // PluginList for further documentation of these functions. |
| 182 void RefreshPlugins(); |
| 183 void AddExtraPluginPath(const FilePath& path); |
| 184 void RemoveExtraPluginPath(const FilePath& path); |
| 185 void UnregisterInternalPlugin(const FilePath& path); |
| 186 void RegisterInternalPlugin(const webkit::WebPluginInfo& info); |
| 187 string16 GetPluginGroupName(const std::string& plugin_name); |
| 188 |
| 189 // TODO(dpranke): This should be private. |
| 190 webkit::npapi::PluginList* plugin_list(); |
| 191 |
| 179 private: | 192 private: |
| 180 friend struct DefaultSingletonTraits<PluginService>; | 193 friend struct DefaultSingletonTraits<PluginService>; |
| 181 | 194 |
| 182 // Creates the PluginService object, but doesn't actually build the plugin | 195 // Creates the PluginService object, but doesn't actually build the plugin |
| 183 // list yet. It's generated lazily. | 196 // list yet. It's generated lazily. |
| 184 PluginService(); | 197 PluginService(); |
| 185 virtual ~PluginService(); | 198 virtual ~PluginService(); |
| 186 | 199 |
| 187 // base::WaitableEventWatcher::Delegate implementation. | 200 // base::WaitableEventWatcher::Delegate implementation. |
| 188 virtual void OnWaitableEventSignaled(base::WaitableEvent* waitable_event); | 201 virtual void OnWaitableEventSignaled(base::WaitableEvent* waitable_event); |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 #if defined(OS_POSIX) | 275 #if defined(OS_POSIX) |
| 263 scoped_refptr<PluginLoaderPosix> plugin_loader_; | 276 scoped_refptr<PluginLoaderPosix> plugin_loader_; |
| 264 #endif | 277 #endif |
| 265 | 278 |
| 266 DISALLOW_COPY_AND_ASSIGN(PluginService); | 279 DISALLOW_COPY_AND_ASSIGN(PluginService); |
| 267 }; | 280 }; |
| 268 | 281 |
| 269 DISABLE_RUNNABLE_METHOD_REFCOUNT(PluginService); | 282 DISABLE_RUNNABLE_METHOD_REFCOUNT(PluginService); |
| 270 | 283 |
| 271 #endif // CONTENT_BROWSER_PLUGIN_SERVICE_H_ | 284 #endif // CONTENT_BROWSER_PLUGIN_SERVICE_H_ |
| OLD | NEW |