summaryrefslogtreecommitdiffstats
path: root/content/browser/plugin_service_impl_browsertest.cc
diff options
context:
space:
mode:
authorcevans@chromium.org <cevans@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-02-01 18:20:54 +0000
committercevans@chromium.org <cevans@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-02-01 18:20:54 +0000
commit6be31d20e5c3727f136b8dfe06cd7f27ebf898bb (patch)
tree4fd003b303a8aad479b3d97fd4d1506817e64c3a /content/browser/plugin_service_impl_browsertest.cc
parentebee9ccaecaf57a0d2b8a36a41de689eef977fea (diff)
downloadchromium_src-6be31d20e5c3727f136b8dfe06cd7f27ebf898bb.zip
chromium_src-6be31d20e5c3727f136b8dfe06cd7f27ebf898bb.tar.gz
chromium_src-6be31d20e5c3727f136b8dfe06cd7f27ebf898bb.tar.bz2
Only permit plug-in loads in the browser if the plug-in isn't blocked or the
user has authorized it with a browser-mediated interaction. (Reland https://codereview.chromium.org/12086077 with Android test tweak) BUG=172573 R=jam@chromium.org Review URL: https://codereview.chromium.org/12092107 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@180159 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/browser/plugin_service_impl_browsertest.cc')
-rw-r--r--content/browser/plugin_service_impl_browsertest.cc43
1 files changed, 39 insertions, 4 deletions
diff --git a/content/browser/plugin_service_impl_browsertest.cc b/content/browser/plugin_service_impl_browsertest.cc
index 18780355..0f25185 100644
--- a/content/browser/plugin_service_impl_browsertest.cc
+++ b/content/browser/plugin_service_impl_browsertest.cc
@@ -9,6 +9,7 @@
#include "base/command_line.h"
#include "base/path_service.h"
#include "content/public/browser/browser_context.h"
+#include "content/public/browser/plugin_service_filter.h"
#include "content/public/browser/resource_context.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/content_switches.h"
@@ -36,10 +37,11 @@ void OpenChannel(PluginProcessHost::Client* client) {
class MockPluginProcessHostClient : public PluginProcessHost::Client,
public IPC::Listener {
public:
- MockPluginProcessHostClient(ResourceContext* context)
+ MockPluginProcessHostClient(ResourceContext* context, bool expect_fail)
: context_(context),
channel_(NULL),
- set_plugin_info_called_(false) {
+ set_plugin_info_called_(false),
+ expect_fail_(expect_fail) {
}
virtual ~MockPluginProcessHostClient() {
@@ -80,6 +82,8 @@ class MockPluginProcessHostClient : public PluginProcessHost::Client,
return false;
}
virtual void OnChannelConnected(int32 peer_pid) OVERRIDE {
+ if (expect_fail_)
+ FAIL();
QuitMessageLoop();
}
virtual void OnChannelError() OVERRIDE {
@@ -96,7 +100,8 @@ class MockPluginProcessHostClient : public PluginProcessHost::Client,
private:
void Fail() {
- FAIL();
+ if (!expect_fail_)
+ FAIL();
QuitMessageLoop();
}
@@ -108,9 +113,27 @@ class MockPluginProcessHostClient : public PluginProcessHost::Client,
ResourceContext* context_;
IPC::Channel* channel_;
bool set_plugin_info_called_;
+ bool expect_fail_;
DISALLOW_COPY_AND_ASSIGN(MockPluginProcessHostClient);
};
+class MockPluginServiceFilter : public content::PluginServiceFilter {
+ public:
+ MockPluginServiceFilter() {}
+
+ virtual bool IsPluginEnabled(
+ int render_process_id,
+ int render_view_id,
+ const void* context,
+ const GURL& url,
+ const GURL& policy_url,
+ webkit::WebPluginInfo* plugin) OVERRIDE { return true; }
+
+ virtual bool CanLoadPlugin(
+ int render_process_id,
+ const FilePath& path) OVERRIDE { return false; }
+};
+
class PluginServiceTest : public ContentBrowserTest {
public:
PluginServiceTest() {}
@@ -140,7 +163,19 @@ class PluginServiceTest : public ContentBrowserTest {
IN_PROC_BROWSER_TEST_F(PluginServiceTest, OpenChannelToPlugin) {
if (!webkit::npapi::NPAPIPluginsSupported())
return;
- MockPluginProcessHostClient mock_client(GetResourceContext());
+ MockPluginProcessHostClient mock_client(GetResourceContext(), false);
+ BrowserThread::PostTask(
+ BrowserThread::IO, FROM_HERE,
+ base::Bind(&OpenChannel, &mock_client));
+ RunMessageLoop();
+}
+
+IN_PROC_BROWSER_TEST_F(PluginServiceTest, OpenChannelToDeniedPlugin) {
+ if (!webkit::npapi::NPAPIPluginsSupported())
+ return;
+ MockPluginServiceFilter filter;
+ PluginServiceImpl::GetInstance()->SetFilter(&filter);
+ MockPluginProcessHostClient mock_client(GetResourceContext(), true);
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
base::Bind(&OpenChannel, &mock_client));