summaryrefslogtreecommitdiffstats
path: root/webkit
diff options
context:
space:
mode:
authordarin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-20 05:03:03 +0000
committerdarin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-20 05:03:03 +0000
commit729ac5974a7bf4d6e5cfe2245c8497ffc9a92405 (patch)
tree32748c77cc1745e4fd14f7ea4807e8f9ffe34d5c /webkit
parented962243707263c97f4ba6f7d7614a6cfde86b0c (diff)
downloadchromium_src-729ac5974a7bf4d6e5cfe2245c8497ffc9a92405.zip
chromium_src-729ac5974a7bf4d6e5cfe2245c8497ffc9a92405.tar.gz
chromium_src-729ac5974a7bf4d6e5cfe2245c8497ffc9a92405.tar.bz2
Implement PPB_URLLoaderTrusted_Dev.
R=brettw BUG=47354 TEST=see ppapi/tests Review URL: http://codereview.chromium.org/3431014 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@59912 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r--webkit/glue/plugins/pepper_plugin_module.cc3
-rw-r--r--webkit/glue/plugins/pepper_url_loader.cc29
-rw-r--r--webkit/glue/plugins/pepper_url_loader.h12
3 files changed, 41 insertions, 3 deletions
diff --git a/webkit/glue/plugins/pepper_plugin_module.cc b/webkit/glue/plugins/pepper_plugin_module.cc
index 74bf27e9..a0cef68 100644
--- a/webkit/glue/plugins/pepper_plugin_module.cc
+++ b/webkit/glue/plugins/pepper_plugin_module.cc
@@ -28,6 +28,7 @@
#include "third_party/ppapi/c/dev/ppb_testing_dev.h"
#include "third_party/ppapi/c/dev/ppb_transport_dev.h"
#include "third_party/ppapi/c/dev/ppb_url_loader_dev.h"
+#include "third_party/ppapi/c/dev/ppb_url_loader_trusted_dev.h"
#include "third_party/ppapi/c/dev/ppb_url_request_info_dev.h"
#include "third_party/ppapi/c/dev/ppb_url_response_info_dev.h"
#include "third_party/ppapi/c/dev/ppb_url_util_dev.h"
@@ -224,6 +225,8 @@ const void* GetInterface(const char* name) {
return Transport::GetInterface();
if (strcmp(name, PPB_URLLOADER_DEV_INTERFACE) == 0)
return URLLoader::GetInterface();
+ if (strcmp(name, PPB_URLLOADERTRUSTED_DEV_INTERFACE) == 0)
+ return URLLoader::GetInterface();
if (strcmp(name, PPB_URLREQUESTINFO_DEV_INTERFACE) == 0)
return URLRequestInfo::GetInterface();
if (strcmp(name, PPB_URLRESPONSEINFO_DEV_INTERFACE) == 0)
diff --git a/webkit/glue/plugins/pepper_url_loader.cc b/webkit/glue/plugins/pepper_url_loader.cc
index bbaf6cb..e0088c4 100644
--- a/webkit/glue/plugins/pepper_url_loader.cc
+++ b/webkit/glue/plugins/pepper_url_loader.cc
@@ -8,12 +8,14 @@
#include "third_party/ppapi/c/pp_completion_callback.h"
#include "third_party/ppapi/c/pp_errors.h"
#include "third_party/ppapi/c/dev/ppb_url_loader_dev.h"
+#include "third_party/ppapi/c/dev/ppb_url_loader_trusted_dev.h"
#include "third_party/WebKit/WebKit/chromium/public/WebDocument.h"
#include "third_party/WebKit/WebKit/chromium/public/WebElement.h"
#include "third_party/WebKit/WebKit/chromium/public/WebFrame.h"
#include "third_party/WebKit/WebKit/chromium/public/WebKit.h"
#include "third_party/WebKit/WebKit/chromium/public/WebKitClient.h"
#include "third_party/WebKit/WebKit/chromium/public/WebPluginContainer.h"
+#include "third_party/WebKit/WebKit/chromium/public/WebSecurityOrigin.h"
#include "third_party/WebKit/WebKit/chromium/public/WebURLRequest.h"
#include "third_party/WebKit/WebKit/chromium/public/WebURLResponse.h"
#include "webkit/glue/plugins/pepper_plugin_instance.h"
@@ -152,6 +154,18 @@ const PPB_URLLoader_Dev ppb_urlloader = {
&Close
};
+void GrantUniversalAccess(PP_Resource loader_id) {
+ scoped_refptr<URLLoader> loader(Resource::GetAs<URLLoader>(loader_id));
+ if (!loader)
+ return;
+
+ loader->GrantUniversalAccess();
+}
+
+const PPB_URLLoaderTrusted_Dev ppb_urlloadertrusted = {
+ &GrantUniversalAccess
+};
+
} // namespace
URLLoader::URLLoader(PluginInstance* instance)
@@ -164,7 +178,8 @@ URLLoader::URLLoader(PluginInstance* instance)
total_bytes_to_be_received_(-1),
user_buffer_(NULL),
user_buffer_size_(0),
- done_status_(PP_ERROR_WOULDBLOCK) {
+ done_status_(PP_ERROR_WOULDBLOCK),
+ has_universal_access_(false) {
}
URLLoader::~URLLoader() {
@@ -188,6 +203,12 @@ int32_t URLLoader::Open(URLRequestInfo* request,
if (!frame)
return PP_ERROR_FAILED;
WebURLRequest web_request(request->ToWebURLRequest(frame));
+
+ // Check if we are allowed to access this URL.
+ if (!has_universal_access_ &&
+ !frame->securityOrigin().canRequest(web_request.url()))
+ return PP_ERROR_NOACCESS;
+
frame->dispatchWillSendRequest(web_request);
loader_.reset(WebKit::webKitClient()->createURLLoader());
@@ -257,6 +278,10 @@ void URLLoader::Close() {
NOTIMPLEMENTED(); // TODO(darin): Implement me.
}
+void URLLoader::GrantUniversalAccess() {
+ has_universal_access_ = true;
+}
+
void URLLoader::willSendRequest(WebURLLoader* loader,
WebURLRequest& new_request,
const WebURLResponse& redirect_response) {
@@ -301,7 +326,7 @@ void URLLoader::didReceiveData(WebURLLoader* loader,
}
}
-void URLLoader::didFinishLoading(WebURLLoader* loader, double finishTime) {
+void URLLoader::didFinishLoading(WebURLLoader* loader, double finish_time) {
done_status_ = PP_OK;
RunCallback(done_status_);
}
diff --git a/webkit/glue/plugins/pepper_url_loader.h b/webkit/glue/plugins/pepper_url_loader.h
index 5795f18..4919de7 100644
--- a/webkit/glue/plugins/pepper_url_loader.h
+++ b/webkit/glue/plugins/pepper_url_loader.h
@@ -14,6 +14,7 @@
#include "webkit/glue/plugins/pepper_resource.h"
struct PPB_URLLoader_Dev;
+struct PPB_URLLoaderTrusted_Dev;
namespace pepper {
@@ -30,6 +31,10 @@ class URLLoader : public Resource, public WebKit::WebURLLoaderClient {
// exposed to the plugin.
static const PPB_URLLoader_Dev* GetInterface();
+ // Returns a pointer to the interface implementing PPB_URLLoaderTrusted that
+ // is exposed to the plugin.
+ static const PPB_URLLoaderTrusted_Dev* GetTrustedInterface();
+
// Resource overrides.
URLLoader* AsURLLoader() { return this; }
@@ -41,6 +46,9 @@ class URLLoader : public Resource, public WebKit::WebURLLoaderClient {
int32_t FinishStreamingToFile(PP_CompletionCallback callback);
void Close();
+ // PPB_URLLoaderTrusted implementation.
+ void GrantUniversalAccess();
+
// WebKit::WebURLLoaderClient implementation.
virtual void willSendRequest(WebKit::WebURLLoader* loader,
WebKit::WebURLRequest& new_request,
@@ -55,7 +63,8 @@ class URLLoader : public Resource, public WebKit::WebURLLoaderClient {
virtual void didReceiveData(WebKit::WebURLLoader* loader,
const char* data,
int data_length);
- virtual void didFinishLoading(WebKit::WebURLLoader* loader, double finishTime);
+ virtual void didFinishLoading(WebKit::WebURLLoader* loader,
+ double finish_time);
virtual void didFail(WebKit::WebURLLoader* loader,
const WebKit::WebURLError& error);
@@ -85,6 +94,7 @@ class URLLoader : public Resource, public WebKit::WebURLLoaderClient {
char* user_buffer_;
size_t user_buffer_size_;
int32_t done_status_;
+ bool has_universal_access_;
};
} // namespace pepper