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

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

Issue 2876753003: Bootstrapping: Display Bluetooth name of CrOS device on OOBE screen. (Closed)
Patch Set: Address achuith@'s comments. Created 3 years, 7 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) 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 "ash/strings/grit/ash_strings.h" 9 #include "ash/strings/grit/ash_strings.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/bind_helpers.h" 11 #include "base/bind_helpers.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/memory/ptr_util.h" 13 #include "base/memory/ptr_util.h"
14 #include "base/strings/string_util.h" 14 #include "base/strings/string_util.h"
15 #include "base/strings/utf_string_conversions.h" 15 #include "base/strings/utf_string_conversions.h"
16 #include "base/sys_info.h" 16 #include "base/sys_info.h"
17 #include "base/task_scheduler/post_task.h" 17 #include "base/task_scheduler/post_task.h"
18 #include "chrome/browser/browser_process.h" 18 #include "chrome/browser/browser_process.h"
19 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" 19 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h"
20 #include "chrome/browser/chromeos/settings/cros_settings.h" 20 #include "chrome/browser/chromeos/settings/cros_settings.h"
21 #include "chrome/grit/chromium_strings.h" 21 #include "chrome/grit/chromium_strings.h"
22 #include "chrome/grit/generated_resources.h" 22 #include "chrome/grit/generated_resources.h"
23 #include "chromeos/settings/cros_settings_names.h" 23 #include "chromeos/settings/cros_settings_names.h"
24 #include "chromeos/system/statistics_provider.h" 24 #include "chromeos/system/statistics_provider.h"
25 #include "components/version_info/version_info.h" 25 #include "components/version_info/version_info.h"
26 #include "device/bluetooth/bluetooth_adapter.h"
27 #include "device/bluetooth/bluetooth_adapter_factory.h"
26 #include "ui/base/l10n/l10n_util.h" 28 #include "ui/base/l10n/l10n_util.h"
27 29
28 namespace chromeos { 30 namespace chromeos {
29 31
30 namespace { 32 namespace {
31 33
32 const char* const kReportingFlags[] = { 34 const char* const kReportingFlags[] = {
33 chromeos::kReportDeviceVersionInfo, 35 chromeos::kReportDeviceVersionInfo,
34 chromeos::kReportDeviceActivityTimes, 36 chromeos::kReportDeviceActivityTimes,
35 chromeos::kReportDeviceBootMode, 37 chromeos::kReportDeviceBootMode,
36 chromeos::kReportDeviceLocation, 38 chromeos::kReportDeviceLocation,
37 }; 39 };
38 40
39 // Strings used to generate the serial number part of the version string. 41 // Strings used to generate the serial number part of the version string.
40 const char kSerialNumberPrefix[] = "SN:"; 42 const char kSerialNumberPrefix[] = "SN:";
41 43
44 // Strings used to generate the bluetooth device name.
45 const char kBluetoothDeviceNamePrefix[] = "Bluetooth device name: ";
46
42 } // namespace 47 } // namespace
43 48
44 /////////////////////////////////////////////////////////////////////////////// 49 ///////////////////////////////////////////////////////////////////////////////
45 // VersionInfoUpdater public: 50 // VersionInfoUpdater public:
46 51
47 VersionInfoUpdater::VersionInfoUpdater(Delegate* delegate) 52 VersionInfoUpdater::VersionInfoUpdater(Delegate* delegate)
48 : cros_settings_(chromeos::CrosSettings::Get()), 53 : cros_settings_(chromeos::CrosSettings::Get()),
49 delegate_(delegate), 54 delegate_(delegate),
50 weak_pointer_factory_(this) { 55 weak_pointer_factory_(this) {
51 } 56 }
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 } 90 }
86 91
87 // Watch for changes to the reporting flags. 92 // Watch for changes to the reporting flags.
88 base::Closure callback = 93 base::Closure callback =
89 base::Bind(&VersionInfoUpdater::UpdateEnterpriseInfo, 94 base::Bind(&VersionInfoUpdater::UpdateEnterpriseInfo,
90 base::Unretained(this)); 95 base::Unretained(this));
91 for (unsigned int i = 0; i < arraysize(kReportingFlags); ++i) { 96 for (unsigned int i = 0; i < arraysize(kReportingFlags); ++i) {
92 subscriptions_.push_back( 97 subscriptions_.push_back(
93 cros_settings_->AddSettingsObserver(kReportingFlags[i], callback)); 98 cros_settings_->AddSettingsObserver(kReportingFlags[i], callback));
94 } 99 }
100
101 // Update device bluetooth info.
102 device::BluetoothAdapterFactory::GetAdapter(base::Bind(
103 &VersionInfoUpdater::OnGetAdapter, weak_pointer_factory_.GetWeakPtr()));
95 } 104 }
96 105
97 void VersionInfoUpdater::UpdateVersionLabel() { 106 void VersionInfoUpdater::UpdateVersionLabel() {
98 if (version_text_.empty()) 107 if (version_text_.empty())
99 return; 108 return;
100 109
101 UpdateSerialNumberInfo(); 110 UpdateSerialNumberInfo();
102 111
103 std::string label_text = l10n_util::GetStringFUTF8( 112 std::string label_text = l10n_util::GetStringFUTF8(
104 IDS_LOGIN_VERSION_LABEL_FORMAT, 113 IDS_LOGIN_VERSION_LABEL_FORMAT,
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 serial_number_text_ = kSerialNumberPrefix; 148 serial_number_text_ = kSerialNumberPrefix;
140 serial_number_text_.append(serial); 149 serial_number_text_.append(serial);
141 } 150 }
142 } 151 }
143 152
144 void VersionInfoUpdater::OnVersion(const std::string& version) { 153 void VersionInfoUpdater::OnVersion(const std::string& version) {
145 version_text_ = version; 154 version_text_ = version;
146 UpdateVersionLabel(); 155 UpdateVersionLabel();
147 } 156 }
148 157
158 void VersionInfoUpdater::OnGetAdapter(
159 scoped_refptr<device::BluetoothAdapter> adapter) {
160 if (delegate_ && adapter->IsDiscoverable() && !adapter->GetName().empty()) {
161 delegate_->OnDeviceInfoUpdated(kBluetoothDeviceNamePrefix +
162 adapter->GetName());
163 }
164 }
165
149 void VersionInfoUpdater::OnStoreLoaded(policy::CloudPolicyStore* store) { 166 void VersionInfoUpdater::OnStoreLoaded(policy::CloudPolicyStore* store) {
150 UpdateEnterpriseInfo(); 167 UpdateEnterpriseInfo();
151 } 168 }
152 169
153 void VersionInfoUpdater::OnStoreError(policy::CloudPolicyStore* store) { 170 void VersionInfoUpdater::OnStoreError(policy::CloudPolicyStore* store) {
154 UpdateEnterpriseInfo(); 171 UpdateEnterpriseInfo();
155 } 172 }
156 173
157 } // namespace chromeos 174 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/version_info_updater.h ('k') | chrome/browser/resources/chromeos/login/login_shared.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698