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 7610e2b788a4a22072d8d6b01f137c481a5b8c63..fec20789c20258b36d8aba009bcd6c2d0524a5bc 100644 |
--- a/chrome/browser/resources/chromeos/login/oobe_screen_hid_detection.js |
+++ b/chrome/browser/resources/chromeos/login/oobe_screen_hid_detection.js |
@@ -7,11 +7,17 @@ |
*/ |
login.createScreen('HIDDetectionScreen', 'hid-detection', function() { |
+ var CONTEXT_KEY_KEYBOARD_STATE = 'keyboard-state'; |
+ var CONTEXT_KEY_MOUSE_STATE = 'mouse-state'; |
+ var CONTEXT_KEY_KEYBOARD_PINCODE = 'keyboard-pincode'; |
+ var CONTEXT_KEY_KEYBOARD_ENTERED_PART_EXPECTED = 'num-keys-entered-expected'; |
+ var CONTEXT_KEY_KEYBOARD_ENTERED_PART_PINCODE = 'num-keys-entered-pincode'; |
+ var CONTEXT_KEY_MOUSE_DEVICE_NAME = 'mouse-device-name'; |
+ var CONTEXT_KEY_KEYBOARD_DEVICE_NAME = 'keyboard-device-name'; |
+ var CONTEXT_KEY_KEYBOARD_LABEL = 'keyboard-device-label'; |
+ var CONTEXT_KEY_CONTINUE_BUTTON_ENABLED = 'continue-button-enabled'; |
+ |
return { |
- EXTERNAL_API: [ |
- 'setPointingDeviceState', |
- 'setKeyboardDeviceState', |
- ], |
/** |
* Enumeration of possible states during pairing. The value associated with |
@@ -22,18 +28,85 @@ login.createScreen('HIDDetectionScreen', 'hid-detection', function() { |
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 |
- */ |
- continueButton_: null, |
+ /** @override */ |
+ decorate: function() { |
+ var self = this; |
+ |
+ this.context.addObserver( |
+ CONTEXT_KEY_MOUSE_STATE, |
+ function(stateId) { |
+ if (stateId === undefined) |
+ return; |
+ self.setDeviceBlockState_('hid-mouse-block', stateId); |
+ } |
+ ); |
+ this.context.addObserver( |
+ CONTEXT_KEY_KEYBOARD_STATE, |
+ function(stateId) { |
+ if (stateId === undefined) |
+ return; |
+ self.setDeviceBlockState_('hid-keyboard-block', stateId); |
+ if (stateId == 'paired') { |
+ $('hid-keyboard-label-paired').textContent = self.context.get( |
+ CONTEXT_KEY_KEYBOARD_LABEL, ''); |
+ } else if (stateId == 'pairing') { |
+ $('hid-keyboard-label-pairing').textContent = self.context.get( |
+ CONTEXT_KEY_KEYBOARD_LABEL, ''); |
+ } else if (stateId == 'connected') { |
+ } |
+ } |
+ ); |
+ this.context.addObserver( |
+ CONTEXT_KEY_KEYBOARD_PINCODE, |
+ function(pincode) { |
+ self.setPincodeKeysState_(-1); |
+ if (!pincode) { |
+ $('hid-keyboard-pincode').classList.remove('show-pincode'); |
+ return; |
+ } |
+ if (self.context.get(CONTEXT_KEY_KEYBOARD_STATE, '') != 'pairing') |
+ return; |
+ $('hid-keyboard-pincode').classList.add('show-pincode'); |
+ for (var i = 0, len = pincode.length; i < len; i++) { |
+ var pincodeSymbol = $('hid-keyboard-pincode-sym-' + (i + 1)); |
+ pincodeSymbol.textContent = pincode[i]; |
+ } |
+ announceAccessibleMessage( |
+ self.context.get(CONTEXT_KEY_KEYBOARD_LABEL, '') + ' ' + pincode + |
+ ' ' + loadTimeData.getString('hidDetectionBTEnterKey')); |
+ } |
+ ); |
+ this.context.addObserver( |
+ CONTEXT_KEY_KEYBOARD_ENTERED_PART_EXPECTED, |
+ function(entered_part_expected) { |
+ if (self.context.get(CONTEXT_KEY_KEYBOARD_STATE, '') != 'pairing') |
+ return; |
+ if (!entered_part_expected) |
+ self.setPincodeKeysState_(-1); |
Denis Kuznetsov (DE-MUC)
2015/02/05 13:33:19
You can use here second bool parameter as well, wi
merkulova
2015/02/09 08:54:36
Done.
|
+ } |
+ ); |
+ this.context.addObserver( |
+ CONTEXT_KEY_KEYBOARD_ENTERED_PART_PINCODE, |
+ function(entered_part) { |
+ if (self.context.get(CONTEXT_KEY_KEYBOARD_STATE, '') != 'pairing' || |
+ !self.context.get(CONTEXT_KEY_KEYBOARD_ENTERED_PART_EXPECTED)) |
+ return; |
+ self.setPincodeKeysState_(entered_part); |
+ } |
+ ); |
+ this.context.addObserver( |
+ CONTEXT_KEY_CONTINUE_BUTTON_ENABLED, |
+ function(enabled) { |
+ $('hid-continue-button').disabled = !enabled; |
+ } |
+ ); |
+ }, |
/** |
* Buttons in oobe wizard's button strip. |
@@ -50,7 +123,6 @@ login.createScreen('HIDDetectionScreen', 'hid-detection', function() { |
e.stopPropagation(); |
}); |
buttons.push(continueButton); |
- this.continueButton_ = continueButton; |
return buttons; |
}, |
@@ -59,7 +131,7 @@ login.createScreen('HIDDetectionScreen', 'hid-detection', function() { |
* Returns a control which should receive an initial focus. |
*/ |
get defaultControl() { |
- return this.continueButton_; |
+ return $('hid-continue-button'); |
}, |
/** |
@@ -113,37 +185,6 @@ login.createScreen('HIDDetectionScreen', 'hid-detection', function() { |
}, |
/** |
- * 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) { |
- this.setPincodeKeysState_(-1); |
- for (var i = 0, len = data['pincode'].length; i < len; i++) { |
- var pincodeSymbol = $('hid-keyboard-pincode-sym-' + (i + 1)); |
- pincodeSymbol.textContent = data['pincode'][i]; |
- } |
- announceAccessibleMessage( |
- data['keyboard-label'] + ' ' + data['pincode'] + ' ' + |
- loadTimeData.getString('hidDetectionBTEnterKey')); |
- } |
- } else if (state == 'update') { |
- if ('keysEntered' in data) { |
- this.setPincodeKeysState_(data['keysEntered']); |
- } |
- } |
- }, |
- |
- /** |
* Event handler that is invoked just before the screen in shown. |
* @param {Object} data Screen init payload. |
*/ |