From d8415ad900d21b08c678bc7b06b2e81581311f71 Mon Sep 17 00:00:00 2001 From: "bauerb@chromium.org" Date: Thu, 23 Aug 2012 14:40:50 +0000 Subject: Add hooks to content to request permission to connect to the PPAPI broker. BUG=142639 TEST=browser_tests:PPAPITest.Broker Review URL: https://chromiumcodereview.appspot.com/10854040 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@152991 0039d316-1c4b-4281-b951-d872f2087c98 --- webkit/plugins/ppapi/plugin_delegate.h | 6 ++---- webkit/plugins/ppapi/ppb_broker_impl.cc | 8 ++++++++ webkit/plugins/ppapi/ppb_broker_impl.h | 4 ++++ 3 files changed, 14 insertions(+), 4 deletions(-) (limited to 'webkit') diff --git a/webkit/plugins/ppapi/plugin_delegate.h b/webkit/plugins/ppapi/plugin_delegate.h index 7418070..3e75cc5 100644 --- a/webkit/plugins/ppapi/plugin_delegate.h +++ b/webkit/plugins/ppapi/plugin_delegate.h @@ -299,12 +299,10 @@ class PluginDelegate { // Provides access to the ppapi broker. class Broker { public: - virtual void Connect(webkit::ppapi::PPB_Broker_Impl* client) = 0; - // Decrements the references to the broker. // When there are no more references, this renderer's dispatcher is // destroyed, allowing the broker to shutdown if appropriate. - // Callers should not reference this object after calling Disconnect. + // Callers should not reference this object after calling Disconnect(). virtual void Disconnect(webkit::ppapi::PPB_Broker_Impl* client) = 0; protected: @@ -404,7 +402,7 @@ class PluginDelegate { // A pointer is returned immediately, but it is not ready to be used until // BrokerConnected has been called. - // The caller is responsible for calling Release() on the returned pointer + // The caller is responsible for calling Disconnect() on the returned pointer // to clean up the corresponding resources allocated during this call. virtual Broker* ConnectToBroker(webkit::ppapi::PPB_Broker_Impl* client) = 0; diff --git a/webkit/plugins/ppapi/ppb_broker_impl.cc b/webkit/plugins/ppapi/ppb_broker_impl.cc index 2386e0d..49342fc 100644 --- a/webkit/plugins/ppapi/ppb_broker_impl.cc +++ b/webkit/plugins/ppapi/ppb_broker_impl.cc @@ -6,6 +6,9 @@ #include "base/logging.h" #include "ppapi/shared_impl/platform_file.h" +#include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" +#include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h" +#include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginContainer.h" #include "webkit/plugins/ppapi/common.h" #include "webkit/plugins/ppapi/plugin_module.h" #include "webkit/plugins/ppapi/resource_helper.h" @@ -75,6 +78,11 @@ int32_t PPB_Broker_Impl::GetHandle(int32_t* handle) { return PP_OK; } +GURL PPB_Broker_Impl::GetDocumentUrl() { + PluginInstance* plugin_instance = ResourceHelper::GetPluginInstance(this); + return plugin_instance->container()->element().document().url(); +} + // Transfers ownership of the handle to the plugin. void PPB_Broker_Impl::BrokerConnected(int32_t handle, int32_t result) { DCHECK(pipe_handle_ == diff --git a/webkit/plugins/ppapi/ppb_broker_impl.h b/webkit/plugins/ppapi/ppb_broker_impl.h index 6799c4f..ab02ae8 100644 --- a/webkit/plugins/ppapi/ppb_broker_impl.h +++ b/webkit/plugins/ppapi/ppb_broker_impl.h @@ -36,6 +36,10 @@ class WEBKIT_PLUGINS_EXPORT PPB_Broker_Impl scoped_refptr< ::ppapi::TrackedCallback> connect_callback) OVERRIDE; virtual int32_t GetHandle(int32_t* handle) OVERRIDE; + // Returns the URL of the document this plug-in runs in. This is necessary to + // decide whether to grant access to the PPAPI broker. + GURL GetDocumentUrl(); + void BrokerConnected(int32_t handle, int32_t result); private: -- cgit v1.1