| 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/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 | 57 |
| 58 bool DeviceIsKeyboard(device::BluetoothDevice::DeviceType device_type) { | 58 bool DeviceIsKeyboard(device::BluetoothDevice::DeviceType device_type) { |
| 59 return device_type == device::BluetoothDevice::DEVICE_KEYBOARD || | 59 return device_type == device::BluetoothDevice::DEVICE_KEYBOARD || |
| 60 device_type == device::BluetoothDevice::DEVICE_KEYBOARD_MOUSE_COMBO; | 60 device_type == device::BluetoothDevice::DEVICE_KEYBOARD_MOUSE_COMBO; |
| 61 } | 61 } |
| 62 | 62 |
| 63 } // namespace | 63 } // namespace |
| 64 | 64 |
| 65 namespace chromeos { | 65 namespace chromeos { |
| 66 | 66 |
| 67 HIDDetectionScreenHandler::HIDDetectionScreenHandler() | 67 HIDDetectionScreenHandler::HIDDetectionScreenHandler( |
| 68 CoreOobeActor* core_oobe_actor) |
| 68 : BaseScreenHandler(kJsScreenPath), | 69 : BaseScreenHandler(kJsScreenPath), |
| 69 delegate_(NULL), | 70 delegate_(NULL), |
| 71 core_oobe_actor_(core_oobe_actor), |
| 70 show_on_init_(false), | 72 show_on_init_(false), |
| 71 mouse_is_pairing_(false), | 73 mouse_is_pairing_(false), |
| 72 keyboard_is_pairing_(false), | 74 keyboard_is_pairing_(false), |
| 73 switch_on_adapter_when_ready_(false), | 75 switch_on_adapter_when_ready_(false), |
| 74 first_time_screen_show_(true), | 76 first_time_screen_show_(true), |
| 75 weak_ptr_factory_(this) { | 77 weak_ptr_factory_(this) { |
| 76 } | 78 } |
| 77 | 79 |
| 78 HIDDetectionScreenHandler::~HIDDetectionScreenHandler() { | 80 HIDDetectionScreenHandler::~HIDDetectionScreenHandler() { |
| 79 if (adapter_.get()) | 81 if (adapter_.get()) |
| (...skipping 16 matching lines...) Expand all Loading... |
| 96 | 98 |
| 97 void HIDDetectionScreenHandler::FindDevicesError() { | 99 void HIDDetectionScreenHandler::FindDevicesError() { |
| 98 VLOG(1) << "Failed to start Bluetooth discovery."; | 100 VLOG(1) << "Failed to start Bluetooth discovery."; |
| 99 } | 101 } |
| 100 | 102 |
| 101 void HIDDetectionScreenHandler::Show() { | 103 void HIDDetectionScreenHandler::Show() { |
| 102 if (!page_is_ready()) { | 104 if (!page_is_ready()) { |
| 103 show_on_init_ = true; | 105 show_on_init_ = true; |
| 104 return; | 106 return; |
| 105 } | 107 } |
| 108 core_oobe_actor_->InitDemoModeDetection(); |
| 106 input_service_proxy_.AddObserver(this); | 109 input_service_proxy_.AddObserver(this); |
| 107 first_time_screen_show_ = true; | 110 first_time_screen_show_ = true; |
| 108 GetDevicesFirstTime(); | 111 GetDevicesFirstTime(); |
| 109 ShowScreen(OobeUI::kScreenHIDDetection, NULL); | 112 ShowScreen(OobeUI::kScreenHIDDetection, NULL); |
| 110 } | 113 } |
| 111 | 114 |
| 112 void HIDDetectionScreenHandler::Hide() { | 115 void HIDDetectionScreenHandler::Hide() { |
| 113 if (adapter_.get()) | 116 if (adapter_.get()) |
| 114 adapter_->RemoveObserver(this); | 117 adapter_->RemoveObserver(this); |
| 115 input_service_proxy_.RemoveObserver(this); | 118 input_service_proxy_.RemoveObserver(this); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 else if (pointing_device_id_.empty()) | 170 else if (pointing_device_id_.empty()) |
| 168 scenario_type = KEYBOARD_DEVICE_ONLY_DETECTED; | 171 scenario_type = KEYBOARD_DEVICE_ONLY_DETECTED; |
| 169 else | 172 else |
| 170 scenario_type = POINTING_DEVICE_ONLY_DETECTED; | 173 scenario_type = POINTING_DEVICE_ONLY_DETECTED; |
| 171 | 174 |
| 172 UMA_HISTOGRAM_ENUMERATION( | 175 UMA_HISTOGRAM_ENUMERATION( |
| 173 "HIDDetection.OOBEDevicesDetectedOnContinuePressed", | 176 "HIDDetection.OOBEDevicesDetectedOnContinuePressed", |
| 174 scenario_type, | 177 scenario_type, |
| 175 CONTINUE_SCENARIO_TYPE_SIZE); | 178 CONTINUE_SCENARIO_TYPE_SIZE); |
| 176 } | 179 } |
| 180 core_oobe_actor_->StopDemoModeDetection(); |
| 177 if (delegate_) | 181 if (delegate_) |
| 178 delegate_->OnExit(); | 182 delegate_->OnExit(); |
| 179 } | 183 } |
| 180 | 184 |
| 181 void HIDDetectionScreenHandler::InitializeAdapter( | 185 void HIDDetectionScreenHandler::InitializeAdapter( |
| 182 scoped_refptr<device::BluetoothAdapter> adapter) { | 186 scoped_refptr<device::BluetoothAdapter> adapter) { |
| 183 adapter_ = adapter; | 187 adapter_ = adapter; |
| 184 CHECK(adapter_.get()); | 188 CHECK(adapter_.get()); |
| 185 | 189 |
| 186 adapter_->AddObserver(this); | 190 adapter_->AddObserver(this); |
| (...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 548 l10n_util::GetStringFUTF16( | 552 l10n_util::GetStringFUTF16( |
| 549 IDS_HID_DETECTION_PAIRED_BLUETOOTH_KEYBOARD, | 553 IDS_HID_DETECTION_PAIRED_BLUETOOTH_KEYBOARD, |
| 550 base::UTF8ToUTF16(keyboard_device_name_))); | 554 base::UTF8ToUTF16(keyboard_device_name_))); |
| 551 } else { | 555 } else { |
| 552 state_info.SetString("state", kUSBConnectedState); | 556 state_info.SetString("state", kUSBConnectedState); |
| 553 } | 557 } |
| 554 CallJS("setKeyboardDeviceState", state_info); | 558 CallJS("setKeyboardDeviceState", state_info); |
| 555 } | 559 } |
| 556 | 560 |
| 557 } // namespace chromeos | 561 } // namespace chromeos |
| OLD | NEW |