| 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/string16.h" | 12 #include "base/string16.h" |
| 13 #include "content/common/content_export.h" | 13 #include "content/common/content_export.h" |
| 14 | 14 |
| 15 class FilePath; | 15 class FilePath; |
| 16 class GURL; | 16 class GURL; |
| 17 class PluginProcessHost; | 17 class PluginProcessHost; |
| 18 | 18 |
| 19 namespace webkit { | 19 namespace webkit { |
| 20 struct WebPluginInfo; | 20 struct WebPluginInfo; |
| 21 namespace npapi { | 21 namespace npapi { |
| 22 class PluginGroup; | |
| 23 class PluginList; | 22 class PluginList; |
| 24 } | 23 } |
| 25 } | 24 } |
| 26 | 25 |
| 27 namespace content { | 26 namespace content { |
| 28 | 27 |
| 29 class BrowserContext; | 28 class BrowserContext; |
| 30 class PluginServiceFilter; | 29 class PluginServiceFilter; |
| 31 class ResourceContext; | 30 class ResourceContext; |
| 32 struct PepperPluginInfo; | 31 struct PepperPluginInfo; |
| 33 | 32 |
| 34 // This must be created on the main thread but it's only called on the IO/file | 33 // This must be created on the main thread but it's only called on the IO/file |
| 35 // thread. This is an asynchronous wrapper around the PluginList interface for | 34 // thread. This is an asynchronous wrapper around the PluginList interface for |
| 36 // querying plugin information. This must be used instead of that to avoid | 35 // querying plugin information. This must be used instead of that to avoid |
| 37 // doing expensive disk operations on the IO/UI threads. | 36 // doing expensive disk operations on the IO/UI threads. |
| 38 class PluginService { | 37 class PluginService { |
| 39 public: | 38 public: |
| 40 typedef base::Callback<void(const std::vector<webkit::WebPluginInfo>&)> | 39 typedef base::Callback<void(const std::vector<webkit::WebPluginInfo>&)> |
| 41 GetPluginsCallback; | 40 GetPluginsCallback; |
| 42 typedef base::Callback<void(const std::vector<webkit::npapi::PluginGroup>&)> | |
| 43 GetPluginGroupsCallback; | |
| 44 | 41 |
| 45 // Returns the PluginService singleton. | 42 // Returns the PluginService singleton. |
| 46 CONTENT_EXPORT static PluginService* GetInstance(); | 43 CONTENT_EXPORT static PluginService* GetInstance(); |
| 47 | 44 |
| 48 // Tells all the renderer processes associated with the given browser context | 45 // Tells all the renderer processes associated with the given browser context |
| 49 // to throw away their cache of the plugin list, and optionally also reload | 46 // to throw away their cache of the plugin list, and optionally also reload |
| 50 // all the pages with plugins. If |browser_context| is NULL, purges the cache | 47 // all the pages with plugins. If |browser_context| is NULL, purges the cache |
| 51 // in all renderers. | 48 // in all renderers. |
| 52 // NOTE: can only be called on the UI thread. | 49 // NOTE: can only be called on the UI thread. |
| 53 CONTENT_EXPORT static void PurgePluginListCache( | 50 CONTENT_EXPORT static void PurgePluginListCache( |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 | 91 |
| 95 // Returns the display name for the plugin identified by the given path. If | 92 // Returns the display name for the plugin identified by the given path. If |
| 96 // the path doesn't identify a plugin, or the plugin has no display name, | 93 // the path doesn't identify a plugin, or the plugin has no display name, |
| 97 // this will attempt to generate a display name from the path. | 94 // this will attempt to generate a display name from the path. |
| 98 virtual string16 GetPluginDisplayNameByPath(const FilePath& plugin_path) = 0; | 95 virtual string16 GetPluginDisplayNameByPath(const FilePath& plugin_path) = 0; |
| 99 | 96 |
| 100 // Asynchronously loads plugins if necessary and then calls back to the | 97 // Asynchronously loads plugins if necessary and then calls back to the |
| 101 // provided function on the calling MessageLoop on completion. | 98 // provided function on the calling MessageLoop on completion. |
| 102 virtual void GetPlugins(const GetPluginsCallback& callback) = 0; | 99 virtual void GetPlugins(const GetPluginsCallback& callback) = 0; |
| 103 | 100 |
| 104 // Asynchronously loads the list of plugin groups if necessary and then calls | |
| 105 // back to the provided function on the calling MessageLoop on completion. | |
| 106 virtual void GetPluginGroups(const GetPluginGroupsCallback& callback) = 0; | |
| 107 | |
| 108 // Returns information about a pepper plugin if it exists, otherwise NULL. | 101 // Returns information about a pepper plugin if it exists, otherwise NULL. |
| 109 // The caller does not own the pointer, and it's not guaranteed to live past | 102 // The caller does not own the pointer, and it's not guaranteed to live past |
| 110 // the call stack. | 103 // the call stack. |
| 111 virtual PepperPluginInfo* GetRegisteredPpapiPluginInfo( | 104 virtual PepperPluginInfo* GetRegisteredPpapiPluginInfo( |
| 112 const FilePath& plugin_path) = 0; | 105 const FilePath& plugin_path) = 0; |
| 113 | 106 |
| 114 virtual void SetFilter(PluginServiceFilter* filter) = 0; | 107 virtual void SetFilter(PluginServiceFilter* filter) = 0; |
| 115 virtual PluginServiceFilter* GetFilter() = 0; | 108 virtual PluginServiceFilter* GetFilter() = 0; |
| 116 | 109 |
| 117 // If the plugin with the given path is running, cleanly shuts it down. | 110 // If the plugin with the given path is running, cleanly shuts it down. |
| 118 virtual void ForcePluginShutdown(const FilePath& plugin_path) = 0; | 111 virtual void ForcePluginShutdown(const FilePath& plugin_path) = 0; |
| 119 | 112 |
| 120 // Used to monitor plug-in stability. An unstable plug-in is one that has | 113 // Used to monitor plug-in stability. An unstable plug-in is one that has |
| 121 // crashed more than a set number of times in a set time period. | 114 // crashed more than a set number of times in a set time period. |
| 122 virtual bool IsPluginUnstable(const FilePath& plugin_path) = 0; | 115 virtual bool IsPluginUnstable(const FilePath& plugin_path) = 0; |
| 123 | 116 |
| 124 // The following functions are wrappers around webkit::npapi::PluginList. | 117 // The following functions are wrappers around webkit::npapi::PluginList. |
| 125 // These must be used instead of those in order to ensure that we have a | 118 // These must be used instead of those in order to ensure that we have a |
| 126 // single global list in the component build and so that we don't | 119 // single global list in the component build and so that we don't |
| 127 // accidentally load plugins in the wrong process or thread. Refer to | 120 // accidentally load plugins in the wrong process or thread. Refer to |
| 128 // PluginList for further documentation of these functions. | 121 // PluginList for further documentation of these functions. |
| 129 virtual void RefreshPlugins() = 0; | 122 virtual void RefreshPlugins() = 0; |
| 130 virtual void AddExtraPluginPath(const FilePath& path) = 0; | 123 virtual void AddExtraPluginPath(const FilePath& path) = 0; |
| 131 virtual void AddExtraPluginDir(const FilePath& path) = 0; | 124 virtual void AddExtraPluginDir(const FilePath& path) = 0; |
| 132 virtual void RemoveExtraPluginPath(const FilePath& path) = 0; | 125 virtual void RemoveExtraPluginPath(const FilePath& path) = 0; |
| 133 virtual void UnregisterInternalPlugin(const FilePath& path) = 0; | 126 virtual void UnregisterInternalPlugin(const FilePath& path) = 0; |
| 134 virtual void RegisterInternalPlugin(const webkit::WebPluginInfo& info, | 127 virtual void RegisterInternalPlugin(const webkit::WebPluginInfo& info, |
| 135 bool add_at_beginning) = 0; | 128 bool add_at_beginning) = 0; |
| 136 virtual string16 GetPluginGroupName(const std::string& plugin_name) = 0; | |
| 137 | 129 |
| 138 // TODO(dpranke): This should be private. | 130 // TODO(dpranke): This should be private. |
| 139 virtual webkit::npapi::PluginList* GetPluginList() = 0; | 131 virtual webkit::npapi::PluginList* GetPluginList() = 0; |
| 140 | 132 |
| 141 virtual void SetPluginListForTesting( | 133 virtual void SetPluginListForTesting( |
| 142 webkit::npapi::PluginList* plugin_list) = 0; | 134 webkit::npapi::PluginList* plugin_list) = 0; |
| 143 | 135 |
| 144 #if defined(OS_MACOSX) | 136 #if defined(OS_MACOSX) |
| 145 // Called when the application is made active so that modal plugin windows can | 137 // Called when the application is made active so that modal plugin windows can |
| 146 // be made forward too. | 138 // be made forward too. |
| 147 virtual void AppActivated() = 0; | 139 virtual void AppActivated() = 0; |
| 148 #endif | 140 #endif |
| 149 }; | 141 }; |
| 150 | 142 |
| 151 } // namespace content | 143 } // namespace content |
| 152 | 144 |
| 153 #endif // CONTENT_PUBLIC_BROWSER_PLUGIN_SERVICE_H_ | 145 #endif // CONTENT_PUBLIC_BROWSER_PLUGIN_SERVICE_H_ |
| OLD | NEW |