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

Unified Diff: chrome/browser/resources/settings/bluetooth_page/bluetooth_device_dialog.js

Issue 2148573003: MD Settings: Bluetooth: Additional polish (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Spelling Created 4 years, 5 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/settings/bluetooth_page/bluetooth_device_dialog.js
diff --git a/chrome/browser/resources/settings/bluetooth_page/bluetooth_device_dialog.js b/chrome/browser/resources/settings/bluetooth_page/bluetooth_device_dialog.js
index f700878bf38254bd346678f34323608a805d1d43..020ab409f22f8cff99ad52173f1c22dd6cf55e51 100644
--- a/chrome/browser/resources/settings/bluetooth_page/bluetooth_device_dialog.js
+++ b/chrome/browser/resources/settings/bluetooth_page/bluetooth_device_dialog.js
@@ -46,9 +46,7 @@ settings.BluetoothAddDeviceBehavior = {
* @return {boolean}
* @private
*/
- deviceNotPaired_: function(device) {
- return !device.paired;
- },
+ deviceNotPaired_: function(device) { return !device.paired; },
/**
* @param {!Array<!chrome.bluetooth.Device>} deviceList
@@ -65,7 +63,7 @@ settings.BluetoothAddDeviceBehavior = {
*/
onDeviceEvent_: function(e) {
this.fire('device-event', e.detail);
- /** @type {Event} */(e).stopPropagation();
+ /** @type {Event} */ (e).stopPropagation();
},
};
@@ -84,6 +82,9 @@ settings.BluetoothPairDeviceBehavior = {
*/
pairingEvent: Object,
+ /** Pincode or passkey value, used to trigger connect enabled changes. */
+ pinOrPass: String,
+
/**
* @const
* @type {!Array<number>}
@@ -110,6 +111,7 @@ settings.BluetoothPairDeviceBehavior = {
this.fire('close-dialog', '');
return;
}
+ this.pinOrPass = '';
},
/**
@@ -184,14 +186,27 @@ settings.BluetoothPairDeviceBehavior = {
if (!pairingEvent)
return false;
var pairing = pairingEvent.pairing;
- if (pairing == PairingEventType.REQUEST_PINCODE) {
- var pincode = /** @type {{invalid: boolean}} */(this.$.pincode);
- return !pincode.invalid;
- } else if (pairing == PairingEventType.REQUEST_PASSKEY) {
- var passkey = /** @type {{invalid: boolean}} */(this.$.passkey);
- return !passkey.invalid;
- }
- return false;
+ return pairing == PairingEventType.REQUEST_PINCODE ||
+ pairing == PairingEventType.REQUEST_PASSKEY;
+ },
+
+ /**
+ * @param {?chrome.bluetoothPrivate.PairingEvent} pairingEvent
+ * @param {string} pinOrPass Unused; call is triggered when this changes.
+ * @return {boolean}
+ * @private
+ */
+ enableConnect_: function(pairingEvent, pinOrPass) {
+ if (!this.showConnect_(this.pairingEvent))
+ return false;
+ var inputId =
+ (this.pairingEvent.pairing == PairingEventType.REQUEST_PINCODE) ?
+ '#pincode' :
+ '#passkey';
+ var paperInput = /** @type {!PaperInputElement} */ (this.$$(inputId));
+ assert(paperInput);
+ /** @type {string} */ var value = paperInput.value;
+ return !!value && paperInput.validate();
},
/**
@@ -235,9 +250,9 @@ settings.BluetoothPairDeviceBehavior = {
if (response == chrome.bluetoothPrivate.PairingResponse.CONFIRM) {
var pairing = this.pairingEvent.pairing;
if (pairing == PairingEventType.REQUEST_PINCODE)
- options.pincode = this.$.pincode.value;
+ options.pincode = this.$$('#pincode').value;
else if (pairing == PairingEventType.REQUEST_PASSKEY)
- options.passkey = parseInt(this.$.passkey.value, 10);
+ options.passkey = parseInt(this.$$('#passkey').value, 10);
}
this.fire('response', options);
},
@@ -254,7 +269,7 @@ settings.BluetoothPairDeviceBehavior = {
eventType == PairingEventType.REQUEST_AUTHORIZATION) {
return 'bluetoothStartConnecting';
}
- return 'bluetooth_' + /** @type {string} */(eventType);
+ return 'bluetooth_' + /** @type {string} */ (eventType);
},
/**
@@ -271,10 +286,10 @@ settings.BluetoothPairDeviceBehavior = {
if (pairing == PairingEventType.DISPLAY_PINCODE && pairingEvent.pincode &&
index < pairingEvent.pincode.length) {
digit = pairingEvent.pincode[index];
- } else if (pairingEvent.passkey &&
- (pairing == PairingEventType.DISPLAY_PASSKEY ||
- pairing == PairingEventType.KEYS_ENTERED ||
- pairing == PairingEventType.CONFIRM_PASSKEY)) {
+ } else if (
+ pairingEvent.passkey && (pairing == PairingEventType.DISPLAY_PASSKEY ||
+ pairing == PairingEventType.KEYS_ENTERED ||
+ pairing == PairingEventType.CONFIRM_PASSKEY)) {
var passkeyString = String(pairingEvent.passkey);
if (index < passkeyString.length)
digit = passkeyString[index];
@@ -303,7 +318,7 @@ settings.BluetoothPairDeviceBehavior = {
pairingEvent.pairing == PairingEventType.KEYS_ENTERED &&
pairingEvent.enteredKey) {
var enteredKey = pairingEvent.enteredKey; // 1-7
- var lastKey = this.digits.length; // 6
+ var lastKey = this.digits.length; // 6
if ((index == -1 && enteredKey > lastKey) || (index + 1 == enteredKey))
cssClass += ' next';
else if (index > enteredKey)
@@ -324,21 +339,27 @@ Polymer({
properties: {
/** Which version of this dialog to show (adding or pairing). */
- dialogType: String,
+ dialogId: String,
},
- /** @private */
- deviceListChanged_: function(e) {
- this.$.dialog.notifyResize();
+ open: function() {
+ this.pinOrPass = '';
+ this.$.dialog.open();
},
+ close: function() { this.$.dialog.close(); },
+
+ /** @private */
+ deviceListChanged_: function(e) { this.$.dialog.notifyResize(); },
+
/**
- * @param {string} dialogType
- * @return {string} The title of for that |dialogType|.
+ * @param {string} dialogId
+ * @return {string} The title of for that |dialogId|.
*/
- getTitle_: function(dialogType) {
- return this.i18n(dialogType == 'addDevice' ?
- 'bluetoothAddDevicePageTitle' : 'bluetoothPairDevicePageTitle');
+ getTitle_: function(dialogId) {
+ return this.i18n(
+ dialogId == 'addDevice' ? 'bluetoothAddDevicePageTitle' :
+ 'bluetoothPairDevicePageTitle');
},
/**
@@ -361,22 +382,12 @@ Polymer({
/** @private */
onIronOverlayCanceled_: function() {
- if (this.dialogType == 'pairDevice')
+ if (this.dialogId == 'pairDevice')
this.sendResponse_(chrome.bluetoothPrivate.PairingResponse.CANCEL);
},
/** @private */
- onIronOverlayClosed_: function() {
- this.fire('close-dialog', '');
- },
-
- open: function() {
- this.$.dialog.open();
- },
-
- close: function() {
- this.$.dialog.close();
- },
+ onIronOverlayClosed_: function() { this.fire('close-dialog', ''); },
});
})();

Powered by Google App Engine
This is Rietveld 408576698