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/channel_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 printer_tags_out[kChromeVersionTagName] = chrome::GetVersionString(); |
29 printer_tags_out[kChromeVersionTagName] = | |
30 version_info.CreateVersionString(); | |
31 printer_tags_out[kSystemNameTagName] = | 29 printer_tags_out[kSystemNameTagName] = |
32 base::SysInfo::OperatingSystemName(); | 30 base::SysInfo::OperatingSystemName(); |
33 printer_tags_out[kSystemVersionTagName] = | 31 printer_tags_out[kSystemVersionTagName] = |
34 base::SysInfo::OperatingSystemVersion(); | 32 base::SysInfo::OperatingSystemVersion(); |
35 return printer_tags_out; | 33 return printer_tags_out; |
36 } | 34 } |
37 | 35 |
38 // Returns the hash of |printer_tags|. | 36 // Returns the hash of |printer_tags|. |
39 std::string HashPrinterTags(const PrinterTags& printer_tags) { | 37 std::string HashPrinterTags(const PrinterTags& printer_tags) { |
40 std::string values_list; | 38 std::string values_list; |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 net::AddMultipartValueForUpload(kPrinterTagValue, tags_hash_msg, | 241 net::AddMultipartValueForUpload(kPrinterTagValue, tags_hash_msg, |
244 mime_boundary, std::string(), &post_data); | 242 mime_boundary, std::string(), &post_data); |
245 return post_data; | 243 return post_data; |
246 } | 244 } |
247 | 245 |
248 std::string GetCloudPrintAuthHeader(const std::string& auth_token) { | 246 std::string GetCloudPrintAuthHeader(const std::string& auth_token) { |
249 return base::StringPrintf("Authorization: OAuth %s", auth_token.c_str()); | 247 return base::StringPrintf("Authorization: OAuth %s", auth_token.c_str()); |
250 } | 248 } |
251 | 249 |
252 } // namespace cloud_print | 250 } // namespace cloud_print |
OLD | NEW |