summaryrefslogtreecommitdiffstats
path: root/ppapi
diff options
context:
space:
mode:
authorpiman@google.com <piman@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-31 21:46:45 +0000
committerpiman@google.com <piman@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-31 21:46:45 +0000
commit087ce7477bfbc656e7ce8931d6036b7b179f85b8 (patch)
treef3a8d4f9eb41bb7ca9f7fc373d9df9603a1fc5d6 /ppapi
parent4a4546fb749ca2e205b318bb68bcdf3baeb2213e (diff)
downloadchromium_src-087ce7477bfbc656e7ce8931d6036b7b179f85b8.zip
chromium_src-087ce7477bfbc656e7ce8931d6036b7b179f85b8.tar.gz
chromium_src-087ce7477bfbc656e7ce8931d6036b7b179f85b8.tar.bz2
Add GetPluginURL to PPB_URLUtil_Dev
BUG=chromium-os:13693 TEST=http://www.ford.com/cars/taurus/ with pepper flash Review URL: http://codereview.chromium.org/6740013 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@80085 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi')
-rw-r--r--ppapi/c/dev/ppb_url_util_dev.h13
-rw-r--r--ppapi/cpp/dev/url_util_dev.cc7
-rw-r--r--ppapi/cpp/dev/url_util_dev.h3
-rw-r--r--ppapi/proxy/ppapi_messages.h3
-rw-r--r--ppapi/proxy/ppb_url_util_proxy.cc23
-rw-r--r--ppapi/proxy/ppb_url_util_proxy.h2
-rw-r--r--ppapi/tests/test_case.html1
-rw-r--r--ppapi/tests/test_url_util.cc9
-rw-r--r--ppapi/tests/test_url_util.h1
9 files changed, 60 insertions, 2 deletions
diff --git a/ppapi/c/dev/ppb_url_util_dev.h b/ppapi/c/dev/ppb_url_util_dev.h
index 2cdad5f..8a79bb1 100644
--- a/ppapi/c/dev/ppb_url_util_dev.h
+++ b/ppapi/c/dev/ppb_url_util_dev.h
@@ -11,7 +11,7 @@
#include "ppapi/c/pp_stdint.h"
#include "ppapi/c/pp_var.h"
-#define PPB_URLUTIL_DEV_INTERFACE "PPB_URLUtil(Dev);0.5"
+#define PPB_URLUTIL_DEV_INTERFACE "PPB_URLUtil(Dev);0.6"
// A component specifies the range of the part of the URL. The begin specifies
// the index into the string of the first character of that component. The len
@@ -117,6 +117,17 @@ struct PPB_URLUtil_Dev {
// to specify that no component information is necessary.
struct PP_Var (*GetDocumentURL)(PP_Instance instance,
struct PP_URLComponents_Dev* components);
+
+ // Returns the Source URL for the plugin. This returns the URL that would be
+ // streamed to the plugin if it were a NPAPI plugin. This is usually the src
+ // attribute on the <embed> element, but the rules are obscure and different
+ // based on whether the plugin is loaded from an <embed> element or an
+ // <object> element.
+ // 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 (*GetPluginInstanceURL)(
+ PP_Instance instance, struct PP_URLComponents_Dev* components);
};
#endif /* PPAPI_C_DEV_PPB_URL_UTIL_DEV_H_ */
diff --git a/ppapi/cpp/dev/url_util_dev.cc b/ppapi/cpp/dev/url_util_dev.cc
index d61c5f2..dad5da16 100644
--- a/ppapi/cpp/dev/url_util_dev.cc
+++ b/ppapi/cpp/dev/url_util_dev.cc
@@ -76,4 +76,11 @@ Var URLUtil_Dev::GetDocumentURL(const Instance& instance,
interface_->GetDocumentURL(instance.pp_instance(), components));
}
+Var URLUtil_Dev::GetPluginInstanceURL(const Instance& instance,
+ PP_URLComponents_Dev* components) const {
+ return Var(Var::PassRef(),
+ interface_->GetPluginInstanceURL(instance.pp_instance(),
+ components));
+}
+
} // namespace pp
diff --git a/ppapi/cpp/dev/url_util_dev.h b/ppapi/cpp/dev/url_util_dev.h
index aa9e2fd3..02f6276 100644
--- a/ppapi/cpp/dev/url_util_dev.h
+++ b/ppapi/cpp/dev/url_util_dev.h
@@ -40,6 +40,9 @@ class URLUtil_Dev {
Var GetDocumentURL(const Instance& instance,
PP_URLComponents_Dev* components = NULL) const;
+ Var GetPluginInstanceURL(const Instance& instance,
+ PP_URLComponents_Dev* components = NULL) const;
+
private:
URLUtil_Dev() : interface_(NULL) {}
diff --git a/ppapi/proxy/ppapi_messages.h b/ppapi/proxy/ppapi_messages.h
index d40c5a46..fad4e8b 100644
--- a/ppapi/proxy/ppapi_messages.h
+++ b/ppapi/proxy/ppapi_messages.h
@@ -689,6 +689,9 @@ IPC_SYNC_MESSAGE_ROUTED2_1(PpapiHostMsg_PPBURLUtil_DocumentCanAccessDocument,
IPC_SYNC_MESSAGE_ROUTED1_1(PpapiHostMsg_PPBURLUtil_GetDocumentURL,
PP_Instance /* active */,
pp::proxy::SerializedVar /* result */)
+IPC_SYNC_MESSAGE_ROUTED1_1(PpapiHostMsg_PPBURLUtil_GetPluginInstanceURL,
+ PP_Instance /* active */,
+ pp::proxy::SerializedVar /* result */)
// PPB_Var.
IPC_MESSAGE_ROUTED1(PpapiHostMsg_PPBVar_AddRefObject,
diff --git a/ppapi/proxy/ppb_url_util_proxy.cc b/ppapi/proxy/ppb_url_util_proxy.cc
index bcff053..17b36ea 100644
--- a/ppapi/proxy/ppb_url_util_proxy.cc
+++ b/ppapi/proxy/ppb_url_util_proxy.cc
@@ -120,6 +120,18 @@ PP_Var GetDocumentURL(PP_Instance instance,
return ConvertComponentsAndReturnURL(result.Return(dispatcher), components);
}
+PP_Var GetPluginInstanceURL(PP_Instance instance,
+ struct PP_URLComponents_Dev* components) {
+ PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance);
+ if (!dispatcher)
+ return PP_MakeNull();
+
+ ReceiveSerializedVarReturnValue result;
+ dispatcher->Send(new PpapiHostMsg_PPBURLUtil_GetPluginInstanceURL(
+ INTERFACE_ID_PPB_URL_UTIL, instance, &result));
+ return ConvertComponentsAndReturnURL(result.Return(dispatcher), components);
+}
+
const PPB_URLUtil_Dev url_util_interface = {
&Canonicalize,
&ResolveRelativeToURL,
@@ -127,7 +139,8 @@ const PPB_URLUtil_Dev url_util_interface = {
&IsSameSecurityOrigin,
&DocumentCanRequest,
&DocumentCanAccessDocument,
- &GetDocumentURL
+ &GetDocumentURL,
+ &GetPluginInstanceURL
};
InterfaceProxy* CreateURLUtilProxy(Dispatcher* dispatcher,
@@ -168,6 +181,8 @@ bool PPB_URLUtil_Proxy::OnMessageReceived(const IPC::Message& msg) {
OnMsgDocumentCanAccessDocument)
IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBURLUtil_GetDocumentURL,
OnMsgGetDocumentURL)
+ IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBURLUtil_GetPluginInstanceURL,
+ OnMsgGetPluginInstanceURL)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
return handled;
@@ -202,6 +217,12 @@ void PPB_URLUtil_Proxy::OnMsgGetDocumentURL(PP_Instance instance,
ppb_url_util_target()->GetDocumentURL(instance, NULL));
}
+void PPB_URLUtil_Proxy::OnMsgGetPluginInstanceURL(
+ PP_Instance instance, SerializedVarReturnValue result) {
+ result.Return(dispatcher(),
+ ppb_url_util_target()->GetPluginInstanceURL(instance, NULL));
+}
+
} // namespace proxy
} // namespace pp
diff --git a/ppapi/proxy/ppb_url_util_proxy.h b/ppapi/proxy/ppb_url_util_proxy.h
index 2d4e001..548d2ef 100644
--- a/ppapi/proxy/ppb_url_util_proxy.h
+++ b/ppapi/proxy/ppb_url_util_proxy.h
@@ -41,6 +41,8 @@ class PPB_URLUtil_Proxy : public InterfaceProxy {
PP_Bool* result);
void OnMsgGetDocumentURL(PP_Instance instance,
SerializedVarReturnValue result);
+ void OnMsgGetPluginInstanceURL(PP_Instance instance,
+ SerializedVarReturnValue result);
DISALLOW_COPY_AND_ASSIGN(PPB_URLUtil_Proxy);
};
diff --git a/ppapi/tests/test_case.html b/ppapi/tests/test_case.html
index cae02bf..5fd094c 100644
--- a/ppapi/tests/test_case.html
+++ b/ppapi/tests/test_case.html
@@ -85,6 +85,7 @@ onload = function() {
if (obj) {
obj.setAttribute("id", "plugin");
obj.setAttribute("testcase", testcase);
+ obj.setAttribute("src", "http://a.b.c/test");
document.getElementById("container").appendChild(obj);
}
}
diff --git a/ppapi/tests/test_url_util.cc b/ppapi/tests/test_url_util.cc
index 34de996..964060d 100644
--- a/ppapi/tests/test_url_util.cc
+++ b/ppapi/tests/test_url_util.cc
@@ -27,6 +27,7 @@ void TestURLUtil::RunTest() {
RUN_TEST(DocumentCanRequest);
RUN_TEST(DocumentCanAccessDocument);
RUN_TEST(GetDocumentURL);
+ RUN_TEST(GetPluginInstanceURL);
}
std::string TestURLUtil::TestCanonicalize() {
@@ -127,3 +128,11 @@ std::string TestURLUtil::TestGetDocumentURL() {
ASSERT_EQ(url.AsString(), href.AsString());
PASS();
}
+
+std::string TestURLUtil::TestGetPluginInstanceURL() {
+ pp::Var url = util_->GetPluginInstanceURL(*instance_);
+ ASSERT_TRUE(url.is_string());
+ // see test_case.html
+ ASSERT_EQ(url.AsString(), "http://a.b.c/test");
+ PASS();
+}
diff --git a/ppapi/tests/test_url_util.h b/ppapi/tests/test_url_util.h
index 61516d4..0bb1f3f 100644
--- a/ppapi/tests/test_url_util.h
+++ b/ppapi/tests/test_url_util.h
@@ -23,6 +23,7 @@ class TestURLUtil : public TestCase {
std::string TestDocumentCanRequest();
std::string TestDocumentCanAccessDocument();
std::string TestGetDocumentURL();
+ std::string TestGetPluginInstanceURL();
const pp::URLUtil_Dev* util_;
};