Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(737)

Unified Diff: content/browser/plugin_service.cc

Issue 7980011: Convert the PluginService interface to be an async wrapper around PluginList. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: New interface as discussed Created 9 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/browser/plugin_service.cc
diff --git a/content/browser/plugin_service.cc b/content/browser/plugin_service.cc
index 0a6007cca5605a32918307d332004e418edaef85..838a6e87add5e65a2f35f6e7c8a79ab481266d72 100644
--- a/content/browser/plugin_service.cc
+++ b/content/browser/plugin_service.cc
@@ -4,9 +4,12 @@
#include "content/browser/plugin_service.h"
+#include "base/bind.h"
#include "base/command_line.h"
#include "base/compiler_specific.h"
#include "base/file_path.h"
+#include "base/message_loop.h"
+#include "base/message_loop_proxy.h"
#include "base/path_service.h"
#include "base/string_util.h"
#include "base/synchronization/waitable_event.h"
@@ -27,6 +30,7 @@
#include "content/common/plugin_messages.h"
#include "content/common/view_messages.h"
#include "webkit/plugins/npapi/plugin_constants_win.h"
+#include "webkit/plugins/npapi/plugin_group.h"
#include "webkit/plugins/npapi/plugin_list.h"
#include "webkit/plugins/webplugininfo.h"
@@ -417,29 +421,35 @@ bool PluginService::GetPluginInfo(int render_process_id,
return false;
}
-void PluginService::GetPlugins(
- const content::ResourceContext& context,
- std::vector<webkit::WebPluginInfo>* plugins) {
- // GetPlugins may need to load the plugins, so we need to be
- // on the FILE thread.
+void PluginService::LoadPluginList(
+ bool refresh,
+ const base::Closure& completion_callback) {
+ if (refresh)
+ webkit::npapi::PluginList::Singleton()->RefreshPlugins();
+ BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE,
+ base::Bind(&PluginService::GetPluginsInternal, base::Unretained(this),
+ MessageLoop::current()->message_loop_proxy(),
+ completion_callback));
+}
+
+void PluginService::GetPlugins(std::vector<webkit::WebPluginInfo>* plugins) {
+ webkit::npapi::PluginList::Singleton()->GetCachedPlugins(plugins);
+}
+
+void PluginService::GetPluginGroups(
+ std::vector<webkit::npapi::PluginGroup>* groups) {
+ webkit::npapi::PluginList::Singleton()->GetPluginGroups(false, groups);
+}
+
+void PluginService::GetPluginsInternal(
+ base::MessageLoopProxy* target_loop,
+ const base::Closure& completion_callback) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
- webkit::npapi::PluginList* plugin_list =
- webkit::npapi::PluginList::Singleton();
- std::vector<webkit::WebPluginInfo> all_plugins;
- plugin_list->GetPlugins(&all_plugins);
-
- int child_process_id = -1;
- int routing_id = MSG_ROUTING_NONE;
- for (size_t i = 0; i < all_plugins.size(); ++i) {
- if (!filter_ || filter_->ShouldUsePlugin(child_process_id,
- routing_id,
- &context,
- GURL(),
- GURL(),
- &all_plugins[i])) {
- plugins->push_back(all_plugins[i]);
- }
- }
+
+ std::vector<webkit::WebPluginInfo> plugins;
+ webkit::npapi::PluginList::Singleton()->GetPlugins(&plugins);
Bernhard Bauer 2011/09/21 22:47:05 Would it be bad to make PluginList::LoadPlugins()
+
+ target_loop->PostTask(FROM_HERE, completion_callback);
}
void PluginService::OnWaitableEventSignaled(

Powered by Google App Engine
This is Rietveld 408576698