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 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_SCREENS_HID_DETECTION_SCREEN_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_SCREENS_HID_DETECTION_SCREEN_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_SCREENS_HID_DETECTION_SCREEN_H_ | 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_SCREENS_HID_DETECTION_SCREEN_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| 11 #include <string> | 11 #include <string> |
| 12 #include <vector> | 12 #include <vector> |
| 13 | 13 |
| 14 #include "base/callback.h" | 14 #include "base/callback.h" |
| 15 #include "base/compiler_specific.h" | 15 #include "base/compiler_specific.h" |
| 16 #include "base/macros.h" | 16 #include "base/macros.h" |
| 17 #include "base/memory/weak_ptr.h" | 17 #include "base/memory/weak_ptr.h" |
| 18 #include "chrome/browser/chromeos/device/input_service_proxy.h" | 18 #include "chrome/browser/chromeos/device/input_service_proxy.h" |
| 19 #include "chrome/browser/chromeos/login/screens/base_screen.h" | 19 #include "chrome/browser/chromeos/login/screens/base_screen.h" |
| 20 #include "chrome/browser/chromeos/login/screens/hid_detection_model.h" | |
| 21 #include "components/login/screens/screen_context.h" | 20 #include "components/login/screens/screen_context.h" |
| 22 #include "device/bluetooth/bluetooth_adapter.h" | 21 #include "device/bluetooth/bluetooth_adapter.h" |
| 23 #include "device/bluetooth/bluetooth_device.h" | 22 #include "device/bluetooth/bluetooth_device.h" |
| 24 #include "device/bluetooth/bluetooth_discovery_session.h" | 23 #include "device/bluetooth/bluetooth_discovery_session.h" |
| 25 #include "device/hid/input_service_linux.h" | 24 #include "device/hid/input_service_linux.h" |
| 26 | 25 |
| 27 namespace chromeos { | 26 namespace chromeos { |
| 28 | 27 |
| 29 class HIDDetectionView; | 28 class HIDDetectionView; |
| 30 | 29 |
| 31 // Representation independent class that controls screen showing warning about | 30 // Representation independent class that controls screen showing warning about |
| 32 // HID absence to users. | 31 // HID absence to users. |
| 33 class HIDDetectionScreen : public HIDDetectionModel, | 32 class HIDDetectionScreen : public BaseScreen, |
| 34 public device::BluetoothAdapter::Observer, | 33 public device::BluetoothAdapter::Observer, |
| 35 public device::BluetoothDevice::PairingDelegate, | 34 public device::BluetoothDevice::PairingDelegate, |
| 36 public InputServiceProxy::Observer { | 35 public InputServiceProxy::Observer { |
| 37 public: | 36 public: |
| 38 typedef device::InputServiceLinux::InputDeviceInfo InputDeviceInfo; | 37 static const char kContextKeyKeyboardState[]; |
| 38 static const char kContextKeyMouseState[]; | |
| 39 static const char kContextKeyNumKeysEnteredExpected[]; | |
| 40 static const char kContextKeyNumKeysEnteredPinCode[]; | |
| 41 static const char kContextKeyPinCode[]; | |
| 42 static const char kContextKeyMouseDeviceName[]; | |
| 43 static const char kContextKeyKeyboardDeviceName[]; | |
| 44 static const char kContextKeyKeyboardLabel[]; | |
| 45 static const char kContextKeyContinueButtonEnabled[]; | |
| 46 | |
| 47 using InputDeviceInfo = device::InputServiceLinux::InputDeviceInfo; | |
| 39 | 48 |
| 40 class Delegate { | 49 class Delegate { |
| 41 public: | 50 public: |
| 42 virtual ~Delegate() {} | 51 virtual ~Delegate() {} |
| 43 virtual void OnHIDScreenNecessityCheck(bool screen_needed) = 0; | 52 virtual void OnHIDScreenNecessityCheck(bool screen_needed) = 0; |
| 44 }; | 53 }; |
| 45 | 54 |
| 46 HIDDetectionScreen(BaseScreenDelegate* base_screen_delegate, | 55 HIDDetectionScreen(BaseScreenDelegate* base_screen_delegate, |
| 47 HIDDetectionView* view); | 56 HIDDetectionView* view); |
| 48 ~HIDDetectionScreen() override; | 57 ~HIDDetectionScreen() override; |
| 49 | 58 |
| 50 // HIDDetectionModel implementation: | 59 // Called when continue button was clicked. |
| 60 void OnContinueButtonClicked(); | |
| 61 | |
| 62 // This method is called when the view is being destroyed. | |
| 63 void OnViewDestroyed(HIDDetectionView* view); | |
| 64 | |
| 65 // Checks if this screen should be display. |on_check_done| should be invoked | |
|
achuithb
2017/01/20 19:18:38
displayed
jdufault
2017/01/20 19:25:37
Done.
| |
| 66 // with the result; true if the screen should be displayed, false otherwise. | |
| 67 void CheckIsScreenRequired(const base::Callback<void(bool)>& on_check_done); | |
| 68 | |
| 69 private: | |
| 70 friend class HIDDetectionScreenTest; | |
| 71 | |
| 72 // BaseScreen implementation: | |
| 51 void Show() override; | 73 void Show() override; |
| 52 void Hide() override; | 74 void Hide() override; |
| 53 void OnContinueButtonClicked() override; | |
| 54 void OnViewDestroyed(HIDDetectionView* view) override; | |
| 55 void CheckIsScreenRequired( | |
| 56 const base::Callback<void(bool)>& on_check_done) override; | |
| 57 | 75 |
| 58 // device::BluetoothDevice::PairingDelegate implementation: | 76 // device::BluetoothDevice::PairingDelegate implementation: |
| 59 void RequestPinCode(device::BluetoothDevice* device) override; | 77 void RequestPinCode(device::BluetoothDevice* device) override; |
| 60 void RequestPasskey(device::BluetoothDevice* device) override; | 78 void RequestPasskey(device::BluetoothDevice* device) override; |
| 61 void DisplayPinCode(device::BluetoothDevice* device, | 79 void DisplayPinCode(device::BluetoothDevice* device, |
| 62 const std::string& pincode) override; | 80 const std::string& pincode) override; |
| 63 void DisplayPasskey(device::BluetoothDevice* device, | 81 void DisplayPasskey(device::BluetoothDevice* device, |
| 64 uint32_t passkey) override; | 82 uint32_t passkey) override; |
| 65 void KeysEntered(device::BluetoothDevice* device, uint32_t entered) override; | 83 void KeysEntered(device::BluetoothDevice* device, uint32_t entered) override; |
| 66 void ConfirmPasskey(device::BluetoothDevice* device, | 84 void ConfirmPasskey(device::BluetoothDevice* device, |
| 67 uint32_t passkey) override; | 85 uint32_t passkey) override; |
| 68 void AuthorizePairing(device::BluetoothDevice* device) override; | 86 void AuthorizePairing(device::BluetoothDevice* device) override; |
| 69 | 87 |
| 70 // device::BluetoothAdapter::Observer implementation. | 88 // device::BluetoothAdapter::Observer implementation. |
| 71 void AdapterPresentChanged(device::BluetoothAdapter* adapter, | 89 void AdapterPresentChanged(device::BluetoothAdapter* adapter, |
| 72 bool present) override; | 90 bool present) override; |
| 73 void DeviceAdded(device::BluetoothAdapter* adapter, | 91 void DeviceAdded(device::BluetoothAdapter* adapter, |
| 74 device::BluetoothDevice* device) override; | 92 device::BluetoothDevice* device) override; |
| 75 void DeviceChanged(device::BluetoothAdapter* adapter, | 93 void DeviceChanged(device::BluetoothAdapter* adapter, |
| 76 device::BluetoothDevice* device) override; | 94 device::BluetoothDevice* device) override; |
| 77 void DeviceRemoved(device::BluetoothAdapter* adapter, | 95 void DeviceRemoved(device::BluetoothAdapter* adapter, |
| 78 device::BluetoothDevice* device) override; | 96 device::BluetoothDevice* device) override; |
| 79 | 97 |
| 80 // InputServiceProxy::Observer implementation. | 98 // InputServiceProxy::Observer implementation. |
| 81 void OnInputDeviceAdded(const InputDeviceInfo& info) override; | 99 void OnInputDeviceAdded(const InputDeviceInfo& info) override; |
| 82 void OnInputDeviceRemoved(const std::string& id) override; | 100 void OnInputDeviceRemoved(const std::string& id) override; |
| 83 | 101 |
| 84 private: | |
| 85 friend class HIDDetectionScreenTest; | |
| 86 | |
| 87 // Types of dialog leaving scenarios for UMA metric. | 102 // Types of dialog leaving scenarios for UMA metric. |
| 88 enum ContinueScenarioType { | 103 enum ContinueScenarioType { |
| 89 // Only pointing device detected, user pressed 'Continue'. | 104 // Only pointing device detected, user pressed 'Continue'. |
| 90 POINTING_DEVICE_ONLY_DETECTED, | 105 POINTING_DEVICE_ONLY_DETECTED, |
| 91 | 106 |
| 92 // Only keyboard detected, user pressed 'Continue'. | 107 // Only keyboard detected, user pressed 'Continue'. |
| 93 KEYBOARD_DEVICE_ONLY_DETECTED, | 108 KEYBOARD_DEVICE_ONLY_DETECTED, |
| 94 | 109 |
| 95 // All devices detected. | 110 // All devices detected. |
| 96 All_DEVICES_DETECTED, | 111 All_DEVICES_DETECTED, |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 219 bool showing_ = false; | 234 bool showing_ = false; |
| 220 | 235 |
| 221 base::WeakPtrFactory<HIDDetectionScreen> weak_ptr_factory_; | 236 base::WeakPtrFactory<HIDDetectionScreen> weak_ptr_factory_; |
| 222 | 237 |
| 223 DISALLOW_COPY_AND_ASSIGN(HIDDetectionScreen); | 238 DISALLOW_COPY_AND_ASSIGN(HIDDetectionScreen); |
| 224 }; | 239 }; |
| 225 | 240 |
| 226 } // namespace chromeos | 241 } // namespace chromeos |
| 227 | 242 |
| 228 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_SCREENS_HID_DETECTION_SCREEN_H_ | 243 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_SCREENS_HID_DETECTION_SCREEN_H_ |
| OLD | NEW |