Index: content/browser/plugin_service.h |
diff --git a/content/browser/plugin_service.h b/content/browser/plugin_service.h |
index 2d2596e3d4e5e6173e28b55db512258c8f6c9615..94c1e6e9d905abe49f4d631546c25171417104f0 100644 |
--- a/content/browser/plugin_service.h |
+++ b/content/browser/plugin_service.h |
@@ -13,6 +13,7 @@ |
#include <vector> |
#include "base/basictypes.h" |
+#include "base/callback.h" |
#include "base/memory/scoped_vector.h" |
#include "base/memory/singleton.h" |
#include "base/synchronization/waitable_event_watcher.h" |
@@ -25,7 +26,6 @@ |
#include "content/common/notification_registrar.h" |
#include "googleurl/src/gurl.h" |
#include "ipc/ipc_channel_handle.h" |
-#include "webkit/plugins/webplugininfo.h" |
#if defined(OS_WIN) |
#include "base/memory/scoped_ptr.h" |
@@ -39,13 +39,27 @@ |
struct PepperPluginInfo; |
class PluginDirWatcherDelegate; |
+namespace base { |
+class MessageLoopProxy; |
+} |
+ |
namespace content { |
class ResourceContext; |
class PluginServiceFilter; |
} |
+namespace webkit { |
+namespace npapi { |
+class MockPluginList; |
+class PluginGroup; |
+class PluginList; |
+} |
+} |
+ |
// This must be created on the main thread but it's only called on the IO/file |
-// thread. |
+// thread. This is an asynchronous wrapper around the PluginList interface for |
+// querying plugin information, and this should instead of that class in the |
+// content layer and above. |
class CONTENT_EXPORT PluginService |
: public base::WaitableEventWatcher::Delegate, |
public NotificationObserver { |
@@ -57,6 +71,11 @@ class CONTENT_EXPORT PluginService |
webkit::WebPluginInfo plugin; |
}; |
+ typedef base::Callback<void(const std::vector<webkit::WebPluginInfo>&)> |
+ GetPluginsCallback; |
+ typedef base::Callback<void(const std::vector<webkit::npapi::PluginGroup>&)> |
+ GetPluginGroupsCallback; |
+ |
// Returns the PluginService singleton. |
static PluginService* GetInstance(); |
@@ -115,10 +134,24 @@ class CONTENT_EXPORT PluginService |
webkit::WebPluginInfo* info, |
std::string* actual_mime_type); |
- // Returns a list of all plug-ins available to the resource context. Must be |
- // called on the FILE thread. |
+ // Marks the plugin list as dirty and will cause the plugins to be reloaded |
+ // on the next access through GetPlugins() or GetPluginGroups(). |
+ void RefreshPluginList(); |
+ |
+ // Asynchronously loads plugins and then calls back to the provided function |
+ // on the calling MessageLoop on completion. |
void GetPlugins(const content::ResourceContext& context, |
- std::vector<webkit::WebPluginInfo>* plugins); |
+ const GetPluginsCallback& callback); |
+ // Variant of above, but does not perform filtering based on |context|. |
+ void GetPlugins(const GetPluginsCallback& callback); |
+ |
+ // Returns the list of cached plugin groups. This can be called from any |
+ // thread, but note that the data can be stale. |
+ void GetCachedPluginGroups(std::vector<webkit::npapi::PluginGroup>* groups); |
+ |
+ // Gets the list of plugin groups, reloading them from disk if marked as dirty |
+ // with RefreshPluginList(). |
+ void GetPluginGroups(const GetPluginGroupsCallback& callback); |
// Tells all the renderer processes to throw away their cache of the plugin |
// list, and optionally also reload all the pages with plugins. |
@@ -129,6 +162,10 @@ class CONTENT_EXPORT PluginService |
filter_ = filter; |
} |
+ // Sets the PluginList for testing environments. Be sure to change back to |
+ // NULL at the end of the test! |
+ void SetPluginListForTesting(webkit::npapi::MockPluginList* plugin_list); |
+ |
private: |
friend struct DefaultSingletonTraits<PluginService>; |
@@ -137,6 +174,9 @@ class CONTENT_EXPORT PluginService |
PluginService(); |
virtual ~PluginService(); |
+ // Returns the PluginList, either the singleton or the override. |
+ webkit::npapi::PluginList* GetPluginList(); |
+ |
// base::WaitableEventWatcher::Delegate implementation. |
virtual void OnWaitableEventSignaled(base::WaitableEvent* waitable_event); |
@@ -148,6 +188,11 @@ class CONTENT_EXPORT PluginService |
PepperPluginInfo* GetRegisteredPpapiPluginInfo(const FilePath& plugin_path); |
+ // Function that is run on the FILE thread to load the plugins synchronously. |
+ void GetPluginsInternal(const content::ResourceContext* context, |
+ base::MessageLoopProxy* target_loop, |
+ const GetPluginsCallback& callback); |
+ |
// Helper so we can do the plugin lookup on the FILE thread. |
void GetAllowedPluginForOpenChannelToPlugin( |
int render_process_id, |
@@ -199,6 +244,10 @@ class CONTENT_EXPORT PluginService |
std::set<PluginProcessHost::Client*> pending_plugin_clients_; |
+ // Alternate plugin list to use for testing environments. When NULL, defaults |
+ // to the singleton. |
+ webkit::npapi::PluginList* plugin_list_; |
+ |
DISALLOW_COPY_AND_ASSIGN(PluginService); |
}; |