OLD | NEW |
---|---|
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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" |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
185 int64_t start_offset; | 185 int64_t start_offset; |
186 int64_t number_of_bytes; | 186 int64_t number_of_bytes; |
187 PP_Time expected_last_modified_time; | 187 PP_Time expected_last_modified_time; |
188 }; | 188 }; |
189 | 189 |
190 PPB_URLRequestInfo_Impl::PPB_URLRequestInfo_Impl(PluginInstance* instance) | 190 PPB_URLRequestInfo_Impl::PPB_URLRequestInfo_Impl(PluginInstance* instance) |
191 : Resource(instance), | 191 : Resource(instance), |
192 stream_to_file_(false), | 192 stream_to_file_(false), |
193 follow_redirects_(true), | 193 follow_redirects_(true), |
194 record_download_progress_(false), | 194 record_download_progress_(false), |
195 record_upload_progress_(false) { | 195 record_upload_progress_(false), |
196 universal_access_(false) { | |
196 } | 197 } |
197 | 198 |
198 PPB_URLRequestInfo_Impl::~PPB_URLRequestInfo_Impl() { | 199 PPB_URLRequestInfo_Impl::~PPB_URLRequestInfo_Impl() { |
199 } | 200 } |
200 | 201 |
201 // static | 202 // static |
202 const PPB_URLRequestInfo* PPB_URLRequestInfo_Impl::GetInterface() { | 203 const PPB_URLRequestInfo* PPB_URLRequestInfo_Impl::GetInterface() { |
203 return &ppb_urlrequestinfo; | 204 return &ppb_urlrequestinfo; |
204 } | 205 } |
205 | 206 |
206 PPB_URLRequestInfo_Impl* PPB_URLRequestInfo_Impl::AsPPB_URLRequestInfo_Impl() { | 207 PPB_URLRequestInfo_Impl* PPB_URLRequestInfo_Impl::AsPPB_URLRequestInfo_Impl() { |
207 return this; | 208 return this; |
208 } | 209 } |
209 | 210 |
210 bool PPB_URLRequestInfo_Impl::SetBooleanProperty(PP_URLRequestProperty property, | 211 bool PPB_URLRequestInfo_Impl::SetBooleanProperty(PP_URLRequestProperty property, |
211 bool value) { | 212 bool value) { |
212 switch (property) { | 213 switch (property) { |
213 case PP_URLREQUESTPROPERTY_STREAMTOFILE: | 214 case PP_URLREQUESTPROPERTY_STREAMTOFILE: |
214 stream_to_file_ = value; | 215 stream_to_file_ = value; |
215 return true; | 216 return true; |
216 case PP_URLREQUESTPROPERTY_FOLLOWREDIRECTS: | 217 case PP_URLREQUESTPROPERTY_FOLLOWREDIRECTS: |
217 follow_redirects_ = value; | 218 follow_redirects_ = value; |
218 return true; | 219 return true; |
219 case PP_URLREQUESTPROPERTY_RECORDDOWNLOADPROGRESS: | 220 case PP_URLREQUESTPROPERTY_RECORDDOWNLOADPROGRESS: |
220 record_download_progress_ = value; | 221 record_download_progress_ = value; |
221 return true; | 222 return true; |
222 case PP_URLREQUESTPROPERTY_RECORDUPLOADPROGRESS: | 223 case PP_URLREQUESTPROPERTY_RECORDUPLOADPROGRESS: |
223 record_upload_progress_ = value; | 224 record_upload_progress_ = value; |
224 return true; | 225 return true; |
226 case PP_URLREQUESTPROPERTY_UNIVERSALACCESS: | |
227 // Only allow it to be set, not unset. | |
228 if (universal_access_ && universal_access_ != value) | |
229 return false; | |
230 universal_access_ = value; | |
231 return true; | |
225 default: | 232 default: |
226 return false; | 233 return false; |
227 } | 234 } |
228 } | 235 } |
229 | 236 |
230 bool PPB_URLRequestInfo_Impl::SetStringProperty(PP_URLRequestProperty property, | 237 bool PPB_URLRequestInfo_Impl::SetStringProperty(PP_URLRequestProperty property, |
231 const std::string& value) { | 238 const std::string& value) { |
232 // TODO(darin): Validate input. Perhaps at a different layer? | 239 // TODO(darin): Validate input. Perhaps at a different layer? |
233 switch (property) { | 240 switch (property) { |
234 case PP_URLREQUESTPROPERTY_URL: | 241 case PP_URLREQUESTPROPERTY_URL: |
235 url_ = value; // NOTE: This may be a relative URL. | 242 url_ = value; // NOTE: This may be a relative URL. |
236 return true; | 243 return true; |
237 case PP_URLREQUESTPROPERTY_METHOD: | 244 case PP_URLREQUESTPROPERTY_METHOD: |
238 method_ = value; | 245 method_ = value; |
239 return true; | 246 return true; |
240 case PP_URLREQUESTPROPERTY_HEADERS: | 247 case PP_URLREQUESTPROPERTY_HEADERS: |
241 if (!AreValidHeaders(value)) | 248 if (!universal_access_ && !AreValidHeaders(value)) |
piman
2011/03/09 02:10:10
I'm not sure we'd want to allow any arbitrary head
| |
242 return false; | 249 return false; |
243 headers_ = value; | 250 headers_ = value; |
244 return true; | 251 return true; |
245 default: | 252 default: |
246 return false; | 253 return false; |
247 } | 254 } |
248 } | 255 } |
249 | 256 |
250 bool PPB_URLRequestInfo_Impl::AppendDataToBody(const std::string& data) { | 257 bool PPB_URLRequestInfo_Impl::AppendDataToBody(const std::string& data) { |
251 if (!data.empty()) | 258 if (!data.empty()) |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
304 body_[i].number_of_bytes, | 311 body_[i].number_of_bytes, |
305 body_[i].expected_last_modified_time); | 312 body_[i].expected_last_modified_time); |
306 } else { | 313 } else { |
307 DCHECK(!body_[i].data.empty()); | 314 DCHECK(!body_[i].data.empty()); |
308 http_body.appendData(WebData(body_[i].data)); | 315 http_body.appendData(WebData(body_[i].data)); |
309 } | 316 } |
310 } | 317 } |
311 web_request.setHTTPBody(http_body); | 318 web_request.setHTTPBody(http_body); |
312 } | 319 } |
313 | 320 |
314 frame->setReferrerForRequest(web_request, WebURL()); // Use default. | 321 frame->setReferrerForRequest(web_request, WebURL()); // Use default. |
piman
2011/03/09 02:10:10
You may want to avoid doing that if the referer is
viettrungluu
2011/03/09 02:16:35
I like this and think we should be as conservative
| |
315 return web_request; | 322 return web_request; |
316 } | 323 } |
317 | 324 |
318 } // namespace ppapi | 325 } // namespace ppapi |
319 } // namespace webkit | 326 } // namespace webkit |
320 | 327 |
OLD | NEW |