| 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 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 return scoped_ptr<base::DictionaryValue>(); | 193 return scoped_ptr<base::DictionaryValue>(); |
| 194 | 194 |
| 195 if (!message_value->IsType(base::Value::TYPE_DICTIONARY)) | 195 if (!message_value->IsType(base::Value::TYPE_DICTIONARY)) |
| 196 return scoped_ptr<base::DictionaryValue>(); | 196 return scoped_ptr<base::DictionaryValue>(); |
| 197 | 197 |
| 198 scoped_ptr<base::DictionaryValue> response_dict( | 198 scoped_ptr<base::DictionaryValue> response_dict( |
| 199 static_cast<base::DictionaryValue*>(message_value.release())); | 199 static_cast<base::DictionaryValue*>(message_value.release())); |
| 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; |
| 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). | 210 // Create a MIME boundary marker (27 '-' characters followed by 16 hex digits). |
| 211 void CreateMimeBoundaryForUpload(std::string* out) { | 211 void CreateMimeBoundaryForUpload(std::string* out) { |
| 212 int r1 = base::RandInt(0, std::numeric_limits<int32_t>::max()); | 212 int r1 = base::RandInt(0, std::numeric_limits<int32_t>::max()); |
| 213 int r2 = base::RandInt(0, std::numeric_limits<int32_t>::max()); | 213 int r2 = base::RandInt(0, std::numeric_limits<int32_t>::max()); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 net::AddMultipartValueForUpload(kPrinterTagValue, tags_hash_msg, | 245 net::AddMultipartValueForUpload(kPrinterTagValue, tags_hash_msg, |
| 246 mime_boundary, std::string(), &post_data); | 246 mime_boundary, std::string(), &post_data); |
| 247 return post_data; | 247 return post_data; |
| 248 } | 248 } |
| 249 | 249 |
| 250 std::string GetCloudPrintAuthHeader(const std::string& auth_token) { | 250 std::string GetCloudPrintAuthHeader(const std::string& auth_token) { |
| 251 return base::StringPrintf("Authorization: OAuth %s", auth_token.c_str()); | 251 return base::StringPrintf("Authorization: OAuth %s", auth_token.c_str()); |
| 252 } | 252 } |
| 253 | 253 |
| 254 } // namespace cloud_print | 254 } // namespace cloud_print |
| OLD | NEW |