Chromium Code Reviews| Index: base/sys_info_chromeos.cc |
| diff --git a/base/sys_info_chromeos.cc b/base/sys_info_chromeos.cc |
| index 8d464db128c1d52fb842b68be5ff7f386372375b..4cdc9bca86a6177c6065f3f85d8af65080467079 100644 |
| --- a/base/sys_info_chromeos.cc |
| +++ b/base/sys_info_chromeos.cc |
| @@ -28,6 +28,14 @@ const char* kLinuxStandardBaseVersionKeys[] = { |
| const size_t kLinuxStandardBaseVersionKeysLength = |
| arraysize(kLinuxStandardBaseVersionKeys); |
| +static const char* kChromeOsReleaseNameKey = "CHROMEOS_RELEASE_NAME"; |
|
satorux1
2013/09/24 04:09:01
nit: 'static' is unnecessary.
const char kChromeO
stevenjb
2013/09/26 22:07:38
Oops, thanks for catching. Done.
|
| + |
| +const char* kChromeOsReleaseNames[] = { |
| + "Chrome OS", |
| + "Chromium OS", |
| +}; |
| +const size_t kChromeOsReleaseNamesLength = arraysize(kChromeOsReleaseNames); |
| + |
| const char kLinuxStandardBaseReleaseFile[] = "/etc/lsb-release"; |
| class ChromeOSVersionInfo { |
| @@ -41,6 +49,7 @@ class ChromeOSVersionInfo { |
| major_version_ = 0; |
| minor_version_ = 0; |
| bugfix_version_ = 0; |
| + is_running_on_chromeos_ = false; |
| std::string lsb_release, lsb_release_time_str; |
| scoped_ptr<base::Environment> env(base::Environment::Create()); |
| @@ -87,6 +96,7 @@ class ChromeOSVersionInfo { |
| const SysInfo::LsbReleaseMap& lsb_release_map() const { |
| return lsb_release_map_; |
| } |
| + bool is_running_on_chromeos() const { return is_running_on_chromeos_; } |
| private: |
| void ParseLsbRelease(const std::string& lsb_release) { |
| @@ -121,6 +131,17 @@ class ChromeOSVersionInfo { |
| StringToInt(StringPiece(tokenizer.token_begin(), tokenizer.token_end()), |
| &bugfix_version_); |
| } |
| + |
| + // Check release name for Chrome OS. |
| + std::string release_name; |
| + if (GetLsbReleaseValue(kChromeOsReleaseNameKey, &release_name)) { |
| + for (size_t i = 0; i < kChromeOsReleaseNamesLength; ++i) { |
|
satorux1
2013/09/24 04:09:01
remove kChromeOsReleaseNamesLength?
arraysize(kCh
stevenjb
2013/09/26 22:07:38
Done.
|
| + if (release_name == kChromeOsReleaseNames[i]) { |
| + is_running_on_chromeos_ = true; |
| + break; |
| + } |
| + } |
| + } |
| } |
| base::Time lsb_release_time_; |
| @@ -128,6 +149,7 @@ class ChromeOSVersionInfo { |
| int32 major_version_; |
| int32 minor_version_; |
| int32 bugfix_version_; |
| + bool is_running_on_chromeos_; |
| }; |
| static LazyInstance<ChromeOSVersionInfo> |
| @@ -172,6 +194,11 @@ base::Time SysInfo::GetLsbReleaseTime() { |
| } |
| // static |
| +bool SysInfo::IsRunningOnChromeOS() { |
| + return GetChromeOSVersionInfo().is_running_on_chromeos(); |
| +} |
| + |
| +// static |
| void SysInfo::SetChromeOSVersionInfoForTest(const std::string& lsb_release, |
| double lsb_release_time) { |
| scoped_ptr<base::Environment> env(base::Environment::Create()); |