Browser Plugin: Only install BrowserPluginMessageFilter if render process supports BrowserPlugin.
BUG=222403 Test=Manually test BrowserPlugin/<webview> on chrome and content_shell Review URL: https://chromiumcodereview.appspot.com/12518033 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@190057 0039d316-1c4b-4281-b951-d872f2087c98
This commit is contained in:
chrome/browser
content
@ -1971,6 +1971,26 @@ content::BrowserPpapiHost*
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool ChromeContentBrowserClient::SupportsBrowserPlugin(
|
||||
content::BrowserContext* browser_context, const GURL& site_url) {
|
||||
if (CommandLine::ForCurrentProcess()->HasSwitch(
|
||||
switches::kEnableBrowserPluginForAllViewTypes))
|
||||
return true;
|
||||
|
||||
Profile* profile = Profile::FromBrowserContext(browser_context);
|
||||
ExtensionService* service =
|
||||
extensions::ExtensionSystem::Get(profile)->extension_service();
|
||||
if (!service)
|
||||
return false;
|
||||
|
||||
const Extension* extension = service->extensions()->
|
||||
GetExtensionOrAppByURL(ExtensionURLInfo(site_url));
|
||||
if (!extension)
|
||||
return false;
|
||||
|
||||
return extension->HasAPIPermission(APIPermission::kWebView);
|
||||
}
|
||||
|
||||
bool ChromeContentBrowserClient::AllowPepperSocketAPI(
|
||||
content::BrowserContext* browser_context,
|
||||
const GURL& url,
|
||||
|
@ -211,6 +211,8 @@ class ChromeContentBrowserClient : public content::ContentBrowserClient {
|
||||
content::BrowserPpapiHost* browser_host) OVERRIDE;
|
||||
virtual content::BrowserPpapiHost* GetExternalBrowserPpapiHost(
|
||||
int plugin_process_id) OVERRIDE;
|
||||
virtual bool SupportsBrowserPlugin(content::BrowserContext* browser_context,
|
||||
const GURL& site_url) OVERRIDE;
|
||||
virtual bool AllowPepperSocketAPI(
|
||||
content::BrowserContext* browser_context,
|
||||
const GURL& url,
|
||||
|
@ -368,6 +368,7 @@ void RenderProcessHost::SetMaxRendererProcessCount(size_t count) {
|
||||
RenderProcessHostImpl::RenderProcessHostImpl(
|
||||
BrowserContext* browser_context,
|
||||
StoragePartitionImpl* storage_partition_impl,
|
||||
bool supports_browser_plugin,
|
||||
bool is_guest)
|
||||
: fast_shutdown_started_(false),
|
||||
deleting_soon_(false),
|
||||
@ -386,6 +387,7 @@ RenderProcessHostImpl::RenderProcessHostImpl(
|
||||
#if defined(OS_ANDROID)
|
||||
dummy_shutdown_event_(false, false),
|
||||
#endif
|
||||
supports_browser_plugin_(supports_browser_plugin),
|
||||
is_guest_(is_guest) {
|
||||
widget_helper_ = new RenderWidgetHelper();
|
||||
|
||||
@ -539,11 +541,11 @@ void RenderProcessHostImpl::CreateMessageFilters() {
|
||||
MediaInternals* media_internals = MediaInternals::GetInstance();;
|
||||
// Add BrowserPluginMessageFilter to ensure it gets the first stab at messages
|
||||
// from guests.
|
||||
// TODO(fsamuel): Call out to the ContentBrowserClient to decide whether or
|
||||
// not to install the BrowserPluginMessageFilter.
|
||||
scoped_refptr<BrowserPluginMessageFilter> bp_message_filter(
|
||||
new BrowserPluginMessageFilter(GetID(), IsGuest()));
|
||||
channel_->AddFilter(bp_message_filter);
|
||||
if (supports_browser_plugin_) {
|
||||
scoped_refptr<BrowserPluginMessageFilter> bp_message_filter(
|
||||
new BrowserPluginMessageFilter(GetID(), IsGuest()));
|
||||
channel_->AddFilter(bp_message_filter);
|
||||
}
|
||||
|
||||
scoped_refptr<RenderMessageFilter> render_message_filter(
|
||||
new RenderMessageFilter(
|
||||
|
@ -61,6 +61,7 @@ class CONTENT_EXPORT RenderProcessHostImpl
|
||||
public:
|
||||
RenderProcessHostImpl(BrowserContext* browser_context,
|
||||
StoragePartitionImpl* storage_partition_impl,
|
||||
bool supports_browser_plugin,
|
||||
bool is_guest);
|
||||
virtual ~RenderProcessHostImpl();
|
||||
|
||||
@ -312,6 +313,10 @@ class CONTENT_EXPORT RenderProcessHostImpl
|
||||
base::WaitableEvent dummy_shutdown_event_;
|
||||
#endif
|
||||
|
||||
// Indicates whether this is a RenderProcessHost that has permission to embed
|
||||
// Browser Plugins.
|
||||
bool supports_browser_plugin_;
|
||||
|
||||
// Indicates whether this is a RenderProcessHost of a Browser Plugin guest
|
||||
// renderer.
|
||||
bool is_guest_;
|
||||
|
@ -118,8 +118,11 @@ RenderProcessHost* SiteInstanceImpl::GetProcess() {
|
||||
StoragePartitionImpl* partition =
|
||||
static_cast<StoragePartitionImpl*>(
|
||||
BrowserContext::GetStoragePartition(browser_context, this));
|
||||
bool supports_browser_plugin = GetContentClient()->browser()->
|
||||
SupportsBrowserPlugin(browser_context, site_);
|
||||
process_ =
|
||||
new RenderProcessHostImpl(browser_context, partition,
|
||||
supports_browser_plugin,
|
||||
site_.SchemeIs(chrome::kGuestScheme));
|
||||
}
|
||||
}
|
||||
|
@ -246,6 +246,11 @@ BrowserPpapiHost*
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool ContentBrowserClient::SupportsBrowserPlugin(
|
||||
BrowserContext* browser_context, const GURL& site_url) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ContentBrowserClient::AllowPepperSocketAPI(
|
||||
BrowserContext* browser_context,
|
||||
const GURL& url,
|
||||
|
@ -478,6 +478,11 @@ class CONTENT_EXPORT ContentBrowserClient {
|
||||
virtual content::BrowserPpapiHost* GetExternalBrowserPpapiHost(
|
||||
int plugin_child_id);
|
||||
|
||||
// Returns true if the given browser_context and site_url support hosting
|
||||
// BrowserPlugins.
|
||||
virtual bool SupportsBrowserPlugin(BrowserContext* browser_context,
|
||||
const GURL& site_url);
|
||||
|
||||
// Returns true if renderer processes can use Pepper TCP/UDP sockets from
|
||||
// the given origin and connection type.
|
||||
virtual bool AllowPepperSocketAPI(BrowserContext* browser_context,
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include "content/public/browser/render_process_host.h"
|
||||
#include "content/public/browser/resource_dispatcher_host.h"
|
||||
#include "content/public/browser/storage_partition.h"
|
||||
#include "content/public/common/content_switches.h"
|
||||
#include "content/shell/geolocation/shell_access_token_store.h"
|
||||
#include "content/shell/shell.h"
|
||||
#include "content/shell/shell_browser_context.h"
|
||||
@ -160,6 +161,12 @@ std::string ShellContentBrowserClient::GetDefaultDownloadName() {
|
||||
return "download";
|
||||
}
|
||||
|
||||
bool ShellContentBrowserClient::SupportsBrowserPlugin(
|
||||
content::BrowserContext* browser_context, const GURL& url) {
|
||||
return CommandLine::ForCurrentProcess()->HasSwitch(
|
||||
switches::kEnableBrowserPluginForAllViewTypes);
|
||||
}
|
||||
|
||||
WebContentsViewDelegate* ShellContentBrowserClient::GetWebContentsViewDelegate(
|
||||
WebContents* web_contents) {
|
||||
#if !defined(USE_AURA)
|
||||
|
@ -44,6 +44,8 @@ class ShellContentBrowserClient : public ContentBrowserClient {
|
||||
virtual void ResourceDispatcherHostCreated() OVERRIDE;
|
||||
virtual AccessTokenStore* CreateAccessTokenStore() OVERRIDE;
|
||||
virtual std::string GetDefaultDownloadName() OVERRIDE;
|
||||
virtual bool SupportsBrowserPlugin(content::BrowserContext* browser_context,
|
||||
const GURL& url) OVERRIDE;
|
||||
virtual WebContentsViewDelegate* GetWebContentsViewDelegate(
|
||||
WebContents* web_contents) OVERRIDE;
|
||||
|
||||
|
Reference in New Issue
Block a user