| 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 "base/json/json_reader.h" | 7 #include "base/json/json_reader.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/md5.h" | 9 #include "base/md5.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "base/rand_util.h" | 11 #include "base/rand_util.h" |
| 12 #include "base/strings/stringprintf.h" | 12 #include "base/strings/stringprintf.h" |
| 13 #include "base/sys_info.h" | 13 #include "base/sys_info.h" |
| 14 #include "base/values.h" | 14 #include "base/values.h" |
| 15 #include "chrome/common/chrome_version_info.h" | 15 #include "chrome/common/chrome_version_info.h" |
| 16 #include "chrome/common/cloud_print/cloud_print_constants.h" | 16 #include "chrome/common/cloud_print/cloud_print_constants.h" |
| 17 #include "net/base/mime_util.h" | 17 #include "net/base/mime_util.h" |
| 18 #include "url/gurl.h" | 18 #include "url/gurl.h" |
| 19 | 19 |
| 20 namespace cloud_print { | 20 namespace cloud_print { |
| 21 | 21 |
| 22 namespace { | 22 namespace { |
| 23 | 23 |
| 24 // Returns printer tags generated from |printer_tags| and the default tags | 24 // Returns printer tags generated from |printer_tags| and the default tags |
| 25 // required by cloud print server. | 25 // required by cloud print server. |
| 26 PrinterTags PreparePrinterTags(const PrinterTags& printer_tags) { | 26 PrinterTags PreparePrinterTags(const PrinterTags& printer_tags) { |
| 27 PrinterTags printer_tags_out = printer_tags; | 27 PrinterTags printer_tags_out = printer_tags; |
| 28 chrome::VersionInfo version_info; | 28 chrome::VersionInfo version_info; |
| 29 DCHECK(version_info.is_valid()); | |
| 30 printer_tags_out[kChromeVersionTagName] = | 29 printer_tags_out[kChromeVersionTagName] = |
| 31 version_info.CreateVersionString(); | 30 version_info.CreateVersionString(); |
| 32 printer_tags_out[kSystemNameTagName] = | 31 printer_tags_out[kSystemNameTagName] = |
| 33 base::SysInfo::OperatingSystemName(); | 32 base::SysInfo::OperatingSystemName(); |
| 34 printer_tags_out[kSystemVersionTagName] = | 33 printer_tags_out[kSystemVersionTagName] = |
| 35 base::SysInfo::OperatingSystemVersion(); | 34 base::SysInfo::OperatingSystemVersion(); |
| 36 return printer_tags_out; | 35 return printer_tags_out; |
| 37 } | 36 } |
| 38 | 37 |
| 39 // Returns the hash of |printer_tags|. | 38 // Returns the hash of |printer_tags|. |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 244 net::AddMultipartValueForUpload(kPrinterTagValue, tags_hash_msg, | 243 net::AddMultipartValueForUpload(kPrinterTagValue, tags_hash_msg, |
| 245 mime_boundary, std::string(), &post_data); | 244 mime_boundary, std::string(), &post_data); |
| 246 return post_data; | 245 return post_data; |
| 247 } | 246 } |
| 248 | 247 |
| 249 std::string GetCloudPrintAuthHeader(const std::string& auth_token) { | 248 std::string GetCloudPrintAuthHeader(const std::string& auth_token) { |
| 250 return base::StringPrintf("Authorization: OAuth %s", auth_token.c_str()); | 249 return base::StringPrintf("Authorization: OAuth %s", auth_token.c_str()); |
| 251 } | 250 } |
| 252 | 251 |
| 253 } // namespace cloud_print | 252 } // namespace cloud_print |
| OLD | NEW |