summaryrefslogtreecommitdiffstats
path: root/content
diff options
context:
space:
mode:
Diffstat (limited to 'content')
-rw-r--r--content/browser/plugin_process_host.h8
-rw-r--r--content/browser/plugin_service.cc195
-rw-r--r--content/browser/plugin_service.h48
-rw-r--r--content/browser/plugin_service_browsertest.cc21
-rw-r--r--content/browser/plugin_service_filter.h37
-rw-r--r--content/browser/renderer_host/buffered_resource_handler.cc18
-rw-r--r--content/browser/renderer_host/render_message_filter.cc48
-rw-r--r--content/browser/renderer_host/render_message_filter.h2
-rw-r--r--content/common/content_notification_types.h4
-rw-r--r--content/common/view_messages.h9
-rw-r--r--content/content_browser.gypi1
-rw-r--r--content/renderer/render_view.cc2
-rw-r--r--content/renderer/render_view.h8
-rw-r--r--content/renderer/webplugin_delegate_proxy.cc4
14 files changed, 221 insertions, 184 deletions
diff --git a/content/browser/plugin_process_host.h b/content/browser/plugin_process_host.h
index 7fdba4d..3c5f116 100644
--- a/content/browser/plugin_process_host.h
+++ b/content/browser/plugin_process_host.h
@@ -19,6 +19,10 @@
#include "webkit/plugins/webplugininfo.h"
#include "ui/gfx/native_widget_types.h"
+namespace content {
+class ResourceContext;
+}
+
namespace gfx {
class Rect;
}
@@ -41,9 +45,11 @@ class PluginProcessHost : public BrowserChildProcessHost {
public:
class Client {
public:
- // Returns a opaque unique identifier for the process requesting
+ // Returns an opaque unique identifier for the process requesting
// the channel.
virtual int ID() = 0;
+ // Returns the resource context for the renderer requesting the channel.
+ virtual const content::ResourceContext& GetResourceContext() = 0;
virtual bool OffTheRecord() = 0;
virtual void SetPluginInfo(const webkit::WebPluginInfo& info) = 0;
// The client should delete itself when one of these methods is called.
diff --git a/content/browser/plugin_service.cc b/content/browser/plugin_service.cc
index 7ca5b22..86670db 100644
--- a/content/browser/plugin_service.cc
+++ b/content/browser/plugin_service.cc
@@ -6,6 +6,7 @@
#include "base/command_line.h"
#include "base/compiler_specific.h"
+#include "base/file_path.h"
#include "base/path_service.h"
#include "base/string_util.h"
#include "base/synchronization/waitable_event.h"
@@ -14,6 +15,7 @@
#include "base/values.h"
#include "content/browser/browser_thread.h"
#include "content/browser/content_browser_client.h"
+#include "content/browser/plugin_service_filter.h"
#include "content/browser/ppapi_plugin_process_host.h"
#include "content/browser/renderer_host/render_process_host.h"
#include "content/browser/renderer_host/render_view_host.h"
@@ -32,6 +34,8 @@
using ::base::files::FilePathWatcher;
#endif
+using content::PluginServiceFilter;
+
#if defined(OS_MACOSX)
static void NotifyPluginsOfActivation() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
@@ -65,7 +69,8 @@ PluginService* PluginService::GetInstance() {
PluginService::PluginService()
: ui_locale_(
- content::GetContentClient()->browser()->GetApplicationLocale()) {
+ content::GetContentClient()->browser()->GetApplicationLocale()),
+ filter_(NULL) {
RegisterPepperPlugins();
// Load any specified on the command line as well.
@@ -77,6 +82,27 @@ PluginService::PluginService()
if (!path.empty())
webkit::npapi::PluginList::Singleton()->AddExtraPluginDir(path);
+#if defined(OS_MACOSX)
+ // We need to know when the browser comes forward so we can bring modal plugin
+ // windows forward too.
+ registrar_.Add(this, content::NOTIFICATION_APP_ACTIVATED,
+ NotificationService::AllSources());
+#endif
+}
+
+PluginService::~PluginService() {
+#if defined(OS_WIN)
+ // Release the events since they're owned by RegKey, not WaitableEvent.
+ hkcu_watcher_.StopWatching();
+ hklm_watcher_.StopWatching();
+ if (hkcu_event_.get())
+ hkcu_event_->Release();
+ if (hklm_event_.get())
+ hklm_event_->Release();
+#endif
+}
+
+void PluginService::StartWatchingPlugins() {
// Start watching for changes in the plugin list. This means watching
// for changes in the Windows registry keys and on both Windows and POSIX
// watch for changes in the paths that are expected to contain plugins.
@@ -97,12 +123,7 @@ PluginService::PluginService()
hklm_watcher_.StartWatching(hklm_event_.get(), this);
}
}
-#elif defined(OS_MACOSX)
- // We need to know when the browser comes forward so we can bring modal plugin
- // windows forward too.
- registrar_.Add(this, content::NOTIFICATION_APP_ACTIVATED,
- NotificationService::AllSources());
-#elif defined(OS_POSIX)
+#elif defined(OS_POSIX) && !defined(OS_MACOSX)
// The FilePathWatcher produces too many false positives on MacOS (access time
// updates?) which will lead to enforcing updates of the plugins way too often.
// On ChromeOS the user can't install plugins anyway and on Windows all
@@ -132,23 +153,6 @@ PluginService::PluginService()
file_watchers_.push_back(watcher);
}
#endif
- registrar_.Add(this, content::NOTIFICATION_PLUGIN_ENABLE_STATUS_CHANGED,
- NotificationService::AllSources());
- registrar_.Add(this,
- content::NOTIFICATION_RENDERER_PROCESS_CLOSED,
- NotificationService::AllSources());
-}
-
-PluginService::~PluginService() {
-#if defined(OS_WIN)
- // Release the events since they're owned by RegKey, not WaitableEvent.
- hkcu_watcher_.StopWatching();
- hklm_watcher_.StopWatching();
- if (hkcu_event_.get())
- hkcu_event_->Release();
- if (hklm_event_.get())
- hklm_event_->Release();
-#endif
}
const std::string& PluginService::GetUILocale() {
@@ -278,6 +282,7 @@ void PluginService::OpenChannelToNpapiPlugin(
int render_process_id,
int render_view_id,
const GURL& url,
+ const GURL& page_url,
const std::string& mime_type,
PluginProcessHost::Client* client) {
// The PluginList::GetPluginInfo may need to load the plugins. Don't do it on
@@ -286,7 +291,8 @@ void PluginService::OpenChannelToNpapiPlugin(
BrowserThread::FILE, FROM_HERE,
NewRunnableMethod(
this, &PluginService::GetAllowedPluginForOpenChannelToPlugin,
- render_process_id, render_view_id, url, mime_type, client));
+ render_process_id, render_view_id, url, page_url, mime_type,
+ client));
}
void PluginService::OpenChannelToPpapiPlugin(
@@ -314,15 +320,19 @@ void PluginService::GetAllowedPluginForOpenChannelToPlugin(
int render_process_id,
int render_view_id,
const GURL& url,
+ const GURL& page_url,
const std::string& mime_type,
PluginProcessHost::Client* client) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
webkit::WebPluginInfo info;
+ bool allow_wildcard = true;
bool found = GetPluginInfo(
- render_process_id, render_view_id, url, mime_type, &info, NULL);
+ render_process_id, render_view_id, client->GetResourceContext(),
+ url, page_url, mime_type, allow_wildcard,
+ NULL, &info, NULL);
FilePath plugin_path;
if (found)
- plugin_path = FilePath(info.path);
+ plugin_path = info.path;
// Now we jump back to the IO thread to finish opening the channel.
BrowserThread::PostTask(
@@ -346,34 +356,38 @@ void PluginService::FinishOpenChannelToPlugin(
bool PluginService::GetPluginInfo(int render_process_id,
int render_view_id,
+ const content::ResourceContext& context,
const GURL& url,
+ const GURL& page_url,
const std::string& mime_type,
+ bool allow_wildcard,
+ bool* use_stale,
webkit::WebPluginInfo* info,
std::string* actual_mime_type) {
+ webkit::npapi::PluginList* plugin_list =
+ webkit::npapi::PluginList::Singleton();
// GetPluginInfoArray may need to load the plugins, so we need to be
// on the FILE thread.
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
- {
- base::AutoLock auto_lock(overridden_plugins_lock_);
- for (size_t i = 0; i < overridden_plugins_.size(); ++i) {
- if (overridden_plugins_[i].render_process_id == render_process_id &&
- overridden_plugins_[i].render_view_id == render_view_id &&
- (overridden_plugins_[i].url == url ||
- overridden_plugins_[i].url.is_empty())) {
- if (actual_mime_type)
- *actual_mime_type = mime_type;
- *info = overridden_plugins_[i].plugin;
- return true;
- }
- }
- }
- bool allow_wildcard = true;
+ DCHECK(use_stale || BrowserThread::CurrentlyOn(BrowserThread::FILE));
std::vector<webkit::WebPluginInfo> plugins;
std::vector<std::string> mime_types;
- webkit::npapi::PluginList::Singleton()->GetPluginInfoArray(
- url, mime_type, allow_wildcard, NULL, &plugins, &mime_types);
+ plugin_list->GetPluginInfoArray(
+ url, mime_type, allow_wildcard, use_stale, &plugins, &mime_types);
+ if (plugins.size() > 1 &&
+ plugins.back().path ==
+ FilePath(webkit::npapi::kDefaultPluginLibraryName)) {
+ // If there is at least one plug-in handling the required MIME type (apart
+ // from the default plug-in), we don't need the default plug-in.
+ plugins.pop_back();
+ }
+
for (size_t i = 0; i < plugins.size(); ++i) {
- if (webkit::IsPluginEnabled(plugins[i])) {
+ if (!filter_ || filter_->ShouldUsePlugin(render_process_id,
+ render_view_id,
+ &context,
+ url,
+ page_url,
+ &plugins[i])) {
*info = plugins[i];
if (actual_mime_type)
*actual_mime_type = mime_types[i];
@@ -383,6 +397,31 @@ 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.
+ 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]);
+ }
+ }
+}
+
void PluginService::OnWaitableEventSignaled(
base::WaitableEvent* waitable_event) {
#if defined(OS_WIN)
@@ -403,40 +442,14 @@ void PluginService::OnWaitableEventSignaled(
void PluginService::Observe(int type,
const NotificationSource& source,
const NotificationDetails& details) {
- switch (type) {
#if defined(OS_MACOSX)
- case content::NOTIFICATION_APP_ACTIVATED: {
- BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
- NewRunnableFunction(&NotifyPluginsOfActivation));
- break;
- }
-#endif
-
- case content::NOTIFICATION_PLUGIN_ENABLE_STATUS_CHANGED: {
- webkit::npapi::PluginList::Singleton()->RefreshPlugins();
- PurgePluginListCache(false);
- break;
- }
- case content::NOTIFICATION_RENDERER_PROCESS_CLOSED: {
- int render_process_id = Source<RenderProcessHost>(source).ptr()->id();
-
- base::AutoLock auto_lock(overridden_plugins_lock_);
- for (size_t i = 0; i < overridden_plugins_.size(); ++i) {
- if (overridden_plugins_[i].render_process_id == render_process_id) {
- overridden_plugins_.erase(overridden_plugins_.begin() + i);
- break;
- }
- }
- break;
- }
- default:
- NOTREACHED();
+ if (type == content::NOTIFICATION_APP_ACTIVATED) {
+ BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
+ NewRunnableFunction(&NotifyPluginsOfActivation));
+ return;
}
-}
-
-void PluginService::OverridePluginForTab(const OverriddenPlugin& plugin) {
- base::AutoLock auto_lock(overridden_plugins_lock_);
- overridden_plugins_.push_back(plugin);
+#endif
+ NOTREACHED();
}
void PluginService::PurgePluginListCache(bool reload_pages) {
@@ -446,32 +459,6 @@ void PluginService::PurgePluginListCache(bool reload_pages) {
}
}
-void PluginService::RestrictPluginToUrl(const FilePath& plugin_path,
- const GURL& url) {
- base::AutoLock auto_lock(restricted_plugin_lock_);
- if (url.is_empty()) {
- restricted_plugin_.erase(plugin_path);
- } else {
- restricted_plugin_[plugin_path] = url;
- }
-}
-
-bool PluginService::PluginAllowedForURL(const FilePath& plugin_path,
- const GURL& url) {
- if (url.is_empty())
- return true; // Caller wants all plugins.
-
- base::AutoLock auto_lock(restricted_plugin_lock_);
-
- RestrictedPluginMap::iterator it = restricted_plugin_.find(plugin_path);
- if (it == restricted_plugin_.end())
- return true; // This plugin is not restricted, so it's allowed everywhere.
-
- const GURL& required_url = it->second;
- return (url.scheme() == required_url.scheme() &&
- url.host() == required_url.host());
-}
-
void PluginService::RegisterPepperPlugins() {
// TODO(abarth): It seems like the PepperPluginRegistry should do this work.
PepperPluginRegistry::ComputeList(&ppapi_plugins_);
diff --git a/content/browser/plugin_service.h b/content/browser/plugin_service.h
index 9cdbcad..8dbef70f 100644
--- a/content/browser/plugin_service.h
+++ b/content/browser/plugin_service.h
@@ -13,11 +13,8 @@
#include <vector>
#include "base/basictypes.h"
-#include "base/file_path.h"
-#include "base/hash_tables.h"
#include "base/memory/scoped_vector.h"
#include "base/memory/singleton.h"
-#include "base/synchronization/lock.h"
#include "base/synchronization/waitable_event_watcher.h"
#include "build/build_config.h"
#include "content/browser/plugin_process_host.h"
@@ -41,6 +38,11 @@
struct PepperPluginInfo;
class PluginDirWatcherDelegate;
+namespace content {
+class ResourceContext;
+class PluginServiceFilter;
+}
+
// This must be created on the main thread but it's only called on the IO/file
// thread.
class PluginService
@@ -57,6 +59,9 @@ class PluginService
// Returns the PluginService singleton.
static PluginService* GetInstance();
+ // Starts watching for changes in the list of installed plug-ins.
+ void StartWatchingPlugins();
+
// Gets the browser's UI locale.
const std::string& GetUILocale();
@@ -85,6 +90,7 @@ class PluginService
void OpenChannelToNpapiPlugin(int render_process_id,
int render_view_id,
const GURL& url,
+ const GURL& page_url,
const std::string& mime_type,
PluginProcessHost::Client* client);
void OpenChannelToPpapiPlugin(const FilePath& path,
@@ -93,32 +99,32 @@ class PluginService
PpapiBrokerProcessHost::Client* client);
// Gets the plugin in the list of plugins that matches the given url and mime
- // type. Must be called on the FILE thread.
+ // type. Must be called on the FILE thread if |use_stale| is NULL.
bool GetPluginInfo(int render_process_id,
int render_view_id,
+ const content::ResourceContext& context,
const GURL& url,
+ const GURL& page_url,
const std::string& mime_type,
+ bool allow_wildcard,
+ bool* use_stale,
webkit::WebPluginInfo* info,
std::string* actual_mime_type);
- // Safe to be called from any thread.
- void OverridePluginForTab(const OverriddenPlugin& plugin);
-
- // Restricts the given plugin to the the scheme and host of the given url.
- // Call with an empty url to reset this.
- // Can be called on any thread.
- void RestrictPluginToUrl(const FilePath& plugin_path, const GURL& url);
-
- // Returns true if the given plugin is allowed to be used by a page with
- // the given URL.
- // Can be called on any thread.
- bool PluginAllowedForURL(const FilePath& plugin_path, const GURL& url);
+ // Returns a list of all plug-ins available to the resource context. Must be
+ // called on the FILE thread.
+ void GetPlugins(const content::ResourceContext& context,
+ std::vector<webkit::WebPluginInfo>* plugins);
// Tells all the renderer processes to throw away their cache of the plugin
// list, and optionally also reload all the pages with plugins.
// NOTE: can only be called on the UI thread.
static void PurgePluginListCache(bool reload_pages);
+ void set_filter(content::PluginServiceFilter* filter) {
+ filter_ = filter;
+ }
+
private:
friend struct DefaultSingletonTraits<PluginService>;
@@ -143,6 +149,7 @@ class PluginService
int render_process_id,
int render_view_id,
const GURL& url,
+ const GURL& page_url,
const std::string& mime_type,
PluginProcessHost::Client* client);
@@ -163,11 +170,6 @@ class PluginService
// The browser's UI locale.
const std::string ui_locale_;
- // Map of plugin paths to the origin they are restricted to.
- base::Lock restricted_plugin_lock_; // Guards access to restricted_plugin_.
- typedef base::hash_map<FilePath, GURL> RestrictedPluginMap;
- RestrictedPluginMap restricted_plugin_;
-
NotificationRegistrar registrar_;
#if defined(OS_WIN)
@@ -187,8 +189,8 @@ class PluginService
std::vector<PepperPluginInfo> ppapi_plugins_;
- std::vector<OverriddenPlugin> overridden_plugins_;
- base::Lock overridden_plugins_lock_;
+ // Weak pointer; outlives us.
+ content::PluginServiceFilter* filter_;
DISALLOW_COPY_AND_ASSIGN(PluginService);
};
diff --git a/content/browser/plugin_service_browsertest.cc b/content/browser/plugin_service_browsertest.cc
index 95ce4b6..c49a90b 100644
--- a/content/browser/plugin_service_browsertest.cc
+++ b/content/browser/plugin_service_browsertest.cc
@@ -6,9 +6,12 @@
#include "base/command_line.h"
#include "base/path_service.h"
+#include "chrome/browser/ui/browser.h"
#include "chrome/test/base/in_process_browser_test.h"
+#include "chrome/test/base/testing_profile.h"
#include "chrome/test/base/ui_test_utils.h"
#include "content/browser/browser_thread.h"
+#include "content/browser/resource_context.h"
#include "content/common/content_switches.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "webkit/plugins/npapi/plugin_list.h"
@@ -22,8 +25,9 @@ const char* kNPAPITestPluginMimeType = "application/vnd.npapi-test";
class MockPluginProcessHostClient : public PluginProcessHost::Client,
public IPC::Channel::Listener {
public:
- MockPluginProcessHostClient()
- : channel_(NULL),
+ MockPluginProcessHostClient(const content::ResourceContext& context)
+ : context_(context),
+ channel_(NULL),
set_plugin_info_called_(false) {
}
@@ -33,8 +37,11 @@ class MockPluginProcessHostClient : public PluginProcessHost::Client,
}
// Client implementation.
- int ID() { return 42; }
- bool OffTheRecord() { return false; }
+ virtual int ID() OVERRIDE { return 42; }
+ virtual bool OffTheRecord() OVERRIDE { return false; }
+ virtual const content::ResourceContext& GetResourceContext() OVERRIDE {
+ return context_;
+ }
void OnChannelOpened(const IPC::ChannelHandle& handle) {
ASSERT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::IO));
@@ -63,6 +70,7 @@ class MockPluginProcessHostClient : public PluginProcessHost::Client,
MOCK_METHOD0(OnChannelListenError, void());
private:
+ const content::ResourceContext& context_;
IPC::Channel* channel_;
bool set_plugin_info_called_;
DISALLOW_COPY_AND_ASSIGN(MockPluginProcessHostClient);
@@ -87,8 +95,9 @@ class PluginServiceTest : public InProcessBrowserTest {
// Try to open a channel to the test plugin. Minimal plugin process spawning
// test for the PluginService interface.
IN_PROC_BROWSER_TEST_F(PluginServiceTest, OpenChannelToPlugin) {
- MockPluginProcessHostClient mock_client;
+ ::testing::StrictMock<MockPluginProcessHostClient> mock_client(
+ browser()->profile()->GetResourceContext());
PluginService::GetInstance()->OpenChannelToNpapiPlugin(
- 0, 0, GURL(), kNPAPITestPluginMimeType, &mock_client);
+ 0, 0, GURL(), GURL(), kNPAPITestPluginMimeType, &mock_client);
ui_test_utils::RunMessageLoop();
}
diff --git a/content/browser/plugin_service_filter.h b/content/browser/plugin_service_filter.h
new file mode 100644
index 0000000..790c501
--- /dev/null
+++ b/content/browser/plugin_service_filter.h
@@ -0,0 +1,37 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CONTENT_BROWSER_PLUGIN_FILTER_H_
+#define CONTENT_BROWSER_PLUGIN_FILTER_H_
+#pragma once
+
+class GURL;
+
+namespace webkit {
+struct WebPluginInfo;
+}
+
+namespace content {
+
+class ResourceContext;
+
+// Callback class to let the client filter the list of all installed plug-ins.
+// This class is called on the FILE thread.
+class PluginServiceFilter {
+ public:
+ virtual ~PluginServiceFilter() {}
+ // Whether to use |plugin|. The client can return false to disallow the
+ // plugin, or return true and optionally change the passed in plugin.
+ virtual bool ShouldUsePlugin(
+ int render_process_id,
+ int render_view_id,
+ const void* context,
+ const GURL& url,
+ const GURL& policy_url,
+ webkit::WebPluginInfo* plugin) = 0;
+};
+
+} // namespace content
+
+#endif // CONTENT_BROWSER_PLUGIN_FILTER_H_
diff --git a/content/browser/renderer_host/buffered_resource_handler.cc b/content/browser/renderer_host/buffered_resource_handler.cc
index 97b063f..026ce66 100644
--- a/content/browser/renderer_host/buffered_resource_handler.cc
+++ b/content/browser/renderer_host/buffered_resource_handler.cc
@@ -12,6 +12,7 @@
#include "content/browser/browser_thread.h"
#include "content/browser/content_browser_client.h"
#include "content/browser/download/download_resource_handler.h"
+#include "content/browser/plugin_service.h"
#include "content/browser/renderer_host/resource_dispatcher_host.h"
#include "content/browser/renderer_host/resource_dispatcher_host_delegate.h"
#include "content/browser/renderer_host/resource_dispatcher_host_request_info.h"
@@ -397,10 +398,15 @@ bool BufferedResourceHandler::ShouldDownload(bool* need_plugin_list) {
// Finally, check the plugin list.
bool allow_wildcard = false;
+ ResourceDispatcherHostRequestInfo* info =
+ ResourceDispatcherHost::InfoForRequest(request_);
bool stale = false;
- std::vector<webkit::WebPluginInfo> plugins;
- webkit::npapi::PluginList::Singleton()->GetPluginInfoArray(
- request_->url(), type, allow_wildcard, &stale, &plugins, NULL);
+ webkit::WebPluginInfo plugin;
+ bool found = PluginService::GetInstance()->GetPluginInfo(
+ info->child_id(), info->route_id(), *info->context(),
+ request_->url(), GURL(), type, allow_wildcard,
+ &stale, &plugin, NULL);
+
if (need_plugin_list) {
if (stale) {
*need_plugin_list = true;
@@ -410,11 +416,7 @@ bool BufferedResourceHandler::ShouldDownload(bool* need_plugin_list) {
DCHECK(!stale);
}
- for (size_t i = 0; i < plugins.size(); ++i) {
- if (webkit::IsPluginEnabled(plugins[i]))
- return false;
- }
- return true;
+ return !found;
}
void BufferedResourceHandler::UseAlternateResourceHandler(
diff --git a/content/browser/renderer_host/render_message_filter.cc b/content/browser/renderer_host/render_message_filter.cc
index 791dc9e..32180e3 100644
--- a/content/browser/renderer_host/render_message_filter.cc
+++ b/content/browser/renderer_host/render_message_filter.cc
@@ -70,6 +70,7 @@
#endif
using net::CookieStore;
+using content::PluginServiceFilter;
namespace {
@@ -121,27 +122,33 @@ class OpenChannelToNpapiPluginCallback : public RenderMessageCompletionCallback,
public PluginProcessHost::Client {
public:
OpenChannelToNpapiPluginCallback(RenderMessageFilter* filter,
+ const content::ResourceContext& context,
IPC::Message* reply_msg)
- : RenderMessageCompletionCallback(filter, reply_msg) {
+ : RenderMessageCompletionCallback(filter, reply_msg),
+ context_(context) {
}
- virtual int ID() {
+ virtual int ID() OVERRIDE {
return filter()->render_process_id();
}
- virtual bool OffTheRecord() {
+ virtual const content::ResourceContext& GetResourceContext() OVERRIDE {
+ return context_;
+ }
+
+ virtual bool OffTheRecord() OVERRIDE {
return filter()->OffTheRecord();
}
- virtual void SetPluginInfo(const webkit::WebPluginInfo& info) {
+ virtual void SetPluginInfo(const webkit::WebPluginInfo& info) OVERRIDE {
info_ = info;
}
- virtual void OnChannelOpened(const IPC::ChannelHandle& handle) {
+ virtual void OnChannelOpened(const IPC::ChannelHandle& handle) OVERRIDE {
WriteReplyAndDeleteThis(handle);
}
- virtual void OnError() {
+ virtual void OnError() OVERRIDE {
WriteReplyAndDeleteThis(IPC::ChannelHandle());
}
@@ -152,6 +159,7 @@ class OpenChannelToNpapiPluginCallback : public RenderMessageCompletionCallback,
SendReplyAndDeleteThis();
}
+ const content::ResourceContext& context_;
webkit::WebPluginInfo info_;
};
@@ -536,38 +544,36 @@ void RenderMessageFilter::OnGetPlugins(
}
}
- std::vector<webkit::WebPluginInfo> all_plugins;
- webkit::npapi::PluginList::Singleton()->GetPlugins(&all_plugins);
- for (size_t i = 0; i < all_plugins.size(); ++i) {
- if (webkit::IsPluginEnabled(all_plugins[i]))
- plugins->push_back(all_plugins[i]);
- }
+ PluginService::GetInstance()->GetPlugins(resource_context_,
+ plugins);
}
void RenderMessageFilter::OnGetPluginInfo(
int routing_id,
const GURL& url,
- const GURL& policy_url,
+ const GURL& page_url,
const std::string& mime_type,
bool* found,
webkit::WebPluginInfo* info,
std::string* actual_mime_type) {
+ bool allow_wildcard = true;
*found = plugin_service_->GetPluginInfo(
- render_process_id_, routing_id, url, mime_type, info, actual_mime_type);
-
- if (*found) {
- if (!plugin_service_->PluginAllowedForURL(info->path, policy_url))
- info->enabled |= webkit::WebPluginInfo::POLICY_DISABLED;
- }
+ render_process_id_, routing_id, resource_context_,
+ url, page_url, mime_type, allow_wildcard,
+ NULL, info, actual_mime_type);
}
void RenderMessageFilter::OnOpenChannelToPlugin(int routing_id,
const GURL& url,
+ const GURL& policy_url,
const std::string& mime_type,
IPC::Message* reply_msg) {
plugin_service_->OpenChannelToNpapiPlugin(
- render_process_id_, routing_id, url, mime_type,
- new OpenChannelToNpapiPluginCallback(this, reply_msg));
+ render_process_id_, routing_id,
+ url, policy_url, mime_type,
+ new OpenChannelToNpapiPluginCallback(this,
+ resource_context_,
+ reply_msg));
}
void RenderMessageFilter::OnOpenChannelToPepperPlugin(
diff --git a/content/browser/renderer_host/render_message_filter.h b/content/browser/renderer_host/render_message_filter.h
index 946d144..247571e 100644
--- a/content/browser/renderer_host/render_message_filter.h
+++ b/content/browser/renderer_host/render_message_filter.h
@@ -27,7 +27,6 @@
#include "ui/gfx/surface/transport_dib.h"
struct FontDescriptor;
-class HostContentSettingsMap;
class RenderWidgetHelper;
struct ViewHostMsg_CreateWindow_Params;
struct ViewHostMsg_CreateWorker_Params;
@@ -157,6 +156,7 @@ class RenderMessageFilter : public BrowserMessageFilter {
std::string* actual_mime_type);
void OnOpenChannelToPlugin(int routing_id,
const GURL& url,
+ const GURL& policy_url,
const std::string& mime_type,
IPC::Message* reply_msg);
void OnOpenChannelToPepperPlugin(const FilePath& path,
diff --git a/content/common/content_notification_types.h b/content/common/content_notification_types.h
index 144ebb7..a193dac 100644
--- a/content/common/content_notification_types.h
+++ b/content/common/content_notification_types.h
@@ -412,10 +412,6 @@ enum NotificationType {
// in a Details<ChildProcessInfo>.
NOTIFICATION_CHILD_INSTANCE_CREATED,
- // Sent by the PluginUpdater when there is a change of plugin
- // enable/disable status.
- NOTIFICATION_PLUGIN_ENABLE_STATUS_CHANGED,
-
// Download Notifications --------------------------------------------------
// Sent when a page generation to MHTML has finished.
diff --git a/content/common/view_messages.h b/content/common/view_messages.h
index 395ff9e..c71b244 100644
--- a/content/common/view_messages.h
+++ b/content/common/view_messages.h
@@ -1613,16 +1613,14 @@ IPC_SYNC_MESSAGE_CONTROL1_1(ViewHostMsg_GetPlugins,
std::vector<webkit::WebPluginInfo> /* plugins */)
// Return information about a plugin for the given URL and MIME
-// type. If there is no matching plugin, |found| is false. If
-// |enabled| in the WebPluginInfo struct is false, the plug-in is
-// treated as if it was not installed at all.
+// type. If there is no matching plugin, |found| is false.
// |actual_mime_type| is the actual mime type supported by the
// plugin found that match the URL given (one for each item in
// |info|).
IPC_SYNC_MESSAGE_CONTROL4_3(ViewHostMsg_GetPluginInfo,
int /* routing_id */,
GURL /* url */,
- GURL /* policy_url */,
+ GURL /* page_url */,
std::string /* mime_type */,
bool /* found */,
webkit::WebPluginInfo /* plugin info */,
@@ -1632,9 +1630,10 @@ IPC_SYNC_MESSAGE_CONTROL4_3(ViewHostMsg_GetPluginInfo,
// create a plugin. The browser will create the plugin process if
// necessary, and will return a handle to the channel on success.
// On error an empty string is returned.
-IPC_SYNC_MESSAGE_CONTROL3_2(ViewHostMsg_OpenChannelToPlugin,
+IPC_SYNC_MESSAGE_CONTROL4_2(ViewHostMsg_OpenChannelToPlugin,
int /* routing_id */,
GURL /* url */,
+ GURL /* page_url */,
std::string /* mime_type */,
IPC::ChannelHandle /* channel_handle */,
webkit::WebPluginInfo /* info */)
diff --git a/content/content_browser.gypi b/content/content_browser.gypi
index a346ffe..60b9e49 100644
--- a/content/content_browser.gypi
+++ b/content/content_browser.gypi
@@ -294,6 +294,7 @@
'browser/plugin_process_host_mac.cc',
'browser/plugin_service.cc',
'browser/plugin_service.h',
+ 'browser/plugin_service_filter.h',
'browser/quota_permission_context.h',
'browser/renderer_host/accelerated_surface_container_mac.cc',
'browser/renderer_host/accelerated_surface_container_mac.h',
diff --git a/content/renderer/render_view.cc b/content/renderer/render_view.cc
index 9ea7d42..c783312 100644
--- a/content/renderer/render_view.cc
+++ b/content/renderer/render_view.cc
@@ -581,7 +581,7 @@ WebPlugin* RenderView::CreatePluginNoCheck(WebFrame* frame,
Send(new ViewHostMsg_GetPluginInfo(
routing_id_, params.url, frame->top()->document().url(),
params.mimeType.utf8(), &found, &info, &mime_type));
- if (!found || !webkit::IsPluginEnabled(info))
+ if (!found)
return NULL;
bool pepper_plugin_was_registered = false;
diff --git a/content/renderer/render_view.h b/content/renderer/render_view.h
index 2df1088..cadbc81 100644
--- a/content/renderer/render_view.h
+++ b/content/renderer/render_view.h
@@ -88,10 +88,6 @@ namespace content {
class P2PSocketDispatcher;
} // namespace content
-namespace chrome {
-class ChromeContentRendererClient;
-} // namespace chrome
-
namespace gfx {
class Point;
class Rect;
@@ -99,10 +95,6 @@ class Rect;
namespace webkit {
-namespace npapi {
-class PluginGroup;
-} // namespace npapi
-
namespace ppapi {
class PluginInstance;
class PluginModule;
diff --git a/content/renderer/webplugin_delegate_proxy.cc b/content/renderer/webplugin_delegate_proxy.cc
index c9640b3..8ffd930 100644
--- a/content/renderer/webplugin_delegate_proxy.cc
+++ b/content/renderer/webplugin_delegate_proxy.cc
@@ -283,8 +283,8 @@ bool WebPluginDelegateProxy::Initialize(
bool load_manually) {
IPC::ChannelHandle channel_handle;
if (!RenderThread::current()->Send(new ViewHostMsg_OpenChannelToPlugin(
- render_view_->routing_id(), url, mime_type_, &channel_handle,
- &info_))) {
+ render_view_->routing_id(), url, page_url_, mime_type_,
+ &channel_handle, &info_))) {
return false;
}