| 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/glue/plugins/pepper_url_request_info.h" | 5 #include "webkit/glue/plugins/pepper_url_request_info.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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 URLRequestInfo* request = new URLRequestInfo(module); | 55 URLRequestInfo* request = new URLRequestInfo(module); |
| 56 | 56 |
| 57 return request->GetReference(); | 57 return request->GetReference(); |
| 58 } | 58 } |
| 59 | 59 |
| 60 PP_Bool IsURLRequestInfo(PP_Resource resource) { | 60 PP_Bool IsURLRequestInfo(PP_Resource resource) { |
| 61 return BoolToPPBool(!!Resource::GetAs<URLRequestInfo>(resource)); | 61 return BoolToPPBool(!!Resource::GetAs<URLRequestInfo>(resource)); |
| 62 } | 62 } |
| 63 | 63 |
| 64 PP_Bool SetProperty(PP_Resource request_id, | 64 PP_Bool SetProperty(PP_Resource request_id, |
| 65 PP_URLRequestProperty_Dev property, | 65 PP_URLRequestProperty property, |
| 66 PP_Var var) { | 66 PP_Var var) { |
| 67 scoped_refptr<URLRequestInfo> request( | 67 scoped_refptr<URLRequestInfo> request( |
| 68 Resource::GetAs<URLRequestInfo>(request_id)); | 68 Resource::GetAs<URLRequestInfo>(request_id)); |
| 69 if (!request) | 69 if (!request) |
| 70 return PP_FALSE; | 70 return PP_FALSE; |
| 71 | 71 |
| 72 if (var.type == PP_VARTYPE_BOOL) { | 72 if (var.type == PP_VARTYPE_BOOL) { |
| 73 return BoolToPPBool( | 73 return BoolToPPBool( |
| 74 request->SetBooleanProperty(property, | 74 request->SetBooleanProperty(property, |
| 75 PPBoolToBool(var.value.as_bool))); | 75 PPBoolToBool(var.value.as_bool))); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 scoped_refptr<FileRef> file_ref(Resource::GetAs<FileRef>(file_ref_id)); | 110 scoped_refptr<FileRef> file_ref(Resource::GetAs<FileRef>(file_ref_id)); |
| 111 if (!file_ref) | 111 if (!file_ref) |
| 112 return PP_FALSE; | 112 return PP_FALSE; |
| 113 | 113 |
| 114 return BoolToPPBool(request->AppendFileToBody(file_ref, | 114 return BoolToPPBool(request->AppendFileToBody(file_ref, |
| 115 start_offset, | 115 start_offset, |
| 116 number_of_bytes, | 116 number_of_bytes, |
| 117 expected_last_modified_time)); | 117 expected_last_modified_time)); |
| 118 } | 118 } |
| 119 | 119 |
| 120 const PPB_URLRequestInfo_Dev ppb_urlrequestinfo = { | 120 const PPB_URLRequestInfo ppb_urlrequestinfo = { |
| 121 &Create, | 121 &Create, |
| 122 &IsURLRequestInfo, | 122 &IsURLRequestInfo, |
| 123 &SetProperty, | 123 &SetProperty, |
| 124 &AppendDataToBody, | 124 &AppendDataToBody, |
| 125 &AppendFileToBody | 125 &AppendFileToBody |
| 126 }; | 126 }; |
| 127 | 127 |
| 128 } // namespace | 128 } // namespace |
| 129 | 129 |
| 130 struct URLRequestInfo::BodyItem { | 130 struct URLRequestInfo::BodyItem { |
| (...skipping 26 matching lines...) Expand all Loading... |
| 157 stream_to_file_(false), | 157 stream_to_file_(false), |
| 158 follow_redirects_(true), | 158 follow_redirects_(true), |
| 159 record_download_progress_(false), | 159 record_download_progress_(false), |
| 160 record_upload_progress_(false) { | 160 record_upload_progress_(false) { |
| 161 } | 161 } |
| 162 | 162 |
| 163 URLRequestInfo::~URLRequestInfo() { | 163 URLRequestInfo::~URLRequestInfo() { |
| 164 } | 164 } |
| 165 | 165 |
| 166 // static | 166 // static |
| 167 const PPB_URLRequestInfo_Dev* URLRequestInfo::GetInterface() { | 167 const PPB_URLRequestInfo* URLRequestInfo::GetInterface() { |
| 168 return &ppb_urlrequestinfo; | 168 return &ppb_urlrequestinfo; |
| 169 } | 169 } |
| 170 | 170 |
| 171 bool URLRequestInfo::SetBooleanProperty(PP_URLRequestProperty_Dev property, | 171 bool URLRequestInfo::SetBooleanProperty(PP_URLRequestProperty property, |
| 172 bool value) { | 172 bool value) { |
| 173 switch (property) { | 173 switch (property) { |
| 174 case PP_URLREQUESTPROPERTY_STREAMTOFILE: | 174 case PP_URLREQUESTPROPERTY_STREAMTOFILE: |
| 175 stream_to_file_ = value; | 175 stream_to_file_ = value; |
| 176 return true; | 176 return true; |
| 177 case PP_URLREQUESTPROPERTY_FOLLOWREDIRECTS: | 177 case PP_URLREQUESTPROPERTY_FOLLOWREDIRECTS: |
| 178 follow_redirects_ = value; | 178 follow_redirects_ = value; |
| 179 return true; | 179 return true; |
| 180 case PP_URLREQUESTPROPERTY_RECORDDOWNLOADPROGRESS: | 180 case PP_URLREQUESTPROPERTY_RECORDDOWNLOADPROGRESS: |
| 181 record_download_progress_ = value; | 181 record_download_progress_ = value; |
| 182 return true; | 182 return true; |
| 183 case PP_URLREQUESTPROPERTY_RECORDUPLOADPROGRESS: | 183 case PP_URLREQUESTPROPERTY_RECORDUPLOADPROGRESS: |
| 184 record_upload_progress_ = value; | 184 record_upload_progress_ = value; |
| 185 return true; | 185 return true; |
| 186 default: | 186 default: |
| 187 //NOTIMPLEMENTED(); // TODO(darin): Implement me! | 187 //NOTIMPLEMENTED(); // TODO(darin): Implement me! |
| 188 return false; | 188 return false; |
| 189 } | 189 } |
| 190 } | 190 } |
| 191 | 191 |
| 192 bool URLRequestInfo::SetStringProperty(PP_URLRequestProperty_Dev property, | 192 bool URLRequestInfo::SetStringProperty(PP_URLRequestProperty property, |
| 193 const std::string& value) { | 193 const std::string& value) { |
| 194 // TODO(darin): Validate input. Perhaps at a different layer? | 194 // TODO(darin): Validate input. Perhaps at a different layer? |
| 195 switch (property) { | 195 switch (property) { |
| 196 case PP_URLREQUESTPROPERTY_URL: | 196 case PP_URLREQUESTPROPERTY_URL: |
| 197 url_ = value; // NOTE: This may be a relative URL. | 197 url_ = value; // NOTE: This may be a relative URL. |
| 198 return true; | 198 return true; |
| 199 case PP_URLREQUESTPROPERTY_METHOD: | 199 case PP_URLREQUESTPROPERTY_METHOD: |
| 200 method_ = value; | 200 method_ = value; |
| 201 return true; | 201 return true; |
| 202 case PP_URLREQUESTPROPERTY_HEADERS: | 202 case PP_URLREQUESTPROPERTY_HEADERS: |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 } | 269 } |
| 270 } | 270 } |
| 271 web_request.setHTTPBody(http_body); | 271 web_request.setHTTPBody(http_body); |
| 272 } | 272 } |
| 273 | 273 |
| 274 frame->setReferrerForRequest(web_request, WebURL()); // Use default. | 274 frame->setReferrerForRequest(web_request, WebURL()); // Use default. |
| 275 return web_request; | 275 return web_request; |
| 276 } | 276 } |
| 277 | 277 |
| 278 } // namespace pepper | 278 } // namespace pepper |
| OLD | NEW |