OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/browser/component_updater/component_updater_utils.h" | 5 #include "chrome/browser/component_updater/component_updater_utils.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 | 8 |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
11 #include "base/guid.h" | 11 #include "base/guid.h" |
12 #include "base/strings/string_number_conversions.h" | 12 #include "base/strings/string_number_conversions.h" |
13 #include "base/strings/string_piece.h" | 13 #include "base/strings/string_piece.h" |
14 #include "base/strings/string_util.h" | 14 #include "base/strings/string_util.h" |
15 #include "base/strings/stringprintf.h" | 15 #include "base/strings/stringprintf.h" |
16 #include "base/sys_info.h" | 16 #include "base/sys_info.h" |
17 #include "base/win/windows_version.h" | 17 #include "base/win/windows_version.h" |
18 #include "chrome/browser/component_updater/crx_update_item.h" | 18 #include "chrome/browser/component_updater/crx_update_item.h" |
19 #include "chrome/browser/omaha_query_params/omaha_query_params.h" | 19 #include "chrome/browser/omaha_query_params/chrome_omaha_query_params_delegate.h
" |
20 #include "chrome/common/chrome_version_info.h" | 20 #include "chrome/common/chrome_version_info.h" |
| 21 #include "components/omaha_query_params/omaha_query_params.h" |
21 #include "extensions/common/extension.h" | 22 #include "extensions/common/extension.h" |
22 #include "net/base/load_flags.h" | 23 #include "net/base/load_flags.h" |
23 #include "net/url_request/url_fetcher.h" | 24 #include "net/url_request/url_fetcher.h" |
24 #include "net/url_request/url_request_context_getter.h" | 25 #include "net/url_request/url_request_context_getter.h" |
25 #include "net/url_request/url_request_status.h" | 26 #include "net/url_request/url_request_status.h" |
26 | 27 |
| 28 using omaha_query_params::OmahaQueryParams; |
| 29 |
27 namespace component_updater { | 30 namespace component_updater { |
28 | 31 |
29 namespace { | 32 namespace { |
30 | 33 |
31 // Returns the amount of physical memory in GB, rounded to the nearest GB. | 34 // Returns the amount of physical memory in GB, rounded to the nearest GB. |
32 int GetPhysicalMemoryGB() { | 35 int GetPhysicalMemoryGB() { |
33 const double kOneGB = 1024 * 1024 * 1024; | 36 const double kOneGB = 1024 * 1024 * 1024; |
34 const int64 phys_mem = base::SysInfo::AmountOfPhysicalMemory(); | 37 const int64 phys_mem = base::SysInfo::AmountOfPhysicalMemory(); |
35 return static_cast<int>(std::floor(0.5 + phys_mem / kOneGB)); | 38 return static_cast<int>(std::floor(0.5 + phys_mem / kOneGB)); |
36 } | 39 } |
37 | 40 |
38 } // namespace | 41 } // namespace |
39 | 42 |
40 std::string BuildProtocolRequest(const std::string& request_body, | 43 std::string BuildProtocolRequest(const std::string& request_body, |
41 const std::string& additional_attributes) { | 44 const std::string& additional_attributes) { |
42 const std::string prod_id(chrome::OmahaQueryParams::GetProdIdString( | 45 const std::string prod_id( |
43 chrome::OmahaQueryParams::CHROME)); | 46 OmahaQueryParams::GetProdIdString(OmahaQueryParams::CHROME)); |
44 const chrome::VersionInfo chrome_version_info; | 47 const chrome::VersionInfo chrome_version_info; |
45 const std::string chrome_version(chrome_version_info.Version()); | 48 const std::string chrome_version(chrome_version_info.Version()); |
| 49 const std::string channel(ChromeOmahaQueryParamsDelegate::GetChannelString()); |
| 50 const std::string lang(ChromeOmahaQueryParamsDelegate::GetLang()); |
46 | 51 |
47 std::string request( | 52 std::string request( |
48 "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" | 53 "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" |
49 "<request protocol=\"3.0\" "); | 54 "<request protocol=\"3.0\" "); |
50 | 55 |
51 if (!additional_attributes.empty()) | 56 if (!additional_attributes.empty()) |
52 base::StringAppendF(&request, "%s ", additional_attributes.c_str()); | 57 base::StringAppendF(&request, "%s ", additional_attributes.c_str()); |
53 | 58 |
54 // Chrome version and platform information. | 59 // Chrome version and platform information. |
55 base::StringAppendF( | 60 base::StringAppendF( |
56 &request, | 61 &request, |
57 "version=\"%s-%s\" prodversion=\"%s\" " | 62 "version=\"%s-%s\" prodversion=\"%s\" " |
58 "requestid=\"{%s}\" lang=\"%s\" updaterchannel=\"%s\" prodchannel=\"%s\" " | 63 "requestid=\"{%s}\" lang=\"%s\" updaterchannel=\"%s\" prodchannel=\"%s\" " |
59 "os=\"%s\" arch=\"%s\" nacl_arch=\"%s\"", | 64 "os=\"%s\" arch=\"%s\" nacl_arch=\"%s\"", |
60 prod_id.c_str(), | 65 prod_id.c_str(), |
61 chrome_version.c_str(), // "version" | 66 chrome_version.c_str(), // "version" |
62 chrome_version.c_str(), // "prodversion" | 67 chrome_version.c_str(), // "prodversion" |
63 base::GenerateGUID().c_str(), // "requestid" | 68 base::GenerateGUID().c_str(), // "requestid" |
64 chrome::OmahaQueryParams::GetLang(), // "lang", | 69 lang.c_str(), // "lang", |
65 chrome::OmahaQueryParams::GetChannelString(), // "updaterchannel" | 70 channel.c_str(), // "updaterchannel" |
66 chrome::OmahaQueryParams::GetChannelString(), // "prodchannel" | 71 channel.c_str(), // "prodchannel" |
67 chrome::OmahaQueryParams::GetOS(), // "os" | 72 OmahaQueryParams::GetOS(), // "os" |
68 chrome::OmahaQueryParams::GetArch(), // "arch" | 73 OmahaQueryParams::GetArch(), // "arch" |
69 chrome::OmahaQueryParams::GetNaclArch()); // "nacl_arch" | 74 OmahaQueryParams::GetNaclArch()); // "nacl_arch" |
70 #if defined(OS_WIN) | 75 #if defined(OS_WIN) |
71 const bool is_wow64(base::win::OSInfo::GetInstance()->wow64_status() == | 76 const bool is_wow64(base::win::OSInfo::GetInstance()->wow64_status() == |
72 base::win::OSInfo::WOW64_ENABLED); | 77 base::win::OSInfo::WOW64_ENABLED); |
73 if (is_wow64) | 78 if (is_wow64) |
74 base::StringAppendF(&request, " wow64=\"1\""); | 79 base::StringAppendF(&request, " wow64=\"1\""); |
75 #endif | 80 #endif |
76 base::StringAppendF(&request, ">"); | 81 base::StringAppendF(&request, ">"); |
77 | 82 |
78 // HW platform information. | 83 // HW platform information. |
79 base::StringAppendF(&request, | 84 base::StringAppendF(&request, |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 DCHECK(extensions::Extension::IdIsValid(id)); | 185 DCHECK(extensions::Extension::IdIsValid(id)); |
181 return id; | 186 return id; |
182 } | 187 } |
183 | 188 |
184 std::string GetCrxComponentID(const CrxComponent& component) { | 189 std::string GetCrxComponentID(const CrxComponent& component) { |
185 return HexStringToID(StringToLowerASCII( | 190 return HexStringToID(StringToLowerASCII( |
186 base::HexEncode(&component.pk_hash[0], component.pk_hash.size() / 2))); | 191 base::HexEncode(&component.pk_hash[0], component.pk_hash.size() / 2))); |
187 } | 192 } |
188 | 193 |
189 } // namespace component_updater | 194 } // namespace component_updater |
OLD | NEW |