OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/common/cloud_print/cloud_print_helpers.h" | 5 #include "chrome/common/cloud_print/cloud_print_helpers.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <limits> | 9 #include <limits> |
10 | 10 |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 if (succeeded && | 200 if (succeeded && |
201 !response_dict->GetBoolean(kSuccessValue, succeeded)) | 201 !response_dict->GetBoolean(kSuccessValue, succeeded)) |
202 *succeeded = false; | 202 *succeeded = false; |
203 return response_dict.Pass(); | 203 return response_dict.Pass(); |
204 } | 204 } |
205 | 205 |
206 std::string GetMultipartMimeType(const std::string& mime_boundary) { | 206 std::string GetMultipartMimeType(const std::string& mime_boundary) { |
207 return std::string("multipart/form-data; boundary=") + mime_boundary; | 207 return std::string("multipart/form-data; boundary=") + mime_boundary; |
208 } | 208 } |
209 | 209 |
210 // Create a MIME boundary marker (27 '-' characters followed by 16 hex digits). | |
211 void CreateMimeBoundaryForUpload(std::string* out) { | |
212 int r1 = base::RandInt(0, std::numeric_limits<int32_t>::max()); | |
213 int r2 = base::RandInt(0, std::numeric_limits<int32_t>::max()); | |
214 base::SStringPrintf(out, "---------------------------%08X%08X", r1, r2); | |
215 } | |
216 | |
217 std::string GetHashOfPrinterTags(const PrinterTags& printer_tags) { | 210 std::string GetHashOfPrinterTags(const PrinterTags& printer_tags) { |
218 return HashPrinterTags(PreparePrinterTags(printer_tags)); | 211 return HashPrinterTags(PreparePrinterTags(printer_tags)); |
219 } | 212 } |
220 | 213 |
221 std::string GetPostDataForPrinterTags( | 214 std::string GetPostDataForPrinterTags( |
222 const PrinterTags& printer_tags, | 215 const PrinterTags& printer_tags, |
223 const std::string& mime_boundary, | 216 const std::string& mime_boundary, |
224 const std::string& proxy_tag_prefix, | 217 const std::string& proxy_tag_prefix, |
225 const std::string& tags_hash_tag_name) { | 218 const std::string& tags_hash_tag_name) { |
226 PrinterTags printer_tags_prepared = PreparePrinterTags(printer_tags); | 219 PrinterTags printer_tags_prepared = PreparePrinterTags(printer_tags); |
(...skipping 18 matching lines...) Expand all Loading... |
245 net::AddMultipartValueForUpload(kPrinterTagValue, tags_hash_msg, | 238 net::AddMultipartValueForUpload(kPrinterTagValue, tags_hash_msg, |
246 mime_boundary, std::string(), &post_data); | 239 mime_boundary, std::string(), &post_data); |
247 return post_data; | 240 return post_data; |
248 } | 241 } |
249 | 242 |
250 std::string GetCloudPrintAuthHeader(const std::string& auth_token) { | 243 std::string GetCloudPrintAuthHeader(const std::string& auth_token) { |
251 return base::StringPrintf("Authorization: OAuth %s", auth_token.c_str()); | 244 return base::StringPrintf("Authorization: OAuth %s", auth_token.c_str()); |
252 } | 245 } |
253 | 246 |
254 } // namespace cloud_print | 247 } // namespace cloud_print |
OLD | NEW |