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

Side by Side Diff: chrome/browser/chromeos/login/screens/hid_detection_screen.h

Issue 2638123002: cros: Fold HIDDetectionModel into HIDDetectionScreen. (Closed)
Patch Set: Initial upload Created 3 years, 11 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 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:
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
38 typedef device::InputServiceLinux::InputDeviceInfo InputDeviceInfo; 47 typedef device::InputServiceLinux::InputDeviceInfo InputDeviceInfo;
achuithb 2017/01/18 23:19:46 let's make this 'using' since you're here.
jdufault 2017/01/20 18:57:21 Done.
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 // Checks if we should show the screen or enough devices already present.
63 // Calls corresponding set of actions based on the bool result.
64 void OnViewDestroyed(HIDDetectionView* view);
65
66 // This method is called, when view is being destroyed. Note, if model
achuithb 2017/01/18 23:19:46 This comment needs an update and better grammar. A
jdufault 2017/01/20 18:57:21 Done.
67 // is destroyed earlier then it has to call Unbind().
68 void CheckIsScreenRequired(const base::Callback<void(bool)>& on_check_done);
69
70 private:
71 friend class HIDDetectionScreenTest;
72
73 // BaseScreen implementation:
51 void Show() override; 74 void Show() override;
52 void Hide() override; 75 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 76
58 // device::BluetoothDevice::PairingDelegate implementation: 77 // device::BluetoothDevice::PairingDelegate implementation:
59 void RequestPinCode(device::BluetoothDevice* device) override; 78 void RequestPinCode(device::BluetoothDevice* device) override;
60 void RequestPasskey(device::BluetoothDevice* device) override; 79 void RequestPasskey(device::BluetoothDevice* device) override;
61 void DisplayPinCode(device::BluetoothDevice* device, 80 void DisplayPinCode(device::BluetoothDevice* device,
62 const std::string& pincode) override; 81 const std::string& pincode) override;
63 void DisplayPasskey(device::BluetoothDevice* device, 82 void DisplayPasskey(device::BluetoothDevice* device,
64 uint32_t passkey) override; 83 uint32_t passkey) override;
65 void KeysEntered(device::BluetoothDevice* device, uint32_t entered) override; 84 void KeysEntered(device::BluetoothDevice* device, uint32_t entered) override;
66 void ConfirmPasskey(device::BluetoothDevice* device, 85 void ConfirmPasskey(device::BluetoothDevice* device,
67 uint32_t passkey) override; 86 uint32_t passkey) override;
68 void AuthorizePairing(device::BluetoothDevice* device) override; 87 void AuthorizePairing(device::BluetoothDevice* device) override;
69 88
70 // device::BluetoothAdapter::Observer implementation. 89 // device::BluetoothAdapter::Observer implementation.
71 void AdapterPresentChanged(device::BluetoothAdapter* adapter, 90 void AdapterPresentChanged(device::BluetoothAdapter* adapter,
72 bool present) override; 91 bool present) override;
73 void DeviceAdded(device::BluetoothAdapter* adapter, 92 void DeviceAdded(device::BluetoothAdapter* adapter,
74 device::BluetoothDevice* device) override; 93 device::BluetoothDevice* device) override;
75 void DeviceChanged(device::BluetoothAdapter* adapter, 94 void DeviceChanged(device::BluetoothAdapter* adapter,
76 device::BluetoothDevice* device) override; 95 device::BluetoothDevice* device) override;
77 void DeviceRemoved(device::BluetoothAdapter* adapter, 96 void DeviceRemoved(device::BluetoothAdapter* adapter,
78 device::BluetoothDevice* device) override; 97 device::BluetoothDevice* device) override;
79 98
80 // InputServiceProxy::Observer implementation. 99 // InputServiceProxy::Observer implementation.
81 void OnInputDeviceAdded(const InputDeviceInfo& info) override; 100 void OnInputDeviceAdded(const InputDeviceInfo& info) override;
82 void OnInputDeviceRemoved(const std::string& id) override; 101 void OnInputDeviceRemoved(const std::string& id) override;
83 102
84 private:
85 friend class HIDDetectionScreenTest;
86
87 // Types of dialog leaving scenarios for UMA metric. 103 // Types of dialog leaving scenarios for UMA metric.
88 enum ContinueScenarioType { 104 enum ContinueScenarioType {
89 // Only pointing device detected, user pressed 'Continue'. 105 // Only pointing device detected, user pressed 'Continue'.
90 POINTING_DEVICE_ONLY_DETECTED, 106 POINTING_DEVICE_ONLY_DETECTED,
91 107
92 // Only keyboard detected, user pressed 'Continue'. 108 // Only keyboard detected, user pressed 'Continue'.
93 KEYBOARD_DEVICE_ONLY_DETECTED, 109 KEYBOARD_DEVICE_ONLY_DETECTED,
94 110
95 // All devices detected. 111 // All devices detected.
96 All_DEVICES_DETECTED, 112 All_DEVICES_DETECTED,
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 bool showing_ = false; 235 bool showing_ = false;
220 236
221 base::WeakPtrFactory<HIDDetectionScreen> weak_ptr_factory_; 237 base::WeakPtrFactory<HIDDetectionScreen> weak_ptr_factory_;
222 238
223 DISALLOW_COPY_AND_ASSIGN(HIDDetectionScreen); 239 DISALLOW_COPY_AND_ASSIGN(HIDDetectionScreen);
224 }; 240 };
225 241
226 } // namespace chromeos 242 } // namespace chromeos
227 243
228 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_SCREENS_HID_DETECTION_SCREEN_H_ 244 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_SCREENS_HID_DETECTION_SCREEN_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698