Index: chrome/browser/resources/chromeos/login/oobe_screen_hid_detection.js |
diff --git a/chrome/browser/resources/chromeos/login/oobe_screen_hid_detection.js b/chrome/browser/resources/chromeos/login/oobe_screen_hid_detection.js |
index 165dae7fa7c50c99fdddd466c14ea85c1e4fcb16..bec2320db7896bdf87093eae1452b045a3b400f7 100644 |
--- a/chrome/browser/resources/chromeos/login/oobe_screen_hid_detection.js |
+++ b/chrome/browser/resources/chromeos/login/oobe_screen_hid_detection.js |
@@ -8,6 +8,27 @@ |
login.createScreen('HIDDetectionScreen', 'hid-detection', function() { |
return { |
+ EXTERNAL_API: [ |
+ 'setPointingDeviceState', |
+ 'setKeyboardDeviceState', |
+ ], |
+ |
+ /** |
+ * Enumeration of possible states during pairing. The value associated with |
+ * each state maps to a localized string in the global variable |
+ * |loadTimeData|. |
+ * @enum {string} |
+ */ |
+ PAIRING: { |
+ STARTUP: 'bluetoothStartConnecting', |
+ REMOTE_PIN_CODE: 'bluetoothRemotePinCode', |
+ REMOTE_PASSKEY: 'bluetoothRemotePasskey', |
+ CONNECT_FAILED: 'bluetoothConnectFailed', |
+ CANCELED: 'bluetoothPairingCanceled', |
+ // Pairing dismissed (succeeded or canceled). |
+ DISMISSED: 'bluetoothPairingDismissed' |
+ }, |
+ |
/** |
* Button to move to usual OOBE flow after detection. |
* @private |
@@ -42,11 +63,80 @@ login.createScreen('HIDDetectionScreen', 'hid-detection', function() { |
}, |
/** |
+ * Sets a device-block css class to reflect device state of searching, |
+ * connected, pairing or paired (for BT devices). |
+ * @param {blockId} id one of 'hid-mouse-block' or 'hid-keyboard-block'. |
+ * @param {state} one of 'searching', 'connected', 'pairing', 'paired'. |
+ * @private |
+ */ |
+ setDeviceBlockState_: function(blockId, state) { |
+ var deviceBlock = $(blockId); |
+ var states = ['searching', 'connected', 'pairing', 'paired']; |
+ for (var i = 0; i < states.length; ++i) { |
+ if (states[i] != state) |
+ deviceBlock.classList.remove(states[i]); |
+ } |
+ deviceBlock.classList.add(state); |
+ }, |
+ |
+ /** |
+ * Sets state for mouse-block. |
+ * @param {state} one of 'searching', 'connected', 'paired'. |
+ */ |
+ setPointingDeviceState: function(state) { |
+ if (state === undefined) |
+ return; |
+ this.setDeviceBlockState_('hid-mouse-block', state); |
+ }, |
+ |
+ /** |
+ * Sets state for keyboard-block. |
+ * @param {data} dict with parameters. |
+ */ |
+ setKeyboardDeviceState: function(data) { |
+ if (data === undefined || !('state' in data)) |
+ return; |
+ var state = data['state']; |
+ this.setDeviceBlockState_('hid-keyboard-block', state); |
+ if (state == 'paired') |
+ $('hid-keyboard-label-paired').textContent = data['keyboard-label']; |
+ else if (state == 'pairing') { |
+ $('hid-keyboard-label-pairing').textContent = data['keyboard-label']; |
+ if (data['pairing-state'] == this.PAIRING.REMOTE_PIN_CODE || |
+ data['pairing-state'] == this.PAIRING.REMOTE_PASSKEY) { |
+ for (var i = 0, len = data['pincode'].length; i < len; i++) { |
+ var pincodeSymbol = $('hid-keyboard-pincode-sym-' + (i + 1)); |
+ pincodeSymbol.textContent = data['pincode'][i]; |
+ } |
+ } |
+ } |
+ }, |
+ |
+ |
+ /** |
* Event handler that is invoked just before the screen in shown. |
* @param {Object} data Screen init payload. |
*/ |
onBeforeShow: function(data) { |
$('hid-continue-button').disabled = true; |
+ this.setDeviceBlockState_('hid-mouse-block', 'searching'); |
+ this.setDeviceBlockState_('hid-keyboard-block', 'searching'); |
+ }, |
+ |
+ addBluetoothDevice: function(device) { |
+ // One device can be in the process of pairing. If found, display |
+ // the Bluetooth pairing overlay. |
+ if (device.pairing) |
+ this.showPairingLayout(device); |
+ }, |
+ |
+ /** |
+ * Displays the pairing overlay. |
+ * @param {Object} device Description of the Bluetooth device. |
+ */ |
+ showPairingLayout: function(device) { |
+ BluetoothPairing.getInstance().update(device); |
+ OptionsPage.showPageByName('bluetoothPairing', false); |
}, |
}; |
}); |