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

Unified Diff: chrome/browser/resources/chromeos/login/oobe_screen_hid_detection.js

Issue 252503002: Base version of HID detection OOBE screen. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 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 side-by-side diff with in-line comments
Download patch
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..e03f99ed17ebbb09bb33952ea5db7c1f9c7c0ff7 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,30 @@
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',
+ ENTER_PIN_CODE: 'bluetoothEnterPinCode',
+ ENTER_PASSKEY: 'bluetoothEnterPasskey',
+ REMOTE_PIN_CODE: 'bluetoothRemotePinCode',
+ REMOTE_PASSKEY: 'bluetoothRemotePasskey',
+ CONFIRM_PASSKEY: 'bluetoothConfirmPasskey',
+ CONNECT_FAILED: 'bluetoothConnectFailed',
+ CANCELED: 'bluetoothPairingCanceled',
+ DISMISSED: 'bluetoothPairingDismissed', // pairing dismissed(succeeded or
ygorshenin1 2014/04/24 11:30:24 nit: move the comment between lines #30 and #31.
Nikita (slow) 2014/04/24 12:14:23 nit: Capitalize comment.
merkulova 2014/04/24 12:49:46 Done.
merkulova 2014/04/24 12:49:46 Done.
+ // canceled).
+ },
+
/**
* Button to move to usual OOBE flow after detection.
* @private
@@ -42,11 +66,89 @@ 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'.
ygorshenin1 2014/04/24 11:30:24 Add tag @private.
merkulova 2014/04/24 12:49:46 Done.
+ */
+ 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);
+ },
+
+ setPointingDeviceState: function(data) {
+ if (data === undefined)
+ return;
+ if ('searching' in data) {
ygorshenin1 2014/04/24 11:30:24 No need in curly braces here, as all branches are
merkulova 2014/04/24 12:49:46 Done.
+ this.setDeviceBlockState_('hid-mouse-block', 'searching');
+ } else if ('USBConnected' in data) {
+ this.setDeviceBlockState_('hid-mouse-block', 'connected');
+ } else if ('BTPaired' in data) {
+ this.setDeviceBlockState_('hid-mouse-block', 'paired');
+ }
+ },
+
+ setKeyboardDeviceState: function(data) {
+ if (data === undefined)
+ return;
+ if ('searching' in data) {
+ this.setDeviceBlockState_('hid-keyboard-block', 'searching');
+ } else if ('USBConnected' in data) {
+ this.setDeviceBlockState_('hid-keyboard-block', 'connected');
+ } else if ('paired' in data) {
+ this.setDeviceBlockState_('hid-keyboard-block', 'paired');
+ } else if ('pairing' in data) {
+ this.setDeviceBlockState_('hid-keyboard-block', 'pairing');
+ $('hid-keyboard-label-pairing').textContent = data['keyboard-label'];
+ if (data['pairing'] == this.PAIRING.REMOTE_PIN_CODE) {
+ // remove pincode pictures if exist.
+ var pincodeBlock = $('hid-keyboard-pincode');
+ while (pincodeBlock.firstChild.id != 'hid-keyboard-pincode-enter') {
+ pincodeBlock.removeChild(pincodeBlock.firstChild);
+ }
+ for (var i = 0, len = data['pincode'].length; i < len; i++) {
+ var pincodeSymbol = this.ownerDocument.createElement('div');
+ pincodeSymbol.textContent = data['pincode'][i];
+ pincodeSymbol.classList.add('bluetooth-keyboard-button');
+ $('hid-keyboard-pincode').insertBefore(
+ pincodeSymbol, $('hid-keyboard-pincode-enter'));
+ }
+
+ }
+ }
+ },
+
+
+ /**
* 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);
+ },
+
};
});

Powered by Google App Engine
This is Rietveld 408576698