Add GetPluginRefererURL to PPB_URLUtil_Dev interface to get the 'Referer' HTTP...

Add GetPluginRefererURL to PPB_URLUtil_Dev interface to get the 'Referer' HTTP header value that was sent by request that loaded plug-in. 
Sometimes Pepper plug-in needs to create additional HTTP request to its source URL (for example, PDF plug-in downloads parts of the file using HTTP Range requests). These requests will fail for servers that check Referer header (example: http://fs51.www.ex.ua/get/96354baf7547114fa116c56ecdbdb3ee/66511913/FRoziner_Iskusstvo_Ciurlionisa_1993.pdf).

Review URL: https://chromiumcodereview.appspot.com/23444004

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@221920 0039d316-1c4b-4281-b951-d872f2087c98
parent 047f81c7
...@@ -93,6 +93,7 @@ ...@@ -93,6 +93,7 @@
#include "third_party/WebKit/public/web/WebBindings.h" #include "third_party/WebKit/public/web/WebBindings.h"
#include "third_party/WebKit/public/web/WebCompositionUnderline.h" #include "third_party/WebKit/public/web/WebCompositionUnderline.h"
#include "third_party/WebKit/public/web/WebCursorInfo.h" #include "third_party/WebKit/public/web/WebCursorInfo.h"
#include "third_party/WebKit/public/web/WebDataSource.h"
#include "third_party/WebKit/public/web/WebDocument.h" #include "third_party/WebKit/public/web/WebDocument.h"
#include "third_party/WebKit/public/web/WebElement.h" #include "third_party/WebKit/public/web/WebElement.h"
#include "third_party/WebKit/public/web/WebFrame.h" #include "third_party/WebKit/public/web/WebFrame.h"
...@@ -2504,6 +2505,24 @@ PP_Var PepperPluginInstanceImpl::GetPluginInstanceURL( ...@@ -2504,6 +2505,24 @@ PP_Var PepperPluginInstanceImpl::GetPluginInstanceURL(
components); components);
} }
PP_Var PepperPluginInstanceImpl::GetPluginReferrerURL(
PP_Instance instance,
PP_URLComponents_Dev* components) {
WebKit::WebDocument document = container()->element().document();
if (!full_frame_)
return ppapi::PPB_URLUtil_Shared::GenerateURLReturn(document.url(),
components);
WebFrame* frame = document.frame();
if (!frame)
return PP_MakeUndefined();
const WebURLRequest& request = frame->dataSource()->originalRequest();
WebString referer = request.httpHeaderField("Referer");
if (referer.isEmpty())
return PP_MakeUndefined();
return ppapi::PPB_URLUtil_Shared::GenerateURLReturn(GURL(referer),
components);
}
PP_ExternalPluginResult PepperPluginInstanceImpl::ResetAsProxied( PP_ExternalPluginResult PepperPluginInstanceImpl::ResetAsProxied(
scoped_refptr<PluginModule> module) { scoped_refptr<PluginModule> module) {
// Save the original module and switch over to the new one now that this // Save the original module and switch over to the new one now that this
......
...@@ -435,6 +435,9 @@ class CONTENT_EXPORT PepperPluginInstanceImpl ...@@ -435,6 +435,9 @@ class CONTENT_EXPORT PepperPluginInstanceImpl
virtual PP_Var GetPluginInstanceURL( virtual PP_Var GetPluginInstanceURL(
PP_Instance instance, PP_Instance instance,
PP_URLComponents_Dev* components) OVERRIDE; PP_URLComponents_Dev* components) OVERRIDE;
virtual PP_Var GetPluginReferrerURL(
PP_Instance instance,
PP_URLComponents_Dev* components) OVERRIDE;
// PPB_ContentDecryptor_Private implementation. // PPB_ContentDecryptor_Private implementation.
virtual void NeedKey(PP_Instance instance, virtual void NeedKey(PP_Instance instance,
......
...@@ -7,8 +7,11 @@ ...@@ -7,8 +7,11 @@
* This file defines the <code>PPB_URLUtil_Dev</code> interface. * This file defines the <code>PPB_URLUtil_Dev</code> interface.
*/ */
[generate_thunk]
label Chrome { label Chrome {
M17 = 0.6 M17 = 0.6,
M31 = 0.7
}; };
/* /*
...@@ -146,4 +149,16 @@ interface PPB_URLUtil_Dev { ...@@ -146,4 +149,16 @@ interface PPB_URLUtil_Dev {
*/ */
PP_Var GetPluginInstanceURL([in] PP_Instance instance, PP_Var GetPluginInstanceURL([in] PP_Instance instance,
[out] PP_URLComponents_Dev components); [out] PP_URLComponents_Dev components);
/*
* Returns the Referrer URL of the HTTP request that loaded the plugin. This
* is the value of the 'Referer' header of the request. An undefined value
* means the 'Referer' header was absent.
* The components pointer, if non-NULL and the canonicalized URL is valid,
* will identify the components of the resulting URL. Components may be NULL
* to specify that no component information is necessary.
*/
[version=0.7]
PP_Var GetPluginReferrerURL([in] PP_Instance instance,
[out] PP_URLComponents_Dev components);
}; };
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* found in the LICENSE file. * found in the LICENSE file.
*/ */
/* From dev/ppb_url_util_dev.idl modified Fri Dec 16 17:34:59 2011. */ /* From dev/ppb_url_util_dev.idl modified Wed Aug 28 19:09:17 2013. */
#ifndef PPAPI_C_DEV_PPB_URL_UTIL_DEV_H_ #ifndef PPAPI_C_DEV_PPB_URL_UTIL_DEV_H_
#define PPAPI_C_DEV_PPB_URL_UTIL_DEV_H_ #define PPAPI_C_DEV_PPB_URL_UTIL_DEV_H_
...@@ -15,7 +15,8 @@ ...@@ -15,7 +15,8 @@
#include "ppapi/c/pp_var.h" #include "ppapi/c/pp_var.h"
#define PPB_URLUTIL_DEV_INTERFACE_0_6 "PPB_URLUtil(Dev);0.6" #define PPB_URLUTIL_DEV_INTERFACE_0_6 "PPB_URLUtil(Dev);0.6"
#define PPB_URLUTIL_DEV_INTERFACE PPB_URLUTIL_DEV_INTERFACE_0_6 #define PPB_URLUTIL_DEV_INTERFACE_0_7 "PPB_URLUtil(Dev);0.7"
#define PPB_URLUTIL_DEV_INTERFACE PPB_URLUTIL_DEV_INTERFACE_0_7
/** /**
* @file * @file
...@@ -77,7 +78,7 @@ PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_URLComponents_Dev, 64); ...@@ -77,7 +78,7 @@ PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_URLComponents_Dev, 64);
* except for the reference fragment (stuff after the '#') which will be * except for the reference fragment (stuff after the '#') which will be
* encoded as UTF-8. * encoded as UTF-8.
*/ */
struct PPB_URLUtil_Dev_0_6 { struct PPB_URLUtil_Dev_0_7 {
/* /*
* Canonicalizes the given URL string according to the rules of the host * Canonicalizes the given URL string according to the rules of the host
* browser. If the URL is invalid or the var is not a string, this will * browser. If the URL is invalid or the var is not a string, this will
...@@ -163,9 +164,41 @@ struct PPB_URLUtil_Dev_0_6 { ...@@ -163,9 +164,41 @@ struct PPB_URLUtil_Dev_0_6 {
struct PP_Var (*GetPluginInstanceURL)( struct PP_Var (*GetPluginInstanceURL)(
PP_Instance instance, PP_Instance instance,
struct PP_URLComponents_Dev* components); struct PP_URLComponents_Dev* components);
/*
* Returns the Referrer URL of the HTTP request that loaded the plugin. This
* is the value of the 'Referer' header of the request. An undefined value
* means the 'Referer' header was absent.
* The components pointer, if non-NULL and the canonicalized URL is valid,
* will identify the components of the resulting URL. Components may be NULL
* to specify that no component information is necessary.
*/
struct PP_Var (*GetPluginReferrerURL)(
PP_Instance instance,
struct PP_URLComponents_Dev* components);
}; };
typedef struct PPB_URLUtil_Dev_0_6 PPB_URLUtil_Dev; typedef struct PPB_URLUtil_Dev_0_7 PPB_URLUtil_Dev;
struct PPB_URLUtil_Dev_0_6 {
struct PP_Var (*Canonicalize)(struct PP_Var url,
struct PP_URLComponents_Dev* components);
struct PP_Var (*ResolveRelativeToURL)(
struct PP_Var base_url,
struct PP_Var relative_string,
struct PP_URLComponents_Dev* components);
struct PP_Var (*ResolveRelativeToDocument)(
PP_Instance instance,
struct PP_Var relative_string,
struct PP_URLComponents_Dev* components);
PP_Bool (*IsSameSecurityOrigin)(struct PP_Var url_a, struct PP_Var url_b);
PP_Bool (*DocumentCanRequest)(PP_Instance instance, struct PP_Var url);
PP_Bool (*DocumentCanAccessDocument)(PP_Instance active, PP_Instance target);
struct PP_Var (*GetDocumentURL)(PP_Instance instance,
struct PP_URLComponents_Dev* components);
struct PP_Var (*GetPluginInstanceURL)(
PP_Instance instance,
struct PP_URLComponents_Dev* components);
};
/** /**
* @} * @}
*/ */
......
...@@ -82,4 +82,11 @@ Var URLUtil_Dev::GetPluginInstanceURL(const InstanceHandle& instance, ...@@ -82,4 +82,11 @@ Var URLUtil_Dev::GetPluginInstanceURL(const InstanceHandle& instance,
components)); components));
} }
Var URLUtil_Dev::GetPluginReferrerURL(const InstanceHandle& instance,
PP_URLComponents_Dev* components) const {
return Var(PASS_REF,
interface_->GetPluginReferrerURL(instance.pp_instance(),
components));
}
} // namespace pp } // namespace pp
...@@ -41,6 +41,8 @@ class URLUtil_Dev { ...@@ -41,6 +41,8 @@ class URLUtil_Dev {
Var GetPluginInstanceURL(const InstanceHandle& instance, Var GetPluginInstanceURL(const InstanceHandle& instance,
PP_URLComponents_Dev* components = NULL) const; PP_URLComponents_Dev* components = NULL) const;
Var GetPluginReferrerURL(const InstanceHandle& instance,
PP_URLComponents_Dev* components = NULL) const;
private: private:
URLUtil_Dev() : interface_(NULL) {} URLUtil_Dev() : interface_(NULL) {}
......
...@@ -184,6 +184,7 @@ static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_Testing_Dev_0_91; ...@@ -184,6 +184,7 @@ static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_Testing_Dev_0_91;
static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_Testing_Dev_0_92; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_Testing_Dev_0_92;
static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_TrueTypeFont_Dev_0_1; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_TrueTypeFont_Dev_0_1;
static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_URLUtil_Dev_0_6; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_URLUtil_Dev_0_6;
static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_URLUtil_Dev_0_7;
static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_VideoCapture_Dev_0_2; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_VideoCapture_Dev_0_2;
static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_VideoCapture_Dev_0_3; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_VideoCapture_Dev_0_3;
static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_VideoDecoder_Dev_0_16; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_VideoDecoder_Dev_0_16;
...@@ -2069,6 +2070,55 @@ static void Pnacl_M17_PPB_URLUtil_Dev_GetPluginInstanceURL(struct PP_Var* _struc ...@@ -2069,6 +2070,55 @@ static void Pnacl_M17_PPB_URLUtil_Dev_GetPluginInstanceURL(struct PP_Var* _struc
/* End wrapper methods for PPB_URLUtil_Dev_0_6 */ /* End wrapper methods for PPB_URLUtil_Dev_0_6 */
/* Begin wrapper methods for PPB_URLUtil_Dev_0_7 */
static void Pnacl_M31_PPB_URLUtil_Dev_Canonicalize(struct PP_Var* _struct_result, struct PP_Var* url, struct PP_URLComponents_Dev* components) {
const struct PPB_URLUtil_Dev_0_7 *iface = Pnacl_WrapperInfo_PPB_URLUtil_Dev_0_7.real_iface;
*_struct_result = iface->Canonicalize(*url, components);
}
static void Pnacl_M31_PPB_URLUtil_Dev_ResolveRelativeToURL(struct PP_Var* _struct_result, struct PP_Var* base_url, struct PP_Var* relative_string, struct PP_URLComponents_Dev* components) {
const struct PPB_URLUtil_Dev_0_7 *iface = Pnacl_WrapperInfo_PPB_URLUtil_Dev_0_7.real_iface;
*_struct_result = iface->ResolveRelativeToURL(*base_url, *relative_string, components);
}
static void Pnacl_M31_PPB_URLUtil_Dev_ResolveRelativeToDocument(struct PP_Var* _struct_result, PP_Instance instance, struct PP_Var* relative_string, struct PP_URLComponents_Dev* components) {
const struct PPB_URLUtil_Dev_0_7 *iface = Pnacl_WrapperInfo_PPB_URLUtil_Dev_0_7.real_iface;
*_struct_result = iface->ResolveRelativeToDocument(instance, *relative_string, components);
}
static PP_Bool Pnacl_M31_PPB_URLUtil_Dev_IsSameSecurityOrigin(struct PP_Var* url_a, struct PP_Var* url_b) {
const struct PPB_URLUtil_Dev_0_7 *iface = Pnacl_WrapperInfo_PPB_URLUtil_Dev_0_7.real_iface;
return iface->IsSameSecurityOrigin(*url_a, *url_b);
}
static PP_Bool Pnacl_M31_PPB_URLUtil_Dev_DocumentCanRequest(PP_Instance instance, struct PP_Var* url) {
const struct PPB_URLUtil_Dev_0_7 *iface = Pnacl_WrapperInfo_PPB_URLUtil_Dev_0_7.real_iface;
return iface->DocumentCanRequest(instance, *url);
}
static PP_Bool Pnacl_M31_PPB_URLUtil_Dev_DocumentCanAccessDocument(PP_Instance active, PP_Instance target) {
const struct PPB_URLUtil_Dev_0_7 *iface = Pnacl_WrapperInfo_PPB_URLUtil_Dev_0_7.real_iface;
return iface->DocumentCanAccessDocument(active, target);
}
static void Pnacl_M31_PPB_URLUtil_Dev_GetDocumentURL(struct PP_Var* _struct_result, PP_Instance instance, struct PP_URLComponents_Dev* components) {
const struct PPB_URLUtil_Dev_0_7 *iface = Pnacl_WrapperInfo_PPB_URLUtil_Dev_0_7.real_iface;
*_struct_result = iface->GetDocumentURL(instance, components);
}
static void Pnacl_M31_PPB_URLUtil_Dev_GetPluginInstanceURL(struct PP_Var* _struct_result, PP_Instance instance, struct PP_URLComponents_Dev* components) {
const struct PPB_URLUtil_Dev_0_7 *iface = Pnacl_WrapperInfo_PPB_URLUtil_Dev_0_7.real_iface;
*_struct_result = iface->GetPluginInstanceURL(instance, components);
}
static void Pnacl_M31_PPB_URLUtil_Dev_GetPluginReferrerURL(struct PP_Var* _struct_result, PP_Instance instance, struct PP_URLComponents_Dev* components) {
const struct PPB_URLUtil_Dev_0_7 *iface = Pnacl_WrapperInfo_PPB_URLUtil_Dev_0_7.real_iface;
*_struct_result = iface->GetPluginReferrerURL(instance, components);
}
/* End wrapper methods for PPB_URLUtil_Dev_0_7 */
/* Begin wrapper methods for PPB_VideoCapture_Dev_0_2 */ /* Begin wrapper methods for PPB_VideoCapture_Dev_0_2 */
static PP_Resource Pnacl_M19_PPB_VideoCapture_Dev_Create(PP_Instance instance) { static PP_Resource Pnacl_M19_PPB_VideoCapture_Dev_Create(PP_Instance instance) {
...@@ -4476,6 +4526,18 @@ struct PPB_URLUtil_Dev_0_6 Pnacl_Wrappers_PPB_URLUtil_Dev_0_6 = { ...@@ -4476,6 +4526,18 @@ struct PPB_URLUtil_Dev_0_6 Pnacl_Wrappers_PPB_URLUtil_Dev_0_6 = {
.GetPluginInstanceURL = (struct PP_Var (*)(PP_Instance instance, struct PP_URLComponents_Dev* components))&Pnacl_M17_PPB_URLUtil_Dev_GetPluginInstanceURL .GetPluginInstanceURL = (struct PP_Var (*)(PP_Instance instance, struct PP_URLComponents_Dev* components))&Pnacl_M17_PPB_URLUtil_Dev_GetPluginInstanceURL
}; };
struct PPB_URLUtil_Dev_0_7 Pnacl_Wrappers_PPB_URLUtil_Dev_0_7 = {
.Canonicalize = (struct PP_Var (*)(struct PP_Var url, struct PP_URLComponents_Dev* components))&Pnacl_M31_PPB_URLUtil_Dev_Canonicalize,
.ResolveRelativeToURL = (struct PP_Var (*)(struct PP_Var base_url, struct PP_Var relative_string, struct PP_URLComponents_Dev* components))&Pnacl_M31_PPB_URLUtil_Dev_ResolveRelativeToURL,
.ResolveRelativeToDocument = (struct PP_Var (*)(PP_Instance instance, struct PP_Var relative_string, struct PP_URLComponents_Dev* components))&Pnacl_M31_PPB_URLUtil_Dev_ResolveRelativeToDocument,
.IsSameSecurityOrigin = (PP_Bool (*)(struct PP_Var url_a, struct PP_Var url_b))&Pnacl_M31_PPB_URLUtil_Dev_IsSameSecurityOrigin,
.DocumentCanRequest = (PP_Bool (*)(PP_Instance instance, struct PP_Var url))&Pnacl_M31_PPB_URLUtil_Dev_DocumentCanRequest,
.DocumentCanAccessDocument = (PP_Bool (*)(PP_Instance active, PP_Instance target))&Pnacl_M31_PPB_URLUtil_Dev_DocumentCanAccessDocument,
.GetDocumentURL = (struct PP_Var (*)(PP_Instance instance, struct PP_URLComponents_Dev* components))&Pnacl_M31_PPB_URLUtil_Dev_GetDocumentURL,
.GetPluginInstanceURL = (struct PP_Var (*)(PP_Instance instance, struct PP_URLComponents_Dev* components))&Pnacl_M31_PPB_URLUtil_Dev_GetPluginInstanceURL,
.GetPluginReferrerURL = (struct PP_Var (*)(PP_Instance instance, struct PP_URLComponents_Dev* components))&Pnacl_M31_PPB_URLUtil_Dev_GetPluginReferrerURL
};
struct PPB_VideoCapture_Dev_0_2 Pnacl_Wrappers_PPB_VideoCapture_Dev_0_2 = { struct PPB_VideoCapture_Dev_0_2 Pnacl_Wrappers_PPB_VideoCapture_Dev_0_2 = {
.Create = (PP_Resource (*)(PP_Instance instance))&Pnacl_M19_PPB_VideoCapture_Dev_Create, .Create = (PP_Resource (*)(PP_Instance instance))&Pnacl_M19_PPB_VideoCapture_Dev_Create,
.IsVideoCapture = (PP_Bool (*)(PP_Resource video_capture))&Pnacl_M19_PPB_VideoCapture_Dev_IsVideoCapture, .IsVideoCapture = (PP_Bool (*)(PP_Resource video_capture))&Pnacl_M19_PPB_VideoCapture_Dev_IsVideoCapture,
...@@ -5282,6 +5344,12 @@ static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_URLUtil_Dev_0_6 = { ...@@ -5282,6 +5344,12 @@ static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_URLUtil_Dev_0_6 = {
.real_iface = NULL .real_iface = NULL
}; };
static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_URLUtil_Dev_0_7 = {
.iface_macro = PPB_URLUTIL_DEV_INTERFACE_0_7,
.wrapped_iface = (void *) &Pnacl_Wrappers_PPB_URLUtil_Dev_0_7,
.real_iface = NULL
};
static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_VideoCapture_Dev_0_2 = { static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_VideoCapture_Dev_0_2 = {
.iface_macro = PPB_VIDEOCAPTURE_DEV_INTERFACE_0_2, .iface_macro = PPB_VIDEOCAPTURE_DEV_INTERFACE_0_2,
.wrapped_iface = (void *) &Pnacl_Wrappers_PPB_VideoCapture_Dev_0_2, .wrapped_iface = (void *) &Pnacl_Wrappers_PPB_VideoCapture_Dev_0_2,
...@@ -5608,6 +5676,7 @@ static struct __PnaclWrapperInfo *s_ppb_wrappers[] = { ...@@ -5608,6 +5676,7 @@ static struct __PnaclWrapperInfo *s_ppb_wrappers[] = {
&Pnacl_WrapperInfo_PPB_Testing_Dev_0_92, &Pnacl_WrapperInfo_PPB_Testing_Dev_0_92,
&Pnacl_WrapperInfo_PPB_TrueTypeFont_Dev_0_1, &Pnacl_WrapperInfo_PPB_TrueTypeFont_Dev_0_1,
&Pnacl_WrapperInfo_PPB_URLUtil_Dev_0_6, &Pnacl_WrapperInfo_PPB_URLUtil_Dev_0_6,
&Pnacl_WrapperInfo_PPB_URLUtil_Dev_0_7,
&Pnacl_WrapperInfo_PPB_VideoCapture_Dev_0_2, &Pnacl_WrapperInfo_PPB_VideoCapture_Dev_0_2,
&Pnacl_WrapperInfo_PPB_VideoCapture_Dev_0_3, &Pnacl_WrapperInfo_PPB_VideoCapture_Dev_0_3,
&Pnacl_WrapperInfo_PPB_VideoDecoder_Dev_0_16, &Pnacl_WrapperInfo_PPB_VideoDecoder_Dev_0_16,
......
...@@ -936,6 +936,9 @@ IPC_SYNC_MESSAGE_ROUTED1_2(PpapiHostMsg_PPBInstance_GetDocumentURL, ...@@ -936,6 +936,9 @@ IPC_SYNC_MESSAGE_ROUTED1_2(PpapiHostMsg_PPBInstance_GetDocumentURL,
IPC_SYNC_MESSAGE_ROUTED1_1(PpapiHostMsg_PPBInstance_GetPluginInstanceURL, IPC_SYNC_MESSAGE_ROUTED1_1(PpapiHostMsg_PPBInstance_GetPluginInstanceURL,
PP_Instance /* active */, PP_Instance /* active */,
ppapi::proxy::SerializedVar /* result */) ppapi::proxy::SerializedVar /* result */)
IPC_SYNC_MESSAGE_ROUTED1_1(PpapiHostMsg_PPBInstance_GetPluginReferrerURL,
PP_Instance /* instance */,
ppapi::proxy::SerializedVar /* result */)
IPC_MESSAGE_ROUTED4(PpapiHostMsg_PPBInstance_SetCursor, IPC_MESSAGE_ROUTED4(PpapiHostMsg_PPBInstance_SetCursor,
PP_Instance /* instance */, PP_Instance /* instance */,
int32_t /* type */, int32_t /* type */,
......
...@@ -173,6 +173,8 @@ bool PPB_Instance_Proxy::OnMessageReceived(const IPC::Message& msg) { ...@@ -173,6 +173,8 @@ bool PPB_Instance_Proxy::OnMessageReceived(const IPC::Message& msg) {
OnHostMsgDocumentCanAccessDocument) OnHostMsgDocumentCanAccessDocument)
IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_GetPluginInstanceURL, IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_GetPluginInstanceURL,
OnHostMsgGetPluginInstanceURL) OnHostMsgGetPluginInstanceURL)
IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_GetPluginReferrerURL,
OnHostMsgGetPluginReferrerURL)
IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_NeedKey, IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_NeedKey,
OnHostMsgNeedKey) OnHostMsgNeedKey)
IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_KeyAdded, IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_KeyAdded,
...@@ -526,6 +528,17 @@ PP_Var PPB_Instance_Proxy::GetPluginInstanceURL( ...@@ -526,6 +528,17 @@ PP_Var PPB_Instance_Proxy::GetPluginInstanceURL(
components); components);
} }
PP_Var PPB_Instance_Proxy::GetPluginReferrerURL(
PP_Instance instance,
PP_URLComponents_Dev* components) {
ReceiveSerializedVarReturnValue result;
dispatcher()->Send(new PpapiHostMsg_PPBInstance_GetPluginReferrerURL(
API_ID_PPB_INSTANCE, instance, &result));
return PPB_URLUtil_Shared::ConvertComponentsAndReturnURL(
result.Return(dispatcher()),
components);
}
void PPB_Instance_Proxy::NeedKey(PP_Instance instance, void PPB_Instance_Proxy::NeedKey(PP_Instance instance,
PP_Var key_system, PP_Var key_system,
PP_Var session_id, PP_Var session_id,
...@@ -1032,6 +1045,18 @@ void PPB_Instance_Proxy::OnHostMsgGetPluginInstanceURL( ...@@ -1032,6 +1045,18 @@ void PPB_Instance_Proxy::OnHostMsgGetPluginInstanceURL(
} }
} }
void PPB_Instance_Proxy::OnHostMsgGetPluginReferrerURL(
PP_Instance instance,
SerializedVarReturnValue result) {
if (!dispatcher()->permissions().HasPermission(PERMISSION_DEV))
return;
EnterInstanceNoLock enter(instance);
if (enter.succeeded()) {
result.Return(dispatcher(),
enter.functions()->GetPluginReferrerURL(instance, NULL));
}
}
void PPB_Instance_Proxy::OnHostMsgNeedKey(PP_Instance instance, void PPB_Instance_Proxy::OnHostMsgNeedKey(PP_Instance instance,
SerializedVarReceiveInput key_system, SerializedVarReceiveInput key_system,
SerializedVarReceiveInput session_id, SerializedVarReceiveInput session_id,
......
...@@ -114,6 +114,9 @@ class PPB_Instance_Proxy : public InterfaceProxy, ...@@ -114,6 +114,9 @@ class PPB_Instance_Proxy : public InterfaceProxy,
virtual PP_Var GetPluginInstanceURL( virtual PP_Var GetPluginInstanceURL(
PP_Instance instance, PP_Instance instance,
PP_URLComponents_Dev* components) OVERRIDE; PP_URLComponents_Dev* components) OVERRIDE;
virtual PP_Var GetPluginReferrerURL(
PP_Instance instance,
PP_URLComponents_Dev* components) OVERRIDE;
virtual void NeedKey(PP_Instance instance, virtual void NeedKey(PP_Instance instance,
PP_Var key_system, PP_Var key_system,
PP_Var session_id, PP_Var session_id,
...@@ -218,6 +221,8 @@ class PPB_Instance_Proxy : public InterfaceProxy, ...@@ -218,6 +221,8 @@ class PPB_Instance_Proxy : public InterfaceProxy,
PP_Bool* result); PP_Bool* result);
void OnHostMsgGetPluginInstanceURL(PP_Instance instance, void OnHostMsgGetPluginInstanceURL(PP_Instance instance,
SerializedVarReturnValue result); SerializedVarReturnValue result);
void OnHostMsgGetPluginReferrerURL(PP_Instance instance,
SerializedVarReturnValue result);
virtual void OnHostMsgNeedKey(PP_Instance instance, virtual void OnHostMsgNeedKey(PP_Instance instance,
SerializedVarReceiveInput key_system, SerializedVarReceiveInput key_system,
SerializedVarReceiveInput session_id, SerializedVarReceiveInput session_id,
......
...@@ -28,6 +28,7 @@ void TestURLUtil::RunTests(const std::string& filter) { ...@@ -28,6 +28,7 @@ void TestURLUtil::RunTests(const std::string& filter) {
RUN_TEST(DocumentCanAccessDocument, filter); RUN_TEST(DocumentCanAccessDocument, filter);
RUN_TEST(GetDocumentURL, filter); RUN_TEST(GetDocumentURL, filter);
RUN_TEST(GetPluginInstanceURL, filter); RUN_TEST(GetPluginInstanceURL, filter);
RUN_TEST(GetPluginReferrerURL, filter);
} }
std::string TestURLUtil::TestCanonicalize() { std::string TestURLUtil::TestCanonicalize() {
...@@ -136,3 +137,14 @@ std::string TestURLUtil::TestGetPluginInstanceURL() { ...@@ -136,3 +137,14 @@ std::string TestURLUtil::TestGetPluginInstanceURL() {
ASSERT_EQ(url.AsString(), "http://a.b.c/test"); ASSERT_EQ(url.AsString(), "http://a.b.c/test");
PASS(); PASS();
} }
std::string TestURLUtil::TestGetPluginReferrerURL() {
pp::Var url = util_->GetPluginReferrerURL(instance_);
ASSERT_TRUE(url.is_string());
pp::VarPrivate window = instance_->GetWindowObject();
pp::Var href = window.GetProperty("location").GetProperty("href");
ASSERT_TRUE(href.is_string());
ASSERT_EQ(url.AsString(), href.AsString());
PASS();
}
...@@ -24,6 +24,7 @@ class TestURLUtil : public TestCase { ...@@ -24,6 +24,7 @@ class TestURLUtil : public TestCase {
std::string TestDocumentCanAccessDocument(); std::string TestDocumentCanAccessDocument();
std::string TestGetDocumentURL(); std::string TestGetDocumentURL();
std::string TestGetPluginInstanceURL(); std::string TestGetPluginInstanceURL();
std::string TestGetPluginReferrerURL();
const pp::URLUtil_Dev* util_; const pp::URLUtil_Dev* util_;
}; };
......
...@@ -68,6 +68,7 @@ PROXIED_IFACE(NoAPIName, PPB_GRAPHICS2D_DEV_INTERFACE_0_1, ...@@ -68,6 +68,7 @@ PROXIED_IFACE(NoAPIName, PPB_GRAPHICS2D_DEV_INTERFACE_0_1,
PPB_Graphics2D_Dev_0_1) PPB_Graphics2D_Dev_0_1)
PROXIED_IFACE(PPB_Instance, PPB_CHAR_SET_DEV_INTERFACE_0_4, PPB_CharSet_Dev_0_4) PROXIED_IFACE(PPB_Instance, PPB_CHAR_SET_DEV_INTERFACE_0_4, PPB_CharSet_Dev_0_4)
PROXIED_IFACE(PPB_Instance, PPB_URLUTIL_DEV_INTERFACE_0_6, PPB_URLUtil_Dev_0_6) PROXIED_IFACE(PPB_Instance, PPB_URLUTIL_DEV_INTERFACE_0_6, PPB_URLUtil_Dev_0_6)
PROXIED_IFACE(PPB_Instance, PPB_URLUTIL_DEV_INTERFACE_0_7, PPB_URLUtil_Dev_0_7)
UNPROXIED_IFACE(PPB_Scrollbar, PPB_SCROLLBAR_DEV_INTERFACE_0_5, UNPROXIED_IFACE(PPB_Scrollbar, PPB_SCROLLBAR_DEV_INTERFACE_0_5,
PPB_Scrollbar_Dev_0_5) PPB_Scrollbar_Dev_0_5)
PROXIED_IFACE(PPB_Instance, PPB_TEXTINPUT_DEV_INTERFACE_0_1, PROXIED_IFACE(PPB_Instance, PPB_TEXTINPUT_DEV_INTERFACE_0_1,
......
...@@ -189,6 +189,8 @@ class PPB_Instance_API { ...@@ -189,6 +189,8 @@ class PPB_Instance_API {
PP_Instance target) = 0; PP_Instance target) = 0;
virtual PP_Var GetPluginInstanceURL(PP_Instance instance, virtual PP_Var GetPluginInstanceURL(PP_Instance instance,
PP_URLComponents_Dev* components) = 0; PP_URLComponents_Dev* components) = 0;
virtual PP_Var GetPluginReferrerURL(PP_Instance instance,
PP_URLComponents_Dev* components) = 0;
#endif // !defined(OS_NACL) #endif // !defined(OS_NACL)
static const ApiID kApiID = API_ID_PPB_INSTANCE; static const ApiID kApiID = API_ID_PPB_INSTANCE;
......
...@@ -53,7 +53,15 @@ PP_Var GetPluginInstanceURL(PP_Instance instance, ...@@ -53,7 +53,15 @@ PP_Var GetPluginInstanceURL(PP_Instance instance,
return enter.functions()->GetPluginInstanceURL(instance, components); return enter.functions()->GetPluginInstanceURL(instance, components);
} }
const PPB_URLUtil_Dev g_ppb_url_util = { PP_Var GetPluginReferrerURL(PP_Instance instance,
PP_URLComponents_Dev* components) {
EnterInstance enter(instance);
if (enter.failed())
return PP_MakeUndefined();
return enter.functions()->GetPluginReferrerURL(instance, components);
}
const PPB_URLUtil_Dev_0_6 g_ppb_url_util_0_6 = {
&PPB_URLUtil_Shared::Canonicalize, &PPB_URLUtil_Shared::Canonicalize,
&PPB_URLUtil_Shared::ResolveRelativeToURL, &PPB_URLUtil_Shared::ResolveRelativeToURL,
&ResolveRelativeToDocument, &ResolveRelativeToDocument,
...@@ -64,10 +72,26 @@ const PPB_URLUtil_Dev g_ppb_url_util = { ...@@ -64,10 +72,26 @@ const PPB_URLUtil_Dev g_ppb_url_util = {
&GetPluginInstanceURL &GetPluginInstanceURL
}; };
const PPB_URLUtil_Dev_0_7 g_ppb_url_util_0_7 = {
&PPB_URLUtil_Shared::Canonicalize,
&PPB_URLUtil_Shared::ResolveRelativeToURL,
&ResolveRelativeToDocument,
&PPB_URLUtil_Shared::IsSameSecurityOrigin,
&DocumentCanRequest,
&DocumentCanAccessDocument,
&GetDocumentURL,
&GetPluginInstanceURL,
&GetPluginReferrerURL
};
} // namespace } // namespace
const PPB_URLUtil_Dev_0_6* GetPPB_URLUtil_Dev_0_6_Thunk() { const PPB_URLUtil_Dev_0_6* GetPPB_URLUtil_Dev_0_6_Thunk() {
return &g_ppb_url_util; return &g_ppb_url_util_0_6;
}
const PPB_URLUtil_Dev_0_7* GetPPB_URLUtil_Dev_0_7_Thunk() {
return &g_ppb_url_util_0_7;
} }
} // namespace thunk } // namespace thunk
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment