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