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

Side by Side Diff: chrome/browser/chromeos/login/version_info_updater.cc

Issue 613653004: Show the serial number of the device in the version string if available. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 6 years, 2 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
« no previous file with comments | « chrome/browser/chromeos/login/version_info_updater.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "chrome/browser/chromeos/login/version_info_updater.h" 5 #include "chrome/browser/chromeos/login/version_info_updater.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 15 matching lines...) Expand all
26 26
27 namespace { 27 namespace {
28 28
29 const char* kReportingFlags[] = { 29 const char* kReportingFlags[] = {
30 chromeos::kReportDeviceVersionInfo, 30 chromeos::kReportDeviceVersionInfo,
31 chromeos::kReportDeviceActivityTimes, 31 chromeos::kReportDeviceActivityTimes,
32 chromeos::kReportDeviceBootMode, 32 chromeos::kReportDeviceBootMode,
33 chromeos::kReportDeviceLocation, 33 chromeos::kReportDeviceLocation,
34 }; 34 };
35 35
36 } 36 // Strings used to generate the serial number part of the version string.
37 const char kSerialNumberPrefix[] = "SN:";
38
39 } // namespace
37 40
38 /////////////////////////////////////////////////////////////////////////////// 41 ///////////////////////////////////////////////////////////////////////////////
39 // VersionInfoUpdater public: 42 // VersionInfoUpdater public:
40 43
41 VersionInfoUpdater::VersionInfoUpdater(Delegate* delegate) 44 VersionInfoUpdater::VersionInfoUpdater(Delegate* delegate)
42 : cros_settings_(chromeos::CrosSettings::Get()), 45 : cros_settings_(chromeos::CrosSettings::Get()),
43 delegate_(delegate), 46 delegate_(delegate),
44 weak_pointer_factory_(this) { 47 weak_pointer_factory_(this) {
45 } 48 }
46 49
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 subscriptions_.push_back( 88 subscriptions_.push_back(
86 cros_settings_->AddSettingsObserver(kReportingFlags[i], 89 cros_settings_->AddSettingsObserver(kReportingFlags[i],
87 callback).release()); 90 callback).release());
88 } 91 }
89 } 92 }
90 93
91 void VersionInfoUpdater::UpdateVersionLabel() { 94 void VersionInfoUpdater::UpdateVersionLabel() {
92 if (version_text_.empty()) 95 if (version_text_.empty())
93 return; 96 return;
94 97
98 UpdateSerialNumberInfo();
99
95 chrome::VersionInfo version_info; 100 chrome::VersionInfo version_info;
96 std::string label_text = l10n_util::GetStringFUTF8( 101 std::string label_text = l10n_util::GetStringFUTF8(
97 IDS_LOGIN_VERSION_LABEL_FORMAT, 102 IDS_LOGIN_VERSION_LABEL_FORMAT,
98 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME), 103 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME),
99 base::UTF8ToUTF16(version_info.Version()), 104 base::UTF8ToUTF16(version_info.Version()),
100 base::UTF8ToUTF16(version_text_)); 105 base::UTF8ToUTF16(version_text_),
106 base::UTF8ToUTF16(serial_number_text_));
101 107
102 // Workaround over incorrect width calculation in old fonts. 108 // Workaround over incorrect width calculation in old fonts.
103 // TODO(glotov): remove the following line when new fonts are used. 109 // TODO(glotov): remove the following line when new fonts are used.
104 label_text += ' '; 110 label_text += ' ';
105 111
106 if (delegate_) 112 if (delegate_)
107 delegate_->OnOSVersionLabelTextUpdated(label_text); 113 delegate_->OnOSVersionLabelTextUpdated(label_text);
108 } 114 }
109 115
110 void VersionInfoUpdater::UpdateEnterpriseInfo() { 116 void VersionInfoUpdater::UpdateEnterpriseInfo() {
111 policy::BrowserPolicyConnectorChromeOS* connector = 117 policy::BrowserPolicyConnectorChromeOS* connector =
112 g_browser_process->platform_part()->browser_policy_connector_chromeos(); 118 g_browser_process->platform_part()->browser_policy_connector_chromeos();
113 SetEnterpriseInfo(connector->GetEnterpriseDomain()); 119 SetEnterpriseInfo(connector->GetEnterpriseDomain());
114 } 120 }
115 121
116 void VersionInfoUpdater::SetEnterpriseInfo(const std::string& domain_name) { 122 void VersionInfoUpdater::SetEnterpriseInfo(const std::string& domain_name) {
117 // Update the notification about device status reporting. 123 // Update the notification about device status reporting.
118 if (delegate_ && !domain_name.empty()) { 124 if (delegate_ && !domain_name.empty()) {
119 std::string enterprise_info; 125 std::string enterprise_info;
120 enterprise_info = l10n_util::GetStringFUTF8( 126 enterprise_info = l10n_util::GetStringFUTF8(
121 IDS_DEVICE_OWNED_BY_NOTICE, 127 IDS_DEVICE_OWNED_BY_NOTICE,
122 base::UTF8ToUTF16(domain_name)); 128 base::UTF8ToUTF16(domain_name));
123 delegate_->OnEnterpriseInfoUpdated(enterprise_info); 129 delegate_->OnEnterpriseInfoUpdated(enterprise_info);
124 } 130 }
125 } 131 }
126 132
133 void VersionInfoUpdater::UpdateSerialNumberInfo() {
134 std::string sn = policy::DeviceCloudPolicyManagerChromeOS::GetMachineID();
135 if (!sn.empty()) {
136 serial_number_text_ = kSerialNumberPrefix;
137 serial_number_text_.append(sn);
138 }
139 }
140
127 void VersionInfoUpdater::OnVersion(const std::string& version) { 141 void VersionInfoUpdater::OnVersion(const std::string& version) {
128 version_text_ = version; 142 version_text_ = version;
129 UpdateVersionLabel(); 143 UpdateVersionLabel();
130 } 144 }
131 145
132 void VersionInfoUpdater::OnStoreLoaded(policy::CloudPolicyStore* store) { 146 void VersionInfoUpdater::OnStoreLoaded(policy::CloudPolicyStore* store) {
133 UpdateEnterpriseInfo(); 147 UpdateEnterpriseInfo();
134 } 148 }
135 149
136 void VersionInfoUpdater::OnStoreError(policy::CloudPolicyStore* store) { 150 void VersionInfoUpdater::OnStoreError(policy::CloudPolicyStore* store) {
137 UpdateEnterpriseInfo(); 151 UpdateEnterpriseInfo();
138 } 152 }
139 153
140 } // namespace chromeos 154 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/version_info_updater.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698