summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/plugin_service.cc30
-rw-r--r--chrome/browser/plugin_service.h14
-rw-r--r--chrome/browser/renderer_host/resource_message_filter.cc21
-rw-r--r--chrome/browser/renderer_host/resource_message_filter.h5
-rw-r--r--chrome/common/render_messages.h6
-rw-r--r--chrome/common/render_messages_internal.h11
-rw-r--r--chrome/renderer/blocked_plugin.cc4
-rw-r--r--chrome/renderer/render_view.cc51
-rw-r--r--chrome/renderer/render_view.h4
9 files changed, 77 insertions, 69 deletions
diff --git a/chrome/browser/plugin_service.cc b/chrome/browser/plugin_service.cc
index 1b36382..197a3ff 100644
--- a/chrome/browser/plugin_service.cc
+++ b/chrome/browser/plugin_service.cc
@@ -228,10 +228,13 @@ void PluginService::OpenChannelToPlugin(
const std::wstring& locale,
IPC::Message* reply_msg) {
DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO));
- // We don't need a policy URL here because that was already checked by a
- // previous call to GetPluginPath.
- GURL policy_url;
- FilePath plugin_path = GetPluginPath(url, policy_url, mime_type, NULL);
+ bool allow_wildcard = true;
+ WebPluginInfo info;
+ FilePath plugin_path;
+ if (NPAPI::PluginList::Singleton()->GetPluginInfo(
+ url, mime_type, allow_wildcard, &info, NULL) && info.enabled) {
+ plugin_path = info.path;
+ }
PluginProcessHost* plugin_host = FindOrStartPluginProcess(plugin_path);
if (plugin_host) {
plugin_host->OpenChannelToPlugin(renderer_msg_filter, mime_type, reply_msg);
@@ -241,21 +244,6 @@ void PluginService::OpenChannelToPlugin(
}
}
-FilePath PluginService::GetPluginPath(const GURL& url,
- const GURL& policy_url,
- const std::string& mime_type,
- std::string* actual_mime_type) {
- bool allow_wildcard = true;
- WebPluginInfo info;
- if (NPAPI::PluginList::Singleton()->GetPluginInfo(
- url, mime_type, allow_wildcard, &info, actual_mime_type) &&
- info.enabled && PluginAllowedForURL(info.path, policy_url)) {
- return info.path;
- }
-
- return FilePath();
-}
-
static void PurgePluginListCache(bool reload_pages) {
for (RenderProcessHost::iterator it = RenderProcessHost::AllHostsIterator();
!it.IsAtEnd(); it.Advance()) {
@@ -336,8 +324,8 @@ void PluginService::Observe(NotificationType type,
}
}
-bool PluginService::PluginAllowedForURL(const FilePath& plugin_path,
- const GURL& url) {
+bool PluginService::PrivatePluginAllowedForURL(const FilePath& plugin_path,
+ const GURL& url) {
if (url.is_empty())
return true; // Caller wants all plugins.
diff --git a/chrome/browser/plugin_service.h b/chrome/browser/plugin_service.h
index 9745973..63513bd 100644
--- a/chrome/browser/plugin_service.h
+++ b/chrome/browser/plugin_service.h
@@ -83,13 +83,9 @@ class PluginService
const std::wstring& locale,
IPC::Message* reply_msg);
- // Get the path to the plugin specified. policy_url is the URL of the page
- // requesting the plugin, so we can verify whether the plugin is allowed
- // on that page.
- FilePath GetPluginPath(const GURL& url,
- const GURL& policy_url,
- const std::string& mime_type,
- std::string* actual_mime_type);
+ // Returns true if the given plugin is allowed to be used by a page with
+ // the given URL.
+ bool PrivatePluginAllowedForURL(const FilePath& plugin_path, const GURL& url);
// The UI thread's message loop
MessageLoop* main_message_loop() { return main_message_loop_; }
@@ -115,10 +111,6 @@ class PluginService
virtual void Observe(NotificationType type, const NotificationSource& source,
const NotificationDetails& details);
- // Returns true if the given plugin is allowed to be used by a page with
- // the given URL.
- bool PluginAllowedForURL(const FilePath& plugin_path, const GURL& url);
-
void RegisterPepperPlugins();
// mapping between plugin path and PluginProcessHost
diff --git a/chrome/browser/renderer_host/resource_message_filter.cc b/chrome/browser/renderer_host/resource_message_filter.cc
index db19895..3d60d80 100644
--- a/chrome/browser/renderer_host/resource_message_filter.cc
+++ b/chrome/browser/renderer_host/resource_message_filter.cc
@@ -366,7 +366,7 @@ bool ResourceMessageFilter::OnMessageReceived(const IPC::Message& msg) {
IPC_MESSAGE_HANDLER(ViewHostMsg_PreCacheFont, OnPreCacheFont)
#endif
IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_GetPlugins, OnGetPlugins)
- IPC_MESSAGE_HANDLER(ViewHostMsg_GetPluginPath, OnGetPluginPath)
+ IPC_MESSAGE_HANDLER(ViewHostMsg_GetPluginInfo, OnGetPluginInfo)
IPC_MESSAGE_HANDLER(ViewHostMsg_DownloadUrl, OnDownloadUrl)
IPC_MESSAGE_HANDLER_GENERIC(ViewHostMsg_ContextMenu,
OnReceiveContextMenuMsg(msg))
@@ -692,13 +692,22 @@ void ResourceMessageFilter::OnGetPluginsOnFileThread(
NewRunnableMethod(this, &ResourceMessageFilter::Send, reply_msg));
}
-void ResourceMessageFilter::OnGetPluginPath(const GURL& url,
+void ResourceMessageFilter::OnGetPluginInfo(const GURL& url,
const GURL& policy_url,
const std::string& mime_type,
- FilePath* filename,
- std::string* url_mime_type) {
- *filename = plugin_service_->GetPluginPath(
- url, policy_url, mime_type, url_mime_type);
+ bool* found,
+ WebPluginInfo* info,
+ std::string* actual_mime_type) {
+ bool allow_wildcard = true;
+ *found = NPAPI::PluginList::Singleton()->GetPluginInfo(url,
+ mime_type,
+ allow_wildcard,
+ info,
+ actual_mime_type);
+ if (*found) {
+ info->enabled = info->enabled &&
+ plugin_service_->PrivatePluginAllowedForURL(info->path, policy_url);
+ }
}
void ResourceMessageFilter::OnOpenChannelToPlugin(const GURL& url,
diff --git a/chrome/browser/renderer_host/resource_message_filter.h b/chrome/browser/renderer_host/resource_message_filter.h
index 7acecaa..c112b77 100644
--- a/chrome/browser/renderer_host/resource_message_filter.h
+++ b/chrome/browser/renderer_host/resource_message_filter.h
@@ -170,10 +170,11 @@ class ResourceMessageFilter : public IPC::ChannelProxy::MessageFilter,
#endif
void OnGetPlugins(bool refresh, IPC::Message* reply_msg);
void OnGetPluginsOnFileThread(bool refresh, IPC::Message* reply_msg);
- void OnGetPluginPath(const GURL& url,
+ void OnGetPluginInfo(const GURL& url,
const GURL& policy_url,
const std::string& mime_type,
- FilePath* filename,
+ bool* found,
+ WebPluginInfo* info,
std::string* actual_mime_type);
void OnOpenChannelToPlugin(const GURL& url,
const std::string& mime_type,
diff --git a/chrome/common/render_messages.h b/chrome/common/render_messages.h
index acdd77e..02790e5 100644
--- a/chrome/common/render_messages.h
+++ b/chrome/common/render_messages.h
@@ -1307,6 +1307,7 @@ struct ParamTraits<WebPluginInfo> {
WriteParam(m, p.version);
WriteParam(m, p.desc);
WriteParam(m, p.mime_types);
+ WriteParam(m, p.enabled);
}
static bool Read(const Message* m, void** iter, param_type* r) {
return
@@ -1314,7 +1315,8 @@ struct ParamTraits<WebPluginInfo> {
ReadParam(m, iter, &r->path) &&
ReadParam(m, iter, &r->version) &&
ReadParam(m, iter, &r->desc) &&
- ReadParam(m, iter, &r->mime_types);
+ ReadParam(m, iter, &r->mime_types) &&
+ ReadParam(m, iter, &r->enabled);
}
static void Log(const param_type& p, std::wstring* l) {
l->append(L"(");
@@ -1328,6 +1330,8 @@ struct ParamTraits<WebPluginInfo> {
LogParam(p.desc, l);
l->append(L", ");
LogParam(p.mime_types, l);
+ l->append(L", ");
+ LogParam(p.enabled, l);
l->append(L")");
}
};
diff --git a/chrome/common/render_messages_internal.h b/chrome/common/render_messages_internal.h
index b8ddb28..6fd0c49 100644
--- a/chrome/common/render_messages_internal.h
+++ b/chrome/common/render_messages_internal.h
@@ -1242,14 +1242,15 @@ IPC_BEGIN_MESSAGES(ViewHost)
bool /* refresh*/,
std::vector<WebPluginInfo> /* plugins */)
- // Returns a path to a plugin for the given url and mime type. If there's
- // no plugin, an empty string is returned.
- IPC_SYNC_MESSAGE_CONTROL3_2(ViewHostMsg_GetPluginPath,
+ // Return information about a plugin for the given URL and MIME type. If there
+ // is no matching plugin, |found| is set to false.
+ IPC_SYNC_MESSAGE_CONTROL3_3(ViewHostMsg_GetPluginInfo,
GURL /* url */,
GURL /* policy_url */,
std::string /* mime_type */,
- FilePath /* filename */,
- std::string /* actual mime type for url */)
+ bool /* found */,
+ WebPluginInfo /* plugin info */,
+ std::string /* actual_mime_type */)
// Requests spellcheck for a word.
IPC_SYNC_MESSAGE_ROUTED2_2(ViewHostMsg_SpellCheck,
diff --git a/chrome/renderer/blocked_plugin.cc b/chrome/renderer/blocked_plugin.cc
index 4f981da..3e891b3 100644
--- a/chrome/renderer/blocked_plugin.cc
+++ b/chrome/renderer/blocked_plugin.cc
@@ -78,8 +78,8 @@ void BlockedPlugin::LoadPlugin() {
WebPlugin* new_plugin =
render_view_->CreatePluginInternal(frame_,
plugin_params_,
- std::string(),
- FilePath());
+ NULL,
+ std::string());
if (new_plugin && new_plugin->initialize(container)) {
container->setPlugin(new_plugin);
plugin_->ReplayReceivedData(new_plugin);
diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc
index 5bdf140..4efa8de 100644
--- a/chrome/renderer/render_view.cc
+++ b/chrome/renderer/render_view.cc
@@ -2199,23 +2199,30 @@ void RenderView::runModal() {
WebPlugin* RenderView::createPlugin(WebFrame* frame,
const WebPluginParams& params) {
- FilePath path;
+ bool found = false;
+ WebPluginInfo info;
+ GURL url(params.url);
+ std::string mime_type(params.mimeType.utf8());
std::string actual_mime_type;
- render_thread_->Send(new ViewHostMsg_GetPluginPath(
- params.url, frame->top()->url(), params.mimeType.utf8(), &path,
+ Send(new ViewHostMsg_GetPluginInfo(url,
+ frame->top()->url(),
+ mime_type,
+ &found,
+ &info,
&actual_mime_type));
- if (path.value().empty())
+
+ if (!found || !info.enabled)
return NULL;
if (CommandLine::ForCurrentProcess()->HasSwitch(
switches::kEnableClickToPlay)) {
if (!AllowContentType(CONTENT_SETTINGS_TYPE_PLUGINS) &&
- path.value() != kDefaultPluginLibraryName) {
+ info.path.value() != kDefaultPluginLibraryName) {
didNotAllowPlugins(frame);
return CreatePluginPlaceholder(frame, params);
}
}
- return CreatePluginInternal(frame, params, actual_mime_type, path);
+ return CreatePluginInternal(frame, params, &info, actual_mime_type);
}
WebWorker* RenderView::createWorker(WebFrame* frame, WebWorkerClient* client) {
@@ -3674,23 +3681,29 @@ void RenderView::ClearBlockedContentSettings() {
WebPlugin* RenderView::CreatePluginInternal(WebFrame* frame,
const WebPluginParams& params,
- const std::string& mime_type,
- const FilePath& plugin_path) {
- FilePath path(plugin_path);
+ WebPluginInfo* plugin_info,
+ const std::string& mime_type) {
std::string actual_mime_type(mime_type);
- if (path.value().empty()) {
- render_thread_->Send(new ViewHostMsg_GetPluginPath(
- params.url, frame->top()->url(), params.mimeType.utf8(), &path,
- &actual_mime_type));
- }
- if (path.value().empty())
+ WebPluginInfo info;
+ if (plugin_info != NULL) {
+ info = *plugin_info;
+ } else {
+ bool found;
+ std::string actual_mime_type(mime_type);
+ Send(new ViewHostMsg_GetPluginInfo(
+ params.url, frame->top()->url(), params.mimeType.utf8(), &found,
+ &info, &actual_mime_type));
+ if (!found)
+ info.enabled = false;
+ }
+ if (!info.enabled)
return NULL;
if (actual_mime_type.empty())
actual_mime_type = params.mimeType.utf8();
scoped_refptr<pepper::PluginModule> pepper_module =
- PepperPluginRegistry::GetInstance()->GetModule(path);
+ PepperPluginRegistry::GetInstance()->GetModule(info.path);
if (pepper_module) {
WebPlugin* plugin = new pepper::WebPluginImpl(pepper_module, params,
pepper_delegate_.AsWeakPtr());
@@ -3702,14 +3715,14 @@ WebPlugin* RenderView::CreatePluginInternal(WebFrame* frame,
// hardcode this for the PDF plugin path.
FilePath pdf_path;
PathService::Get(chrome::FILE_PDF_PLUGIN, &pdf_path);
- if (path == pdf_path)
+ if (info.path == pdf_path)
Send(new ViewHostMsg_SetDisplayingPDFContent(routing_id_));
}
return plugin;
}
- return new webkit_glue::WebPluginImpl(frame, params, path, actual_mime_type,
- AsWeakPtr());
+ return new webkit_glue::WebPluginImpl(frame, params, info.path,
+ actual_mime_type, AsWeakPtr());
}
WebPlugin* RenderView::CreatePluginPlaceholder(WebFrame* frame,
diff --git a/chrome/renderer/render_view.h b/chrome/renderer/render_view.h
index 4bd7ba4..6e2a43b 100644
--- a/chrome/renderer/render_view.h
+++ b/chrome/renderer/render_view.h
@@ -275,8 +275,8 @@ class RenderView : public RenderWidget,
WebKit::WebPlugin* CreatePluginInternal(
WebKit::WebFrame* frame,
const WebKit::WebPluginParams& params,
- const std::string& mime_type,
- const FilePath& plugin_path);
+ WebPluginInfo* plugin_info,
+ const std::string& mime_type);
// Asks the browser for the CPBrowsingContext associated with this renderer.
// This is an opaque identifier associated with the renderer for sending