Chromium Code Reviews| 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/ui/webui/chromeos/login/hid_detection_screen_handler.h" | 5 #include "chrome/browser/ui/webui/chromeos/login/hid_detection_screen_handler.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 54 bool DeviceIsPointing(const device::InputServiceLinux::InputDeviceInfo& info) { | 54 bool DeviceIsPointing(const device::InputServiceLinux::InputDeviceInfo& info) { |
| 55 return info.is_mouse || info.is_touchpad || info.is_touchscreen || | 55 return info.is_mouse || info.is_touchpad || info.is_touchscreen || |
| 56 info.is_tablet; | 56 info.is_tablet; |
| 57 } | 57 } |
| 58 | 58 |
| 59 bool DeviceIsKeyboard(device::BluetoothDevice::DeviceType device_type) { | 59 bool DeviceIsKeyboard(device::BluetoothDevice::DeviceType device_type) { |
| 60 return device_type == device::BluetoothDevice::DEVICE_KEYBOARD || | 60 return device_type == device::BluetoothDevice::DEVICE_KEYBOARD || |
| 61 device_type == device::BluetoothDevice::DEVICE_KEYBOARD_MOUSE_COMBO; | 61 device_type == device::BluetoothDevice::DEVICE_KEYBOARD_MOUSE_COMBO; |
| 62 } | 62 } |
| 63 | 63 |
| 64 bool DeviceIsKeyboard(const device::InputServiceLinux::InputDeviceInfo& info) { | |
| 65 return info.is_keyboard || info.is_touchscreen || info.is_tablet; | |
|
ygorshenin1
2014/12/24 09:34:47
I disagree about touchscreen, because presence of
merkulova
2014/12/24 13:47:46
Left to be discussed.
| |
| 66 } | |
| 67 | |
| 64 } // namespace | 68 } // namespace |
| 65 | 69 |
| 66 namespace chromeos { | 70 namespace chromeos { |
| 67 | 71 |
| 68 HIDDetectionScreenHandler::HIDDetectionScreenHandler( | 72 HIDDetectionScreenHandler::HIDDetectionScreenHandler( |
| 69 CoreOobeActor* core_oobe_actor) | 73 CoreOobeActor* core_oobe_actor) |
| 70 : BaseScreenHandler(kJsScreenPath), | 74 : BaseScreenHandler(kJsScreenPath), |
| 71 delegate_(NULL), | 75 delegate_(NULL), |
| 72 core_oobe_actor_(core_oobe_actor), | 76 core_oobe_actor_(core_oobe_actor), |
| 73 show_on_init_(false), | 77 show_on_init_(false), |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 116 input_service_proxy_.AddObserver(this); | 120 input_service_proxy_.AddObserver(this); |
| 117 UpdateDevices(); | 121 UpdateDevices(); |
| 118 | 122 |
| 119 PrefService* local_state = g_browser_process->local_state(); | 123 PrefService* local_state = g_browser_process->local_state(); |
| 120 int num_of_times_dialog_was_shown = local_state->GetInteger( | 124 int num_of_times_dialog_was_shown = local_state->GetInteger( |
| 121 prefs::kTimesHIDDialogShown); | 125 prefs::kTimesHIDDialogShown); |
| 122 local_state->SetInteger(prefs::kTimesHIDDialogShown, | 126 local_state->SetInteger(prefs::kTimesHIDDialogShown, |
| 123 num_of_times_dialog_was_shown + 1); | 127 num_of_times_dialog_was_shown + 1); |
| 124 | 128 |
| 125 ShowScreen(OobeUI::kScreenHIDDetection, NULL); | 129 ShowScreen(OobeUI::kScreenHIDDetection, NULL); |
| 126 if (!pointing_device_id_.empty()) | 130 SendPointingDeviceNotification(); |
| 127 SendPointingDeviceNotification(); | 131 SendKeyboardDeviceNotification(NULL); |
| 128 if (!keyboard_device_id_.empty()) | |
| 129 SendKeyboardDeviceNotification(NULL); | |
| 130 } | 132 } |
| 131 | 133 |
| 132 void HIDDetectionScreenHandler::Hide() { | 134 void HIDDetectionScreenHandler::Hide() { |
| 133 if (adapter_.get()) | 135 if (adapter_.get()) |
| 134 adapter_->RemoveObserver(this); | 136 adapter_->RemoveObserver(this); |
| 135 input_service_proxy_.RemoveObserver(this); | 137 input_service_proxy_.RemoveObserver(this); |
| 136 } | 138 } |
| 137 | 139 |
| 138 void HIDDetectionScreenHandler::SetDelegate(Delegate* delegate) { | 140 void HIDDetectionScreenHandler::SetDelegate(Delegate* delegate) { |
| 139 delegate_ = delegate; | 141 delegate_ = delegate; |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 362 // TODO(merkulova): deal with all available device types, e.g. joystick. | 364 // TODO(merkulova): deal with all available device types, e.g. joystick. |
| 363 if (!keyboard_device_id_.empty() && !pointing_device_id_.empty()) | 365 if (!keyboard_device_id_.empty() && !pointing_device_id_.empty()) |
| 364 return; | 366 return; |
| 365 | 367 |
| 366 if (pointing_device_id_.empty() && DeviceIsPointing(info)) { | 368 if (pointing_device_id_.empty() && DeviceIsPointing(info)) { |
| 367 pointing_device_id_ = info.id; | 369 pointing_device_id_ = info.id; |
| 368 pointing_device_name_ = info.name; | 370 pointing_device_name_ = info.name; |
| 369 pointing_device_connect_type_ = info.type; | 371 pointing_device_connect_type_ = info.type; |
| 370 SendPointingDeviceNotification(); | 372 SendPointingDeviceNotification(); |
| 371 } | 373 } |
| 372 if (keyboard_device_id_.empty() && info.is_keyboard) { | 374 if (keyboard_device_id_.empty() && DeviceIsKeyboard(info)) { |
| 373 keyboard_device_id_ = info.id; | 375 keyboard_device_id_ = info.id; |
| 374 keyboard_device_name_ = info.name; | 376 keyboard_device_name_ = info.name; |
| 375 keyboard_device_connect_type_ = info.type; | 377 keyboard_device_connect_type_ = info.type; |
| 376 SendKeyboardDeviceNotification(NULL); | 378 SendKeyboardDeviceNotification(NULL); |
| 377 } | 379 } |
| 378 } | 380 } |
| 379 | 381 |
| 380 void HIDDetectionScreenHandler::OnInputDeviceRemoved(const std::string& id) { | 382 void HIDDetectionScreenHandler::OnInputDeviceRemoved(const std::string& id) { |
| 381 if (id == keyboard_device_id_) { | 383 if (id == keyboard_device_id_) { |
| 382 keyboard_device_id_.clear(); | 384 keyboard_device_id_.clear(); |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 581 l10n_util::GetStringFUTF16( | 583 l10n_util::GetStringFUTF16( |
| 582 IDS_HID_DETECTION_PAIRED_BLUETOOTH_KEYBOARD, | 584 IDS_HID_DETECTION_PAIRED_BLUETOOTH_KEYBOARD, |
| 583 base::UTF8ToUTF16(keyboard_device_name_))); | 585 base::UTF8ToUTF16(keyboard_device_name_))); |
| 584 } else { | 586 } else { |
| 585 state_info.SetString("state", kUSBConnectedState); | 587 state_info.SetString("state", kUSBConnectedState); |
| 586 } | 588 } |
| 587 CallJS("setKeyboardDeviceState", state_info); | 589 CallJS("setKeyboardDeviceState", state_info); |
| 588 } | 590 } |
| 589 | 591 |
| 590 } // namespace chromeos | 592 } // namespace chromeos |
| OLD | NEW |