summaryrefslogtreecommitdiffstats
path: root/chrome/browser/plugin_service.cc
diff options
context:
space:
mode:
authorgspencer@chromium.org <gspencer@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-14 23:59:26 +0000
committergspencer@chromium.org <gspencer@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-14 23:59:26 +0000
commit6fdd418b9a50f24f7788e229bd3ae4acaf6ec1d4 (patch)
treed55a82a8551a7df61d6c84f13835e7b8e17507f3 /chrome/browser/plugin_service.cc
parent6f7582fd31ff06faa0298ab6d530369256e9f20a (diff)
downloadchromium_src-6fdd418b9a50f24f7788e229bd3ae4acaf6ec1d4.zip
chromium_src-6fdd418b9a50f24f7788e229bd3ae4acaf6ec1d4.tar.gz
chromium_src-6fdd418b9a50f24f7788e229bd3ae4acaf6ec1d4.tar.bz2
This adds a plugin selection policy for selecting which plugin is
allowed for a particular domain. It is only used on ChromeOS. It reads from a file that is installed in a known location on ChromeOS, and uses that as it's policy. When there are multiple plugins supporting the same mime-type, the appropriate plugin file to load is now selected based on policy. BUG=http://crosbug.com/7403 TEST=ran new unit test, tested on device. Review URL: http://codereview.chromium.org/3717005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@62679 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/plugin_service.cc')
-rw-r--r--chrome/browser/plugin_service.cc80
1 files changed, 73 insertions, 7 deletions
diff --git a/chrome/browser/plugin_service.cc b/chrome/browser/plugin_service.cc
index ebf4338..5f86020 100644
--- a/chrome/browser/plugin_service.cc
+++ b/chrome/browser/plugin_service.cc
@@ -40,6 +40,11 @@
#endif
#include "webkit/glue/plugins/plugin_constants_win.h"
#include "webkit/glue/plugins/plugin_list.h"
+#include "webkit/glue/plugins/webplugininfo.h"
+
+#if defined(OS_CHROMEOS)
+#include "chrome/browser/chromeos/plugin_selection_policy.h"
+#endif
#if defined(OS_MACOSX)
static void NotifyPluginsOfActivation() {
@@ -123,6 +128,11 @@ PluginService::PluginService()
}
#endif
+#if defined(OS_CHROMEOS)
+ plugin_selection_policy_ = new chromeos::PluginSelectionPolicy;
+ plugin_selection_policy_->StartInit();
+#endif
+
chrome::RegisterInternalGPUPlugin();
#if defined(OS_WIN)
@@ -243,17 +253,42 @@ void PluginService::OpenChannelToPlugin(
ResourceMessageFilter* renderer_msg_filter,
const GURL& url,
const std::string& mime_type,
- const std::string& locale,
IPC::Message* reply_msg) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
+ // The PluginList::GetFirstAllowedPluginInfo may need to load the
+ // plugins. Don't do it on the IO thread.
+ BrowserThread::PostTask(
+ BrowserThread::FILE, FROM_HERE,
+ NewRunnableMethod(
+ this, &PluginService::GetAllowedPluginForOpenChannelToPlugin,
+ renderer_msg_filter, url, mime_type, reply_msg));
+}
- bool allow_wildcard = true;
+void PluginService::GetAllowedPluginForOpenChannelToPlugin(
+ ResourceMessageFilter* renderer_msg_filter,
+ const GURL& url,
+ const std::string& mime_type,
+ IPC::Message* reply_msg) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
WebPluginInfo info;
+ bool found = GetFirstAllowedPluginInfo(url, mime_type, &info, NULL);
FilePath plugin_path;
- if (NPAPI::PluginList::Singleton()->GetPluginInfo(
- url, mime_type, allow_wildcard, &info, NULL) && info.enabled) {
- plugin_path = info.path;
- }
+ if (found && info.enabled)
+ plugin_path = FilePath(info.path);
+
+ // Now we jump back to the IO thread to finish opening the channel.
+ BrowserThread::PostTask(
+ BrowserThread::IO, FROM_HERE,
+ NewRunnableMethod(
+ this, &PluginService::FinishOpenChannelToPlugin,
+ renderer_msg_filter, mime_type, plugin_path, reply_msg));
+}
+
+void PluginService::FinishOpenChannelToPlugin(
+ ResourceMessageFilter* renderer_msg_filter,
+ const std::string& mime_type,
+ const FilePath& plugin_path,
+ IPC::Message* reply_msg) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
PluginProcessHost* plugin_host = FindOrStartPluginProcess(plugin_path);
if (plugin_host) {
@@ -264,6 +299,37 @@ void PluginService::OpenChannelToPlugin(
}
}
+bool PluginService::GetFirstAllowedPluginInfo(
+ const GURL& url,
+ const std::string& mime_type,
+ WebPluginInfo* info,
+ std::string* actual_mime_type) {
+ // GetPluginInfoArray may need to load the plugins, so we need to be
+ // on the FILE thread.
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
+ bool allow_wildcard = true;
+#if defined(OS_CHROMEOS)
+ std::vector<WebPluginInfo> info_array;
+ std::vector<std::string> actual_mime_types;
+ NPAPI::PluginList::Singleton()->GetPluginInfoArray(
+ url, mime_type, allow_wildcard, &info_array, &actual_mime_types);
+
+ // Now we filter by the plugin selection policy.
+ int allowed_index = plugin_selection_policy_->FindFirstAllowed(url,
+ info_array);
+ if (!info_array.empty() && allowed_index >= 0) {
+ *info = info_array[allowed_index];
+ if (actual_mime_type)
+ *actual_mime_type = actual_mime_types[allowed_index];
+ return true;
+ }
+ return false;
+#else
+ return NPAPI::PluginList::Singleton()->GetPluginInfo(
+ url, mime_type, allow_wildcard, info, actual_mime_type);
+#endif
+}
+
static void PurgePluginListCache(bool reload_pages) {
for (RenderProcessHost::iterator it = RenderProcessHost::AllHostsIterator();
!it.IsAtEnd(); it.Advance()) {