OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/screens/hid_detection_screen.h" | 5 #include "chrome/browser/chromeos/login/screens/hid_detection_screen.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 on_check_done)); | 158 on_check_done)); |
159 } | 159 } |
160 | 160 |
161 void HIDDetectionScreen::OnViewDestroyed(HIDDetectionView* view) { | 161 void HIDDetectionScreen::OnViewDestroyed(HIDDetectionView* view) { |
162 if (view_ == view) | 162 if (view_ == view) |
163 view_ = NULL; | 163 view_ = NULL; |
164 } | 164 } |
165 | 165 |
166 void HIDDetectionScreen::RequestPinCode(device::BluetoothDevice* device) { | 166 void HIDDetectionScreen::RequestPinCode(device::BluetoothDevice* device) { |
167 VLOG(1) << "RequestPinCode id = " << device->GetDeviceID() | 167 VLOG(1) << "RequestPinCode id = " << device->GetDeviceID() |
168 << " name = " << device->GetName(); | 168 << " name = " << device->GetNameForDisplay(); |
169 device->CancelPairing(); | 169 device->CancelPairing(); |
170 } | 170 } |
171 | 171 |
172 void HIDDetectionScreen::RequestPasskey(device::BluetoothDevice* device) { | 172 void HIDDetectionScreen::RequestPasskey(device::BluetoothDevice* device) { |
173 VLOG(1) << "RequestPassKey id = " << device->GetDeviceID() | 173 VLOG(1) << "RequestPassKey id = " << device->GetDeviceID() |
174 << " name = " << device->GetName(); | 174 << " name = " << device->GetNameForDisplay(); |
175 device->CancelPairing(); | 175 device->CancelPairing(); |
176 } | 176 } |
177 | 177 |
178 void HIDDetectionScreen::DisplayPinCode(device::BluetoothDevice* device, | 178 void HIDDetectionScreen::DisplayPinCode(device::BluetoothDevice* device, |
179 const std::string& pincode) { | 179 const std::string& pincode) { |
180 VLOG(1) << "DisplayPinCode id = " << device->GetDeviceID() | 180 VLOG(1) << "DisplayPinCode id = " << device->GetDeviceID() |
181 << " name = " << device->GetName(); | 181 << " name = " << device->GetNameForDisplay(); |
182 GetContextEditor().SetString(kContextKeyPinCode, pincode); | 182 GetContextEditor().SetString(kContextKeyPinCode, pincode); |
183 SetKeyboardDeviceName_(base::UTF16ToUTF8(device->GetName())); | 183 SetKeyboardDeviceName_(base::UTF16ToUTF8(device->GetNameForDisplay())); |
184 SendKeyboardDeviceNotification(); | 184 SendKeyboardDeviceNotification(); |
185 } | 185 } |
186 | 186 |
187 void HIDDetectionScreen::DisplayPasskey(device::BluetoothDevice* device, | 187 void HIDDetectionScreen::DisplayPasskey(device::BluetoothDevice* device, |
188 uint32_t passkey) { | 188 uint32_t passkey) { |
189 VLOG(1) << "DisplayPassKey id = " << device->GetDeviceID() | 189 VLOG(1) << "DisplayPassKey id = " << device->GetDeviceID() |
190 << " name = " << device->GetName(); | 190 << " name = " << device->GetNameForDisplay(); |
191 std::string pincode = base::UintToString(passkey); | 191 std::string pincode = base::UintToString(passkey); |
192 pincode = std::string(kPincodeLength - pincode.length(), '0').append(pincode); | 192 pincode = std::string(kPincodeLength - pincode.length(), '0').append(pincode); |
193 // No differences in UI for passkey and pincode authentication calls. | 193 // No differences in UI for passkey and pincode authentication calls. |
194 DisplayPinCode(device, pincode); | 194 DisplayPinCode(device, pincode); |
195 } | 195 } |
196 | 196 |
197 void HIDDetectionScreen::KeysEntered(device::BluetoothDevice* device, | 197 void HIDDetectionScreen::KeysEntered(device::BluetoothDevice* device, |
198 uint32_t entered) { | 198 uint32_t entered) { |
199 VLOG(1) << "Number of keys entered " << entered; | 199 VLOG(1) << "Number of keys entered " << entered; |
200 GetContextEditor() | 200 GetContextEditor() |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
367 | 367 |
368 void HIDDetectionScreen::SetKeyboardDeviceName_(const std::string& name) { | 368 void HIDDetectionScreen::SetKeyboardDeviceName_(const std::string& name) { |
369 keyboard_device_name_ = | 369 keyboard_device_name_ = |
370 keyboard_device_id_.empty() || !name.empty() | 370 keyboard_device_id_.empty() || !name.empty() |
371 ? name | 371 ? name |
372 : l10n_util::GetStringUTF8(IDS_HID_DETECTION_DEFAULT_KEYBOARD_NAME); | 372 : l10n_util::GetStringUTF8(IDS_HID_DETECTION_DEFAULT_KEYBOARD_NAME); |
373 } | 373 } |
374 | 374 |
375 void HIDDetectionScreen::DeviceAdded( | 375 void HIDDetectionScreen::DeviceAdded( |
376 device::BluetoothAdapter* adapter, device::BluetoothDevice* device) { | 376 device::BluetoothAdapter* adapter, device::BluetoothDevice* device) { |
377 VLOG(1) << "BT input device added id = " << device->GetDeviceID() << | 377 VLOG(1) << "BT input device added id = " << device->GetDeviceID() |
378 " name = " << device->GetName(); | 378 << " name = " << device->GetNameForDisplay(); |
379 TryPairingAsPointingDevice(device); | 379 TryPairingAsPointingDevice(device); |
380 TryPairingAsKeyboardDevice(device); | 380 TryPairingAsKeyboardDevice(device); |
381 } | 381 } |
382 | 382 |
383 void HIDDetectionScreen::DeviceChanged( | 383 void HIDDetectionScreen::DeviceChanged( |
384 device::BluetoothAdapter* adapter, device::BluetoothDevice* device) { | 384 device::BluetoothAdapter* adapter, device::BluetoothDevice* device) { |
385 VLOG(1) << "BT device changed id = " << device->GetDeviceID() << " name = " << | 385 VLOG(1) << "BT device changed id = " << device->GetDeviceID() |
386 device->GetName(); | 386 << " name = " << device->GetNameForDisplay(); |
387 TryPairingAsPointingDevice(device); | 387 TryPairingAsPointingDevice(device); |
388 TryPairingAsKeyboardDevice(device); | 388 TryPairingAsKeyboardDevice(device); |
389 } | 389 } |
390 | 390 |
391 void HIDDetectionScreen::DeviceRemoved( | 391 void HIDDetectionScreen::DeviceRemoved( |
392 device::BluetoothAdapter* adapter, device::BluetoothDevice* device) { | 392 device::BluetoothAdapter* adapter, device::BluetoothDevice* device) { |
393 VLOG(1) << "BT device removed id = " << device->GetDeviceID() << " name = " << | 393 VLOG(1) << "BT device removed id = " << device->GetDeviceID() |
394 device->GetName(); | 394 << " name = " << device->GetNameForDisplay(); |
395 } | 395 } |
396 | 396 |
397 void HIDDetectionScreen::OnInputDeviceAdded( | 397 void HIDDetectionScreen::OnInputDeviceAdded( |
398 const InputDeviceInfo& info) { | 398 const InputDeviceInfo& info) { |
399 VLOG(1) << "Input device added id = " << info.id << " name = " << info.name; | 399 VLOG(1) << "Input device added id = " << info.id << " name = " << info.name; |
400 // TODO(merkulova): deal with all available device types, e.g. joystick. | 400 // TODO(merkulova): deal with all available device types, e.g. joystick. |
401 if (!keyboard_device_id_.empty() && !pointing_device_id_.empty()) | 401 if (!keyboard_device_id_.empty() && !pointing_device_id_.empty()) |
402 return; | 402 return; |
403 | 403 |
404 if (pointing_device_id_.empty() && DeviceIsPointing(info)) { | 404 if (pointing_device_id_.empty() && DeviceIsPointing(info)) { |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
546 void HIDDetectionScreen::SetPoweredOffError() { | 546 void HIDDetectionScreen::SetPoweredOffError() { |
547 LOG(ERROR) << "Failed to power off BT adapter"; | 547 LOG(ERROR) << "Failed to power off BT adapter"; |
548 } | 548 } |
549 | 549 |
550 void HIDDetectionScreen::FindDevicesError() { | 550 void HIDDetectionScreen::FindDevicesError() { |
551 VLOG(1) << "Failed to start Bluetooth discovery."; | 551 VLOG(1) << "Failed to start Bluetooth discovery."; |
552 } | 552 } |
553 | 553 |
554 | 554 |
555 } // namespace chromeos | 555 } // namespace chromeos |
OLD | NEW |