Commit 54311ec8 authored by pastarmovj's avatar pastarmovj Committed by Commit bot

Show the serial number of the device in the version string if available.

BUG=216422
TEST=manual.

Review URL: https://codereview.chromium.org/613653004

Cr-Commit-Position: refs/heads/master@{#297160}
parent 182d382a
......@@ -5032,7 +5032,7 @@ Battery full
Remove this user
</message>
<message name="IDS_LOGIN_VERSION_LABEL_FORMAT" desc="Login screen version text format.">
<ph name="PRODUCT_NAME">$1<ex>Google Chrome</ex></ph> <ph name="PRODUCT_VERSION">$2<ex>15.0.0.0</ex></ph> (Platform <ph name="PLATFORM_VERSION">$3<ex>900.0-11.09.01</ex></ph>)
<ph name="PRODUCT_NAME">$1<ex>Google Chrome</ex></ph> <ph name="PRODUCT_VERSION">$2<ex>15.0.0.0</ex></ph> (Platform <ph name="PLATFORM_VERSION">$3<ex>900.0-11.09.01</ex></ph>) <ph name="DEVICE_SERIAL_NUMBER">$4<ex>SN:123456789ABC</ex></ph>
</message>
<message name="IDS_DEVICE_OWNED_BY_NOTICE" desc="Text for notifications showing that this is managed device.">
This device is managed by <ph name="DOMAIN">$1<ex>acmecorp.com</ex></ph>.
......
......@@ -33,7 +33,10 @@ const char* kReportingFlags[] = {
chromeos::kReportDeviceLocation,
};
}
// Strings used to generate the serial number part of the version string.
const char kSerialNumberPrefix[] = "SN:";
} // namespace
///////////////////////////////////////////////////////////////////////////////
// VersionInfoUpdater public:
......@@ -92,12 +95,15 @@ void VersionInfoUpdater::UpdateVersionLabel() {
if (version_text_.empty())
return;
UpdateSerialNumberInfo();
chrome::VersionInfo version_info;
std::string label_text = l10n_util::GetStringFUTF8(
IDS_LOGIN_VERSION_LABEL_FORMAT,
l10n_util::GetStringUTF16(IDS_PRODUCT_NAME),
base::UTF8ToUTF16(version_info.Version()),
base::UTF8ToUTF16(version_text_));
base::UTF8ToUTF16(version_text_),
base::UTF8ToUTF16(serial_number_text_));
// Workaround over incorrect width calculation in old fonts.
// TODO(glotov): remove the following line when new fonts are used.
......@@ -124,6 +130,14 @@ void VersionInfoUpdater::SetEnterpriseInfo(const std::string& domain_name) {
}
}
void VersionInfoUpdater::UpdateSerialNumberInfo() {
std::string sn = policy::DeviceCloudPolicyManagerChromeOS::GetMachineID();
if (!sn.empty()) {
serial_number_text_ = kSerialNumberPrefix;
serial_number_text_.append(sn);
}
}
void VersionInfoUpdater::OnVersion(const std::string& version) {
version_text_ = version;
UpdateVersionLabel();
......
......@@ -59,6 +59,9 @@ class VersionInfoUpdater : public policy::CloudPolicyStore::Observer {
// Set enterprise domain name.
void SetEnterpriseInfo(const std::string& domain_name);
// Creates a serial number string.
void UpdateSerialNumberInfo();
// Callback from chromeos::VersionLoader giving the version.
void OnVersion(const std::string& version);
......@@ -71,6 +74,7 @@ class VersionInfoUpdater : public policy::CloudPolicyStore::Observer {
// Information pieces for version label.
std::string version_text_;
std::string serial_number_text_;
// Full text for the OS version label.
std::string os_version_label_text_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment