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

Side by Side Diff: chrome/browser/ui/webui/chromeos/login/hid_detection_screen_handler.h

Issue 276433003: UMA metrics added for HID detection dialog. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Refactored. Created 6 years, 7 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 | Annotate | Revision Log
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_UI_WEBUI_CHROMEOS_LOGIN_HID_DETECTION_SCREEN_HANDLER_H_ 5 #ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_HID_DETECTION_SCREEN_HANDLER_H_
6 #define CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_HID_DETECTION_SCREEN_HANDLER_H_ 6 #define CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_HID_DETECTION_SCREEN_HANDLER_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
12 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "base/memory/weak_ptr.h" 13 #include "base/memory/weak_ptr.h"
14 #include "base/prefs/pref_registry_simple.h"
14 #include "base/values.h" 15 #include "base/values.h"
15 #include "chrome/browser/chromeos/device/input_service_proxy.h" 16 #include "chrome/browser/chromeos/device/input_service_proxy.h"
16 #include "chrome/browser/chromeos/login/screens/hid_detection_screen_actor.h" 17 #include "chrome/browser/chromeos/login/screens/hid_detection_screen_actor.h"
17 #include "chrome/browser/ui/webui/chromeos/login/base_screen_handler.h" 18 #include "chrome/browser/ui/webui/chromeos/login/base_screen_handler.h"
18 #include "content/public/browser/web_ui.h" 19 #include "content/public/browser/web_ui.h"
19 #include "device/bluetooth/bluetooth_adapter.h" 20 #include "device/bluetooth/bluetooth_adapter.h"
20 #include "device/bluetooth/bluetooth_device.h" 21 #include "device/bluetooth/bluetooth_device.h"
21 #include "device/bluetooth/bluetooth_discovery_session.h" 22 #include "device/bluetooth/bluetooth_discovery_session.h"
22 23
23 namespace base { 24 namespace base {
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 device::BluetoothDevice* device) OVERRIDE; 72 device::BluetoothDevice* device) OVERRIDE;
72 virtual void DeviceChanged(device::BluetoothAdapter* adapter, 73 virtual void DeviceChanged(device::BluetoothAdapter* adapter,
73 device::BluetoothDevice* device) OVERRIDE; 74 device::BluetoothDevice* device) OVERRIDE;
74 virtual void DeviceRemoved(device::BluetoothAdapter* adapter, 75 virtual void DeviceRemoved(device::BluetoothAdapter* adapter,
75 device::BluetoothDevice* device) OVERRIDE; 76 device::BluetoothDevice* device) OVERRIDE;
76 77
77 // InputServiceProxy::Observer implementation. 78 // InputServiceProxy::Observer implementation.
78 virtual void OnInputDeviceAdded(const InputDeviceInfo& info) OVERRIDE; 79 virtual void OnInputDeviceAdded(const InputDeviceInfo& info) OVERRIDE;
79 virtual void OnInputDeviceRemoved(const std::string& id) OVERRIDE; 80 virtual void OnInputDeviceRemoved(const std::string& id) OVERRIDE;
80 81
82 // Registers the preference for derelict state.
83 static void RegisterPrefs(PrefRegistrySimple* registry);
84
81 private: 85 private:
86 // Types of dialog leaving scenarios for UMA metric.
87 enum ContinueScenarioType {
88 // Only pointing device detected, user pressed 'Continue'.
89 POINTING_DEVICE_ONLY_DETECTED,
90
91 // Only keyboard detected, user pressed 'Continue'.
92 KEYBOARD_DEVICE_ONLY_DETECTED,
93
94 // All devices detected.
95 All_DEVICES_DETECTED,
96
97 // Must be last enum element.
98 CONTINUE_SCENARIO_TYPE_SIZE
99 };
100
82 void InitializeAdapter(scoped_refptr<device::BluetoothAdapter> adapter); 101 void InitializeAdapter(scoped_refptr<device::BluetoothAdapter> adapter);
83 102
84 // Sends a notification to the Web UI of the status of available Bluetooth/USB 103 // Sends a notification to the Web UI of the status of available Bluetooth/USB
85 // pointing device. 104 // pointing device.
86 void SendPointingDeviceNotification(); 105 void SendPointingDeviceNotification();
87 106
88 // Sends a notification to the Web UI of the status of available Bluetooth/USB 107 // Sends a notification to the Web UI of the status of available Bluetooth/USB
89 // keyboard device. 108 // keyboard device.
90 void SendKeyboardDeviceNotification(base::DictionaryValue* params); 109 void SendKeyboardDeviceNotification(base::DictionaryValue* params);
91 110
111 // Updates internal state and UI using list of connected devices.
112 void ProcessConnectedDevicesList(const std::vector<InputDeviceInfo>& devices);
113
114 // Checks for lack of mouse or keyboard. If found starts BT devices update.
115 // Initiates BTAdapter if it's not active and BT devices update required.
116 void TryInitiateBTDevicesUpdate();
117
118 void OnGetInputDevicesListFirstTime(
119 const std::vector<InputDeviceInfo>& devices);
120
92 void OnGetInputDevicesList(const std::vector<InputDeviceInfo>& devices); 121 void OnGetInputDevicesList(const std::vector<InputDeviceInfo>& devices);
93 122
94 void StartBTDiscoverySession(); 123 void StartBTDiscoverySession();
95 124
96 // Called by device::BluetoothDevice on a successful pairing and connection 125 // Called by device::BluetoothDevice on a successful pairing and connection
97 // to a device. 126 // to a device.
98 void BTConnected(device::BluetoothDevice::DeviceType device_type); 127 void BTConnected(device::BluetoothDevice::DeviceType device_type);
99 128
100 // Called by device::BluetoothDevice in response to a failure to 129 // Called by device::BluetoothDevice in response to a failure to
101 // connect to the device with bluetooth address |address| due to an error 130 // connect to the device with bluetooth address |address| due to an error
(...skipping 19 matching lines...) Expand all
121 scoped_ptr<device::BluetoothDiscoverySession> discovery_session); 150 scoped_ptr<device::BluetoothDiscoverySession> discovery_session);
122 151
123 // Called by device::BluetoothAdapter in response to a failure to 152 // Called by device::BluetoothAdapter in response to a failure to
124 // initiate a discovery session. 153 // initiate a discovery session.
125 void FindDevicesError(); 154 void FindDevicesError();
126 155
127 // Called by device::BluetoothAdapter in response to a failure to 156 // Called by device::BluetoothAdapter in response to a failure to
128 // power BT adapter. 157 // power BT adapter.
129 void SetPoweredError(); 158 void SetPoweredError();
130 159
160 // Special case uf UpdateDevice. Called on first show, skips the dialog if
161 // all necessary devices (mouse and keyboard) already connected.
162 void GetDevicesFirstTime();
163
131 // Called for revision of active devices. If current-placement is available 164 // Called for revision of active devices. If current-placement is available
132 // for mouse or keyboard device, sets one of active devices as current or 165 // for mouse or keyboard device, sets one of active devices as current or
133 // tries to connect some BT device if no appropriate devices are connected. 166 // tries to connect some BT device if no appropriate devices are connected.
134 void UpdateDevices(); 167 void UpdateDevices();
135 168
136 // Tries to connect some BT devices if no type-appropriate devices are 169 // Tries to connect some BT devices if no type-appropriate devices are
137 // connected. 170 // connected.
138 void UpdateBTDevices(); 171 void UpdateBTDevices();
139 172
140 // Tries to connect given BT device. 173 // Tries to connect given BT device.
(...skipping 22 matching lines...) Expand all
163 InputDeviceInfo::Type pointing_device_connect_type_; 196 InputDeviceInfo::Type pointing_device_connect_type_;
164 197
165 // Current keyboard device, if any. 198 // Current keyboard device, if any.
166 std::string keyboard_device_name_; 199 std::string keyboard_device_name_;
167 std::string keyboard_device_id_; 200 std::string keyboard_device_id_;
168 bool keyboard_is_pairing_; 201 bool keyboard_is_pairing_;
169 InputDeviceInfo::Type keyboard_device_connect_type_; 202 InputDeviceInfo::Type keyboard_device_connect_type_;
170 203
171 bool switch_on_adapter_when_ready_; 204 bool switch_on_adapter_when_ready_;
172 205
173 bool skip_screen_if_devices_present_; 206 bool first_time_screen_show_;
174 207
175 base::WeakPtrFactory<HIDDetectionScreenHandler> weak_ptr_factory_; 208 base::WeakPtrFactory<HIDDetectionScreenHandler> weak_ptr_factory_;
176 209
177 DISALLOW_COPY_AND_ASSIGN(HIDDetectionScreenHandler); 210 DISALLOW_COPY_AND_ASSIGN(HIDDetectionScreenHandler);
178 }; 211 };
179 212
180 } // namespace chromeos 213 } // namespace chromeos
181 214
182 #endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_HID_DETECTION_SCREEN_HANDLER_H _ 215 #endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_HID_DETECTION_SCREEN_HANDLER_H _
183 216
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698