Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(607)

Side by Side Diff: chromeos/system/version_loader.cc

Issue 1905113002: Add ARC version to help and version pages (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "chromeos/system/version_loader.h" 5 #include "chromeos/system/version_loader.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <vector> 9 #include <vector>
10 10
(...skipping 11 matching lines...) Expand all
22 22
23 namespace { 23 namespace {
24 24
25 // Beginning of line we look for that gives full version number. 25 // Beginning of line we look for that gives full version number.
26 // Format: x.x.xx.x (Developer|Official build extra info) board info 26 // Format: x.x.xx.x (Developer|Official build extra info) board info
27 const char kFullVersionKey[] = "CHROMEOS_RELEASE_DESCRIPTION"; 27 const char kFullVersionKey[] = "CHROMEOS_RELEASE_DESCRIPTION";
28 28
29 // Same but for short version (x.x.xx.x). 29 // Same but for short version (x.x.xx.x).
30 const char kVersionKey[] = "CHROMEOS_RELEASE_VERSION"; 30 const char kVersionKey[] = "CHROMEOS_RELEASE_VERSION";
31 31
32 // Same but for ARC version.
33 const char kArcVersionKey[] = "CHROMEOS_ARC_VERSION";
34
32 // Beginning of line we look for that gives the firmware version. 35 // Beginning of line we look for that gives the firmware version.
33 const char kFirmwarePrefix[] = "version"; 36 const char kFirmwarePrefix[] = "version";
34 37
35 // File to look for firmware number in. 38 // File to look for firmware number in.
36 const char kPathFirmware[] = "/var/log/bios_info.txt"; 39 const char kPathFirmware[] = "/var/log/bios_info.txt";
37 40
38 } // namespace 41 } // namespace
39 42
40 std::string GetVersion(VersionFormat format) { 43 std::string GetVersion(VersionFormat format) {
41 std::string version; 44 std::string version;
42 std::string key = (format == VERSION_FULL ? 45 std::string key = (format == VERSION_FULL ?
43 kFullVersionKey : kVersionKey); 46 kFullVersionKey : kVersionKey);
44 if (!base::SysInfo::GetLsbReleaseValue(key, &version)) { 47 if (!base::SysInfo::GetLsbReleaseValue(key, &version)) {
45 LOG_IF(ERROR, base::SysInfo::IsRunningOnChromeOS()) 48 LOG_IF(ERROR, base::SysInfo::IsRunningOnChromeOS())
46 << "No LSB version key: " << key; 49 << "No LSB version key: " << key;
47 version = "0.0.0.0"; 50 version = "0.0.0.0";
48 } 51 }
49 if (format == VERSION_SHORT_WITH_DATE) { 52 if (format == VERSION_SHORT_WITH_DATE) {
50 base::Time::Exploded ctime; 53 base::Time::Exploded ctime;
51 base::SysInfo::GetLsbReleaseTime().UTCExplode(&ctime); 54 base::SysInfo::GetLsbReleaseTime().UTCExplode(&ctime);
52 version += base::StringPrintf("-%02u.%02u.%02u", 55 version += base::StringPrintf("-%02u.%02u.%02u",
53 ctime.year % 100, 56 ctime.year % 100,
54 ctime.month, 57 ctime.month,
55 ctime.day_of_month); 58 ctime.day_of_month);
56 } 59 }
57 60
58 return version; 61 return version;
59 } 62 }
60 63
64 std::string GetARCVersion() {
65 std::string version;
66 if (!base::SysInfo::GetLsbReleaseValue(kArcVersionKey, &version)) {
67 LOG_IF(ERROR, base::SysInfo::IsRunningOnChromeOS())
68 << "No LSB version key: " << kArcVersionKey;
69 version = "";
stevenjb 2016/04/21 19:38:54 nit: not strictly necessary, version will not be s
elijahtaylor1 2016/04/21 20:23:12 Done.
70 }
71 return version;
72 }
73
61 std::string GetFirmware() { 74 std::string GetFirmware() {
62 std::string firmware; 75 std::string firmware;
63 std::string contents; 76 std::string contents;
64 const base::FilePath file_path(kPathFirmware); 77 const base::FilePath file_path(kPathFirmware);
65 if (base::ReadFileToString(file_path, &contents)) { 78 if (base::ReadFileToString(file_path, &contents)) {
66 firmware = ParseFirmware(contents); 79 firmware = ParseFirmware(contents);
67 } 80 }
68 return firmware; 81 return firmware;
69 } 82 }
70 83
(...skipping 15 matching lines...) Expand all
86 size_t found = str.find_first_not_of("| "); 99 size_t found = str.find_first_not_of("| ");
87 if (found != std::string::npos) 100 if (found != std::string::npos)
88 return str.substr(found); 101 return str.substr(found);
89 } 102 }
90 } 103 }
91 return std::string(); 104 return std::string();
92 } 105 }
93 106
94 } // namespace version_loader 107 } // namespace version_loader
95 } // namespace chromeos 108 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698