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

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: . 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: ";
achuithb 2017/05/17 00:02:50 nit newline after this. This doesn't need to be l
xdai1 2017/05/17 23:55:43 I don't think it needs to be localized, especially
42 } // namespace 46 } // namespace
43 47
44 /////////////////////////////////////////////////////////////////////////////// 48 ///////////////////////////////////////////////////////////////////////////////
45 // VersionInfoUpdater public: 49 // VersionInfoUpdater public:
46 50
47 VersionInfoUpdater::VersionInfoUpdater(Delegate* delegate) 51 VersionInfoUpdater::VersionInfoUpdater(Delegate* delegate)
48 : cros_settings_(chromeos::CrosSettings::Get()), 52 : cros_settings_(chromeos::CrosSettings::Get()),
49 delegate_(delegate), 53 delegate_(delegate),
50 weak_pointer_factory_(this) { 54 weak_pointer_factory_(this) {
51 } 55 }
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 } 89 }
86 90
87 // Watch for changes to the reporting flags. 91 // Watch for changes to the reporting flags.
88 base::Closure callback = 92 base::Closure callback =
89 base::Bind(&VersionInfoUpdater::UpdateEnterpriseInfo, 93 base::Bind(&VersionInfoUpdater::UpdateEnterpriseInfo,
90 base::Unretained(this)); 94 base::Unretained(this));
91 for (unsigned int i = 0; i < arraysize(kReportingFlags); ++i) { 95 for (unsigned int i = 0; i < arraysize(kReportingFlags); ++i) {
92 subscriptions_.push_back( 96 subscriptions_.push_back(
93 cros_settings_->AddSettingsObserver(kReportingFlags[i], callback)); 97 cros_settings_->AddSettingsObserver(kReportingFlags[i], callback));
94 } 98 }
99
100 UpdateDeviceInfo();
95 } 101 }
96 102
97 void VersionInfoUpdater::UpdateVersionLabel() { 103 void VersionInfoUpdater::UpdateVersionLabel() {
98 if (version_text_.empty()) 104 if (version_text_.empty())
99 return; 105 return;
100 106
101 UpdateSerialNumberInfo(); 107 UpdateSerialNumberInfo();
102 108
103 std::string label_text = l10n_util::GetStringFUTF8( 109 std::string label_text = l10n_util::GetStringFUTF8(
104 IDS_LOGIN_VERSION_LABEL_FORMAT, 110 IDS_LOGIN_VERSION_LABEL_FORMAT,
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 serial_number_text_ = kSerialNumberPrefix; 145 serial_number_text_ = kSerialNumberPrefix;
140 serial_number_text_.append(serial); 146 serial_number_text_.append(serial);
141 } 147 }
142 } 148 }
143 149
144 void VersionInfoUpdater::OnVersion(const std::string& version) { 150 void VersionInfoUpdater::OnVersion(const std::string& version) {
145 version_text_ = version; 151 version_text_ = version;
146 UpdateVersionLabel(); 152 UpdateVersionLabel();
147 } 153 }
148 154
155 void VersionInfoUpdater::UpdateDeviceInfo() {
achuithb 2017/05/17 00:02:50 Why not get rid of this function since it's just o
xdai1 2017/05/17 23:55:43 Done.
156 device::BluetoothAdapterFactory::GetAdapter(base::Bind(
157 &VersionInfoUpdater::OnGetAdapter, weak_pointer_factory_.GetWeakPtr()));
158 }
159
160 void VersionInfoUpdater::OnGetAdapter(
161 scoped_refptr<device::BluetoothAdapter> adapter) {
162 if (delegate_ && adapter->IsDiscoverable() && !adapter->GetName().empty()) {
163 std::string bluetooth_name_text = kBluetoothDeviceNamePrefix;
164 bluetooth_name_text.append(adapter->GetName());
165 delegate_->OnDeviceInfoUpdated(bluetooth_name_text);
achuithb 2017/05/17 00:02:50 Why not delegate_->OnDeviceInfoUpdated(kBluetoothD
xdai1 2017/05/17 23:55:44 Done.
166 }
167 }
168
149 void VersionInfoUpdater::OnStoreLoaded(policy::CloudPolicyStore* store) { 169 void VersionInfoUpdater::OnStoreLoaded(policy::CloudPolicyStore* store) {
150 UpdateEnterpriseInfo(); 170 UpdateEnterpriseInfo();
151 } 171 }
152 172
153 void VersionInfoUpdater::OnStoreError(policy::CloudPolicyStore* store) { 173 void VersionInfoUpdater::OnStoreError(policy::CloudPolicyStore* store) {
154 UpdateEnterpriseInfo(); 174 UpdateEnterpriseInfo();
155 } 175 }
156 176
157 } // namespace chromeos 177 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698