OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/update_client/utils.h" | 5 #include "components/update_client/utils.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 } else { | 59 } else { |
60 id.append(1, 'a'); | 60 id.append(1, 'a'); |
61 } | 61 } |
62 } | 62 } |
63 | 63 |
64 DCHECK(crx_file::id_util::IdIsValid(id)); | 64 DCHECK(crx_file::id_util::IdIsValid(id)); |
65 | 65 |
66 return id; | 66 return id; |
67 } | 67 } |
68 | 68 |
| 69 std::string GetOSVersion() { |
| 70 #if defined(OS_WIN) |
| 71 int32_t major = 0; |
| 72 int32_t minor = 0; |
| 73 int32_t bugfix = 0; |
| 74 base::SysInfo::OperatingSystemVersionNumbers(&major, &minor, &bugfix); |
| 75 return base::StringPrintf("%d.%d.%d", major, minor, bugfix); |
| 76 #else |
| 77 return base::SysInfo().OperatingSystemVersion(); |
| 78 #endif |
| 79 } |
| 80 |
| 81 std::string GetServicePack() { |
| 82 #if defined(OS_WIN) |
| 83 return base::win::OSInfo::GetInstance()->service_pack_str(); |
| 84 #else |
| 85 return std::string(); |
| 86 #endif |
| 87 } |
| 88 |
69 } // namespace | 89 } // namespace |
70 | 90 |
71 std::string BuildProtocolRequest(const std::string& prod_id, | 91 std::string BuildProtocolRequest(const std::string& prod_id, |
72 const std::string& browser_version, | 92 const std::string& browser_version, |
73 const std::string& channel, | 93 const std::string& channel, |
74 const std::string& lang, | 94 const std::string& lang, |
75 const std::string& os_long_name, | 95 const std::string& os_long_name, |
76 const std::string& download_preference, | 96 const std::string& download_preference, |
77 const std::string& request_body, | 97 const std::string& request_body, |
78 const std::string& additional_attributes) { | 98 const std::string& additional_attributes) { |
(...skipping 29 matching lines...) Expand all Loading... |
108 if (!download_preference.empty()) | 128 if (!download_preference.empty()) |
109 base::StringAppendF(&request, " dlpref=\"%s\"", | 129 base::StringAppendF(&request, " dlpref=\"%s\"", |
110 download_preference.c_str()); | 130 download_preference.c_str()); |
111 base::StringAppendF(&request, ">"); | 131 base::StringAppendF(&request, ">"); |
112 | 132 |
113 // HW platform information. | 133 // HW platform information. |
114 base::StringAppendF(&request, "<hw physmemory=\"%d\"/>", | 134 base::StringAppendF(&request, "<hw physmemory=\"%d\"/>", |
115 GetPhysicalMemoryGB()); // "physmem" in GB. | 135 GetPhysicalMemoryGB()); // "physmem" in GB. |
116 | 136 |
117 // OS version and platform information. | 137 // OS version and platform information. |
| 138 const std::string os_version = GetOSVersion(); |
| 139 const std::string os_sp = GetServicePack(); |
| 140 |
118 base::StringAppendF( | 141 base::StringAppendF( |
119 &request, "<os platform=\"%s\" version=\"%s\" arch=\"%s\"/>", | 142 &request, "<os platform=\"%s\" arch=\"%s\"", |
120 os_long_name.c_str(), // "platform" | 143 os_long_name.c_str(), // "platform" |
121 base::SysInfo().OperatingSystemVersion().c_str(), // "version" | |
122 base::SysInfo().OperatingSystemArchitecture().c_str()); // "arch" | 144 base::SysInfo().OperatingSystemArchitecture().c_str()); // "arch" |
| 145 if (!os_version.empty()) |
| 146 base::StringAppendF(&request, " version=\"%s\"", os_version.c_str()); |
| 147 if (!os_sp.empty()) |
| 148 base::StringAppendF(&request, " sp=\"%s\"", os_sp.c_str()); |
| 149 base::StringAppendF(&request, "/>"); |
123 | 150 |
124 // The actual payload of the request. | 151 // The actual payload of the request. |
125 base::StringAppendF(&request, "%s</request>", request_body.c_str()); | 152 base::StringAppendF(&request, "%s</request>", request_body.c_str()); |
126 | 153 |
127 return request; | 154 return request; |
128 } | 155 } |
129 | 156 |
130 std::unique_ptr<net::URLFetcher> SendProtocolRequest( | 157 std::unique_ptr<net::URLFetcher> SendProtocolRequest( |
131 const GURL& url, | 158 const GURL& url, |
132 const std::string& protocol_request, | 159 const std::string& protocol_request, |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 | 304 |
278 void RemoveUnsecureUrls(std::vector<GURL>* urls) { | 305 void RemoveUnsecureUrls(std::vector<GURL>* urls) { |
279 DCHECK(urls); | 306 DCHECK(urls); |
280 urls->erase(std::remove_if( | 307 urls->erase(std::remove_if( |
281 urls->begin(), urls->end(), | 308 urls->begin(), urls->end(), |
282 [](const GURL& url) { return !url.SchemeIsCryptographic(); }), | 309 [](const GURL& url) { return !url.SchemeIsCryptographic(); }), |
283 urls->end()); | 310 urls->end()); |
284 } | 311 } |
285 | 312 |
286 } // namespace update_client | 313 } // namespace update_client |
OLD | NEW |