Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(37)

Side by Side Diff: webkit/plugins/ppapi/ppb_url_request_info_impl.cc

Issue 6652014: Pepper: Add a property to URLRequestInfo to skip header validation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: used undefined var to unset Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "webkit/plugins/ppapi/ppb_url_request_info_impl.h" 5 #include "webkit/plugins/ppapi/ppb_url_request_info_impl.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "googleurl/src/gurl.h" 9 #include "googleurl/src/gurl.h"
10 #include "net/http/http_util.h" 10 #include "net/http/http_util.h"
11 #include "ppapi/c/pp_var.h" 11 #include "ppapi/c/pp_var.h"
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 } 96 }
97 97
98 PP_Bool SetProperty(PP_Resource request_id, 98 PP_Bool SetProperty(PP_Resource request_id,
99 PP_URLRequestProperty property, 99 PP_URLRequestProperty property,
100 PP_Var var) { 100 PP_Var var) {
101 scoped_refptr<PPB_URLRequestInfo_Impl> request( 101 scoped_refptr<PPB_URLRequestInfo_Impl> request(
102 Resource::GetAs<PPB_URLRequestInfo_Impl>(request_id)); 102 Resource::GetAs<PPB_URLRequestInfo_Impl>(request_id));
103 if (!request) 103 if (!request)
104 return PP_FALSE; 104 return PP_FALSE;
105 105
106 if (var.type == PP_VARTYPE_UNDEFINED)
brettw 2011/03/11 23:31:05 Now that we have 3 of these, I think it would be m
viettrungluu 2011/03/14 17:13:53 Done.
107 return BoolToPPBool(request->SetUndefinedProperty(property));
108
106 if (var.type == PP_VARTYPE_BOOL) { 109 if (var.type == PP_VARTYPE_BOOL) {
107 return BoolToPPBool( 110 return BoolToPPBool(
108 request->SetBooleanProperty(property, 111 request->SetBooleanProperty(property,
109 PPBoolToBool(var.value.as_bool))); 112 PPBoolToBool(var.value.as_bool)));
110 } 113 }
111 114
112 if (var.type == PP_VARTYPE_STRING) { 115 if (var.type == PP_VARTYPE_STRING) {
113 scoped_refptr<StringVar> string(StringVar::FromPPVar(var)); 116 scoped_refptr<StringVar> string(StringVar::FromPPVar(var));
114 if (string) { 117 if (string) {
115 return BoolToPPBool(request->SetStringProperty(property, 118 return BoolToPPBool(request->SetStringProperty(property,
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 int64_t start_offset; 188 int64_t start_offset;
186 int64_t number_of_bytes; 189 int64_t number_of_bytes;
187 PP_Time expected_last_modified_time; 190 PP_Time expected_last_modified_time;
188 }; 191 };
189 192
190 PPB_URLRequestInfo_Impl::PPB_URLRequestInfo_Impl(PluginInstance* instance) 193 PPB_URLRequestInfo_Impl::PPB_URLRequestInfo_Impl(PluginInstance* instance)
191 : Resource(instance), 194 : Resource(instance),
192 stream_to_file_(false), 195 stream_to_file_(false),
193 follow_redirects_(true), 196 follow_redirects_(true),
194 record_download_progress_(false), 197 record_download_progress_(false),
195 record_upload_progress_(false) { 198 record_upload_progress_(false),
199 has_custom_referrer_url_(false) {
196 } 200 }
197 201
198 PPB_URLRequestInfo_Impl::~PPB_URLRequestInfo_Impl() { 202 PPB_URLRequestInfo_Impl::~PPB_URLRequestInfo_Impl() {
199 } 203 }
200 204
201 // static 205 // static
202 const PPB_URLRequestInfo* PPB_URLRequestInfo_Impl::GetInterface() { 206 const PPB_URLRequestInfo* PPB_URLRequestInfo_Impl::GetInterface() {
203 return &ppb_urlrequestinfo; 207 return &ppb_urlrequestinfo;
204 } 208 }
205 209
206 PPB_URLRequestInfo_Impl* PPB_URLRequestInfo_Impl::AsPPB_URLRequestInfo_Impl() { 210 PPB_URLRequestInfo_Impl* PPB_URLRequestInfo_Impl::AsPPB_URLRequestInfo_Impl() {
207 return this; 211 return this;
208 } 212 }
209 213
214 bool PPB_URLRequestInfo_Impl::SetUndefinedProperty(
215 PP_URLRequestProperty property) {
216 switch (property) {
217 case PP_URLREQUESTPROPERTY_CUSTOMREFERRERURL:
218 has_custom_referrer_url_ = false;
219 custom_referrer_url_ = std::string();
220 return true;
221 default:
222 return false;
223 }
224 }
225
210 bool PPB_URLRequestInfo_Impl::SetBooleanProperty(PP_URLRequestProperty property, 226 bool PPB_URLRequestInfo_Impl::SetBooleanProperty(PP_URLRequestProperty property,
211 bool value) { 227 bool value) {
212 switch (property) { 228 switch (property) {
213 case PP_URLREQUESTPROPERTY_STREAMTOFILE: 229 case PP_URLREQUESTPROPERTY_STREAMTOFILE:
214 stream_to_file_ = value; 230 stream_to_file_ = value;
215 return true; 231 return true;
216 case PP_URLREQUESTPROPERTY_FOLLOWREDIRECTS: 232 case PP_URLREQUESTPROPERTY_FOLLOWREDIRECTS:
217 follow_redirects_ = value; 233 follow_redirects_ = value;
218 return true; 234 return true;
219 case PP_URLREQUESTPROPERTY_RECORDDOWNLOADPROGRESS: 235 case PP_URLREQUESTPROPERTY_RECORDDOWNLOADPROGRESS:
(...skipping 15 matching lines...) Expand all
235 url_ = value; // NOTE: This may be a relative URL. 251 url_ = value; // NOTE: This may be a relative URL.
236 return true; 252 return true;
237 case PP_URLREQUESTPROPERTY_METHOD: 253 case PP_URLREQUESTPROPERTY_METHOD:
238 method_ = value; 254 method_ = value;
239 return true; 255 return true;
240 case PP_URLREQUESTPROPERTY_HEADERS: 256 case PP_URLREQUESTPROPERTY_HEADERS:
241 if (!AreValidHeaders(value)) 257 if (!AreValidHeaders(value))
242 return false; 258 return false;
243 headers_ = value; 259 headers_ = value;
244 return true; 260 return true;
261 case PP_URLREQUESTPROPERTY_CUSTOMREFERRERURL:
262 has_custom_referrer_url_ = true;
263 custom_referrer_url_ = value;
264 return true;
245 default: 265 default:
246 return false; 266 return false;
247 } 267 }
248 } 268 }
249 269
250 bool PPB_URLRequestInfo_Impl::AppendDataToBody(const std::string& data) { 270 bool PPB_URLRequestInfo_Impl::AppendDataToBody(const std::string& data) {
251 if (!data.empty()) 271 if (!data.empty())
252 body_.push_back(BodyItem(data)); 272 body_.push_back(BodyItem(data));
253 return true; 273 return true;
254 } 274 }
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 body_[i].number_of_bytes, 324 body_[i].number_of_bytes,
305 body_[i].expected_last_modified_time); 325 body_[i].expected_last_modified_time);
306 } else { 326 } else {
307 DCHECK(!body_[i].data.empty()); 327 DCHECK(!body_[i].data.empty());
308 http_body.appendData(WebData(body_[i].data)); 328 http_body.appendData(WebData(body_[i].data));
309 } 329 }
310 } 330 }
311 web_request.setHTTPBody(http_body); 331 web_request.setHTTPBody(http_body);
312 } 332 }
313 333
314 frame->setReferrerForRequest(web_request, WebURL()); // Use default. 334 if (has_custom_referrer_url_) {
335 if (!custom_referrer_url_.empty())
336 frame->setReferrerForRequest(web_request, GURL(custom_referrer_url_));
337 } else {
338 frame->setReferrerForRequest(web_request, WebURL()); // Use default.
339 }
340
315 return web_request; 341 return web_request;
316 } 342 }
317 343
344 bool PPB_URLRequestInfo_Impl::RequiresUniversalAccess() const {
345 return has_custom_referrer_url_;
346 }
347
318 } // namespace ppapi 348 } // namespace ppapi
319 } // namespace webkit 349 } // namespace webkit
320
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698