| 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 bool IsURLRequestInfo(PP_Resource resource) { | 60 bool IsURLRequestInfo(PP_Resource resource) { |
| 61 return !!Resource::GetAs<URLRequestInfo>(resource); | 61 return !!Resource::GetAs<URLRequestInfo>(resource); |
| 62 } | 62 } |
| 63 | 63 |
| 64 bool SetProperty(PP_Resource request_id, | 64 bool SetProperty(PP_Resource request_id, |
| 65 PP_URLRequestProperty property, | 65 PP_URLRequestProperty_Dev 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 false; | 70 return false; |
| 71 | 71 |
| 72 if (var.type == PP_VARTYPE_BOOL) | 72 if (var.type == PP_VARTYPE_BOOL) |
| 73 return request->SetBooleanProperty(property, var.value.as_bool); | 73 return request->SetBooleanProperty(property, var.value.as_bool); |
| 74 | 74 |
| 75 if (var.type == PP_VARTYPE_STRING) | 75 if (var.type == PP_VARTYPE_STRING) |
| (...skipping 28 matching lines...) Expand all Loading... |
| 104 scoped_refptr<FileRef> file_ref(Resource::GetAs<FileRef>(file_ref_id)); | 104 scoped_refptr<FileRef> file_ref(Resource::GetAs<FileRef>(file_ref_id)); |
| 105 if (!file_ref) | 105 if (!file_ref) |
| 106 return false; | 106 return false; |
| 107 | 107 |
| 108 return request->AppendFileToBody(file_ref, | 108 return request->AppendFileToBody(file_ref, |
| 109 start_offset, | 109 start_offset, |
| 110 number_of_bytes, | 110 number_of_bytes, |
| 111 expected_last_modified_time); | 111 expected_last_modified_time); |
| 112 } | 112 } |
| 113 | 113 |
| 114 const PPB_URLRequestInfo ppb_urlrequestinfo = { | 114 const PPB_URLRequestInfo_Dev ppb_urlrequestinfo = { |
| 115 &Create, | 115 &Create, |
| 116 &IsURLRequestInfo, | 116 &IsURLRequestInfo, |
| 117 &SetProperty, | 117 &SetProperty, |
| 118 &AppendDataToBody, | 118 &AppendDataToBody, |
| 119 &AppendFileToBody | 119 &AppendFileToBody |
| 120 }; | 120 }; |
| 121 | 121 |
| 122 } // namespace | 122 } // namespace |
| 123 | 123 |
| 124 URLRequestInfo::URLRequestInfo(PluginModule* module) | 124 URLRequestInfo::URLRequestInfo(PluginModule* module) |
| 125 : Resource(module), | 125 : Resource(module), |
| 126 stream_to_file_(false) { | 126 stream_to_file_(false) { |
| 127 } | 127 } |
| 128 | 128 |
| 129 URLRequestInfo::~URLRequestInfo() { | 129 URLRequestInfo::~URLRequestInfo() { |
| 130 } | 130 } |
| 131 | 131 |
| 132 // static | 132 // static |
| 133 const PPB_URLRequestInfo* URLRequestInfo::GetInterface() { | 133 const PPB_URLRequestInfo_Dev* URLRequestInfo::GetInterface() { |
| 134 return &ppb_urlrequestinfo; | 134 return &ppb_urlrequestinfo; |
| 135 } | 135 } |
| 136 | 136 |
| 137 bool URLRequestInfo::SetBooleanProperty(PP_URLRequestProperty property, | 137 bool URLRequestInfo::SetBooleanProperty(PP_URLRequestProperty_Dev property, |
| 138 bool value) { | 138 bool value) { |
| 139 switch (property) { | 139 switch (property) { |
| 140 case PP_URLREQUESTPROPERTY_STREAMTOFILE: | 140 case PP_URLREQUESTPROPERTY_STREAMTOFILE: |
| 141 stream_to_file_ = value; | 141 stream_to_file_ = value; |
| 142 return true; | 142 return true; |
| 143 default: | 143 default: |
| 144 NOTIMPLEMENTED(); // TODO(darin): Implement me! | 144 NOTIMPLEMENTED(); // TODO(darin): Implement me! |
| 145 return false; | 145 return false; |
| 146 } | 146 } |
| 147 } | 147 } |
| 148 | 148 |
| 149 bool URLRequestInfo::SetStringProperty(PP_URLRequestProperty property, | 149 bool URLRequestInfo::SetStringProperty(PP_URLRequestProperty_Dev property, |
| 150 const std::string& value) { | 150 const std::string& value) { |
| 151 // TODO(darin): Validate input. Perhaps at a different layer? | 151 // TODO(darin): Validate input. Perhaps at a different layer? |
| 152 switch (property) { | 152 switch (property) { |
| 153 case PP_URLREQUESTPROPERTY_URL: | 153 case PP_URLREQUESTPROPERTY_URL: |
| 154 url_ = value; // NOTE: This may be a relative URL. | 154 url_ = value; // NOTE: This may be a relative URL. |
| 155 return true; | 155 return true; |
| 156 case PP_URLREQUESTPROPERTY_METHOD: | 156 case PP_URLREQUESTPROPERTY_METHOD: |
| 157 method_ = value; | 157 method_ = value; |
| 158 return true; | 158 return true; |
| 159 case PP_URLREQUESTPROPERTY_HEADERS: | 159 case PP_URLREQUESTPROPERTY_HEADERS: |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 } | 227 } |
| 228 } | 228 } |
| 229 web_request.setHTTPBody(http_body); | 229 web_request.setHTTPBody(http_body); |
| 230 } | 230 } |
| 231 | 231 |
| 232 frame->setReferrerForRequest(web_request, WebURL()); // Use default. | 232 frame->setReferrerForRequest(web_request, WebURL()); // Use default. |
| 233 return web_request; | 233 return web_request; |
| 234 } | 234 } |
| 235 | 235 |
| 236 } // namespace pepper | 236 } // namespace pepper |
| OLD | NEW |