summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ppapi/c/ppb_url_request_info.h21
-rw-r--r--ppapi/cpp/url_request_info.h8
-rw-r--r--webkit/plugins/ppapi/ppb_url_request_info_impl.cc10
-rw-r--r--webkit/plugins/ppapi/ppb_url_request_info_impl.h8
-rw-r--r--webkit/plugins/ppapi/url_request_info_unittest.cc26
5 files changed, 67 insertions, 6 deletions
diff --git a/ppapi/c/ppb_url_request_info.h b/ppapi/c/ppb_url_request_info.h
index aad1c9e..259760e 100644
--- a/ppapi/c/ppb_url_request_info.h
+++ b/ppapi/c/ppb_url_request_info.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010 The Chromium Authors. All rights reserved.
+/* Copyright (c) 2011 The Chromium Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
@@ -37,7 +37,7 @@ typedef enum {
// Boolean (default = PP_FALSE).
PP_URLREQUESTPROPERTY_RECORDDOWNLOADPROGRESS,
- // Set to true if you want to be able to pull the upload progress via the
+ // Set to true if you want to be able to poll the upload progress via the
// URLLoader.GetUploadProgress function.
//
// Boolean (default = PP_FALSE).
@@ -51,7 +51,22 @@ typedef enum {
// result.
//
// Undefined/String (default = Undefined)
- PP_URLREQUESTPROPERTY_CUSTOMREFERRERURL
+ PP_URLREQUESTPROPERTY_CUSTOMREFERRERURL,
+
+ // Whether cross-origin requests are allowed. Cross-origin requests are made
+ // using the CORS (Cross-Origin Resource Sharing) algorithm to check whether
+ // the request should be allowed. For the complete CORS algorithm, see:
+ // http://www.w3.org/TR/access-control
+ //
+ // Boolean (default = PP_FALSE).
+ PP_URLREQUESTPROPERTY_ALLOWCROSSORIGINREQUESTS,
+
+ // Whether HTTP credentials are sent with cross-origin requests. If false,
+ // no credentials are sent with the request and cookies are ignored in the
+ // response. If the request is not cross-origin, this property is ignored.
+ //
+ // Boolean (default = PP_FALSE).
+ PP_URLREQUESTPROPERTY_ALLOWCREDENTIALS
} PP_URLRequestProperty;
PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_URLRequestProperty, 4);
/**
diff --git a/ppapi/cpp/url_request_info.h b/ppapi/cpp/url_request_info.h
index 2530085..9d38c69 100644
--- a/ppapi/cpp/url_request_info.h
+++ b/ppapi/cpp/url_request_info.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -58,6 +58,12 @@ class URLRequestInfo : public Resource {
bool SetCustomReferrerURL(const Var& url_string) {
return SetProperty(PP_URLREQUESTPROPERTY_CUSTOMREFERRERURL, url_string);
}
+ bool SetAllowCrossOriginRequests(bool enable) {
+ return SetProperty(PP_URLREQUESTPROPERTY_ALLOWCROSSORIGINREQUESTS, enable);
+ }
+ bool SetAllowCredentials(bool enable) {
+ return SetProperty(PP_URLREQUESTPROPERTY_ALLOWCREDENTIALS, enable);
+ }
};
} // namespace pp
diff --git a/webkit/plugins/ppapi/ppb_url_request_info_impl.cc b/webkit/plugins/ppapi/ppb_url_request_info_impl.cc
index a3685d3..89cf3c1 100644
--- a/webkit/plugins/ppapi/ppb_url_request_info_impl.cc
+++ b/webkit/plugins/ppapi/ppb_url_request_info_impl.cc
@@ -200,7 +200,9 @@ PPB_URLRequestInfo_Impl::PPB_URLRequestInfo_Impl(PluginInstance* instance)
follow_redirects_(true),
record_download_progress_(false),
record_upload_progress_(false),
- has_custom_referrer_url_(false) {
+ has_custom_referrer_url_(false),
+ allow_cross_origin_requests_(false),
+ allow_credentials_(false) {
}
PPB_URLRequestInfo_Impl::~PPB_URLRequestInfo_Impl() {
@@ -242,6 +244,12 @@ bool PPB_URLRequestInfo_Impl::SetBooleanProperty(PP_URLRequestProperty property,
case PP_URLREQUESTPROPERTY_RECORDUPLOADPROGRESS:
record_upload_progress_ = value;
return true;
+ case PP_URLREQUESTPROPERTY_ALLOWCROSSORIGINREQUESTS:
+ allow_cross_origin_requests_ = value;
+ return true;
+ case PP_URLREQUESTPROPERTY_ALLOWCREDENTIALS:
+ allow_credentials_ = value;
+ return true;
default:
return false;
}
diff --git a/webkit/plugins/ppapi/ppb_url_request_info_impl.h b/webkit/plugins/ppapi/ppb_url_request_info_impl.h
index a626e86..1b06aa7 100644
--- a/webkit/plugins/ppapi/ppb_url_request_info_impl.h
+++ b/webkit/plugins/ppapi/ppb_url_request_info_impl.h
@@ -55,6 +55,11 @@ class PPB_URLRequestInfo_Impl : public Resource {
bool record_download_progress() const { return record_download_progress_; }
bool record_upload_progress() const { return record_upload_progress_; }
+ bool allow_cross_origin_requests() const {
+ return allow_cross_origin_requests_;
+ }
+ bool allow_credentials() const { return allow_credentials_; }
+
private:
struct BodyItem;
typedef std::vector<BodyItem> Body;
@@ -76,6 +81,9 @@ class PPB_URLRequestInfo_Impl : public Resource {
bool has_custom_referrer_url_;
std::string custom_referrer_url_;
+ bool allow_cross_origin_requests_;
+ bool allow_credentials_;
+
DISALLOW_COPY_AND_ASSIGN(PPB_URLRequestInfo_Impl);
};
diff --git a/webkit/plugins/ppapi/url_request_info_unittest.cc b/webkit/plugins/ppapi/url_request_info_unittest.cc
index c2e2e77..cc56abc 100644
--- a/webkit/plugins/ppapi/url_request_info_unittest.cc
+++ b/webkit/plugins/ppapi/url_request_info_unittest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -160,6 +160,30 @@ TEST_F(URLRequestInfoTest, RecordUploadProgress) {
ASSERT_FALSE(info_->record_upload_progress());
}
+TEST_F(URLRequestInfoTest, AllowCrossOriginRequests) {
+ ASSERT_FALSE(info_->allow_cross_origin_requests());
+
+ ASSERT_TRUE(info_->SetBooleanProperty(
+ PP_URLREQUESTPROPERTY_ALLOWCROSSORIGINREQUESTS, true));
+ ASSERT_TRUE(info_->allow_cross_origin_requests());
+
+ ASSERT_TRUE(info_->SetBooleanProperty(
+ PP_URLREQUESTPROPERTY_ALLOWCROSSORIGINREQUESTS, false));
+ ASSERT_FALSE(info_->allow_cross_origin_requests());
+}
+
+TEST_F(URLRequestInfoTest, AllowCredentials) {
+ ASSERT_FALSE(info_->allow_credentials());
+
+ ASSERT_TRUE(info_->SetBooleanProperty(
+ PP_URLREQUESTPROPERTY_ALLOWCREDENTIALS, true));
+ ASSERT_TRUE(info_->allow_credentials());
+
+ ASSERT_TRUE(info_->SetBooleanProperty(
+ PP_URLREQUESTPROPERTY_ALLOWCREDENTIALS, false));
+ ASSERT_FALSE(info_->allow_credentials());
+}
+
TEST_F(URLRequestInfoTest, SetURL) {
// Test default URL is "about:blank".
ASSERT_TRUE(IsExpected(GetURL(), "about:blank"));