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 "base/sys_info.h" | 5 #include "base/sys_info.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include "base/environment.h" | 10 #include "base/environment.h" |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 // static | 193 // static |
194 std::string SysInfo::GetLsbReleaseBoard() { | 194 std::string SysInfo::GetLsbReleaseBoard() { |
195 const char kMachineInfoBoard[] = "CHROMEOS_RELEASE_BOARD"; | 195 const char kMachineInfoBoard[] = "CHROMEOS_RELEASE_BOARD"; |
196 std::string board; | 196 std::string board; |
197 if (!GetLsbReleaseValue(kMachineInfoBoard, &board)) | 197 if (!GetLsbReleaseValue(kMachineInfoBoard, &board)) |
198 board = "unknown"; | 198 board = "unknown"; |
199 return board; | 199 return board; |
200 } | 200 } |
201 | 201 |
202 // static | 202 // static |
| 203 std::string SysInfo::GetStrippedReleaseBoard() { |
| 204 std::string board = GetLsbReleaseBoard(); |
| 205 const size_t index = board.find("-signed-"); |
| 206 if (index != std::string::npos) |
| 207 board.resize(index); |
| 208 |
| 209 return base::ToLowerASCII(board); |
| 210 } |
| 211 |
| 212 // static |
203 Time SysInfo::GetLsbReleaseTime() { | 213 Time SysInfo::GetLsbReleaseTime() { |
204 return GetChromeOSVersionInfo().lsb_release_time(); | 214 return GetChromeOSVersionInfo().lsb_release_time(); |
205 } | 215 } |
206 | 216 |
207 // static | 217 // static |
208 bool SysInfo::IsRunningOnChromeOS() { | 218 bool SysInfo::IsRunningOnChromeOS() { |
209 return GetChromeOSVersionInfo().is_running_on_chromeos(); | 219 return GetChromeOSVersionInfo().is_running_on_chromeos(); |
210 } | 220 } |
211 | 221 |
212 // static | 222 // static |
213 void SysInfo::SetChromeOSVersionInfoForTest(const std::string& lsb_release, | 223 void SysInfo::SetChromeOSVersionInfoForTest(const std::string& lsb_release, |
214 const Time& lsb_release_time) { | 224 const Time& lsb_release_time) { |
215 std::unique_ptr<Environment> env(Environment::Create()); | 225 std::unique_ptr<Environment> env(Environment::Create()); |
216 env->SetVar(kLsbReleaseKey, lsb_release); | 226 env->SetVar(kLsbReleaseKey, lsb_release); |
217 env->SetVar(kLsbReleaseTimeKey, | 227 env->SetVar(kLsbReleaseTimeKey, |
218 DoubleToString(lsb_release_time.ToDoubleT())); | 228 DoubleToString(lsb_release_time.ToDoubleT())); |
219 g_chrome_os_version_info.Get().Parse(); | 229 g_chrome_os_version_info.Get().Parse(); |
220 } | 230 } |
221 | 231 |
222 } // namespace base | 232 } // namespace base |
OLD | NEW |