summaryrefslogtreecommitdiffstats
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
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
-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
-rw-r--r--webkit/plugins/ppapi/ppapi_plugin_instance.cc2
-rw-r--r--webkit/plugins/ppapi/ppapi_plugin_instance.h6
-rw-r--r--webkit/plugins/ppapi/ppapi_webplugin_impl.cc4
-rw-r--r--webkit/plugins/ppapi/ppb_url_util_impl.cc15
13 files changed, 86 insertions, 3 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_;
};
diff --git a/webkit/plugins/ppapi/ppapi_plugin_instance.cc b/webkit/plugins/ppapi/ppapi_plugin_instance.cc
index 66a38d9..8e5f6fc 100644
--- a/webkit/plugins/ppapi/ppapi_plugin_instance.cc
+++ b/webkit/plugins/ppapi/ppapi_plugin_instance.cc
@@ -687,8 +687,10 @@ void PluginInstance::Delete() {
bool PluginInstance::Initialize(WebPluginContainer* container,
const std::vector<std::string>& arg_names,
const std::vector<std::string>& arg_values,
+ const GURL& plugin_url,
bool full_frame) {
container_ = container;
+ plugin_url_ = plugin_url;
full_frame_ = full_frame;
size_t argc = 0;
diff --git a/webkit/plugins/ppapi/ppapi_plugin_instance.h b/webkit/plugins/ppapi/ppapi_plugin_instance.h
index c6d92d2..bb19d31 100644
--- a/webkit/plugins/ppapi/ppapi_plugin_instance.h
+++ b/webkit/plugins/ppapi/ppapi_plugin_instance.h
@@ -14,6 +14,7 @@
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
#include "base/string16.h"
+#include "googleurl/src/gurl.h"
#include "ppapi/c/dev/pp_cursor_type_dev.h"
#include "ppapi/c/dev/ppp_graphics_3d_dev.h"
#include "ppapi/c/dev/ppp_printing_dev.h"
@@ -135,6 +136,7 @@ class PluginInstance : public base::RefCounted<PluginInstance> {
PP_Var GetWindowObject();
PP_Var GetOwnerElementObject();
bool BindGraphics(PP_Resource graphics_id);
+ const GURL& plugin_url() const { return plugin_url_; }
bool full_frame() const { return full_frame_; }
// If |type| is not PP_CURSORTYPE_CUSTOM, |custom_image| and |hot_spot| are
// ignored.
@@ -148,6 +150,7 @@ class PluginInstance : public base::RefCounted<PluginInstance> {
bool Initialize(WebKit::WebPluginContainer* container,
const std::vector<std::string>& arg_names,
const std::vector<std::string>& arg_values,
+ const GURL& plugin_url,
bool full_frame);
bool HandleDocumentLoad(PPB_URLLoader_Impl* loader);
bool HandleInputEvent(const WebKit::WebInputEvent& event,
@@ -303,6 +306,9 @@ class PluginInstance : public base::RefCounted<PluginInstance> {
// NULL until we have been initialized.
WebKit::WebPluginContainer* container_;
+ // Plugin URL.
+ GURL plugin_url_;
+
// Indicates whether this is a full frame instance, which means it represents
// an entire document rather than an embed tag.
bool full_frame_;
diff --git a/webkit/plugins/ppapi/ppapi_webplugin_impl.cc b/webkit/plugins/ppapi/ppapi_webplugin_impl.cc
index 57ae78b..7049d35 100644
--- a/webkit/plugins/ppapi/ppapi_webplugin_impl.cc
+++ b/webkit/plugins/ppapi/ppapi_webplugin_impl.cc
@@ -7,6 +7,7 @@
#include <cmath>
#include "base/message_loop.h"
+#include "googleurl/src/gurl.h"
#include "ppapi/c/pp_var.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebBindings.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginParams.h"
@@ -37,6 +38,7 @@ struct WebPluginImpl::InitData {
base::WeakPtr<PluginDelegate> delegate;
std::vector<std::string> arg_names;
std::vector<std::string> arg_values;
+ GURL url;
};
WebPluginImpl::WebPluginImpl(
@@ -52,6 +54,7 @@ WebPluginImpl::WebPluginImpl(
init_data_->arg_names.push_back(params.attributeNames[i].utf8());
init_data_->arg_values.push_back(params.attributeValues[i].utf8());
}
+ init_data_->url = params.url;
}
WebPluginImpl::~WebPluginImpl() {
@@ -69,6 +72,7 @@ bool WebPluginImpl::initialize(WebPluginContainer* container) {
bool success = instance_->Initialize(container,
init_data_->arg_names,
init_data_->arg_values,
+ init_data_->url,
full_frame_);
if (!success) {
instance_->Delete();
diff --git a/webkit/plugins/ppapi/ppb_url_util_impl.cc b/webkit/plugins/ppapi/ppb_url_util_impl.cc
index 674dafd..13de355 100644
--- a/webkit/plugins/ppapi/ppb_url_util_impl.cc
+++ b/webkit/plugins/ppapi/ppb_url_util_impl.cc
@@ -146,6 +146,18 @@ PP_Var GetDocumentURL(PP_Instance instance_id,
frame->url(), components);
}
+PP_Var GetPluginInstanceURL(PP_Instance instance_id,
+ PP_URLComponents_Dev* components) {
+ PluginInstance* instance = ResourceTracker::Get()->GetInstance(instance_id);
+ if (!instance)
+ return PP_MakeNull();
+
+ const GURL& url = instance->plugin_url();
+ return URLUtilImpl::GenerateURLReturn(Var::GetInterface()->VarFromUtf8,
+ instance->module()->pp_module(),
+ url, components);
+}
+
const PPB_URLUtil_Dev ppb_url_util = {
&Canonicalize,
&ResolveRelativeToURL,
@@ -153,7 +165,8 @@ const PPB_URLUtil_Dev ppb_url_util = {
&IsSameSecurityOrigin,
&DocumentCanRequest,
&DocumentCanAccessDocument,
- &GetDocumentURL
+ &GetDocumentURL,
+ &GetPluginInstanceURL
};
} // namespace