Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 cr.exportPath('settings'); | 5 cr.exportPath('settings'); |
| 6 | 6 |
| 7 (function() { | |
| 8 | |
| 9 var PairingEventType = chrome.bluetoothPrivate.PairingEventType; | 7 var PairingEventType = chrome.bluetoothPrivate.PairingEventType; |
| 10 | 8 |
| 11 // NOTE(dbeam): even though these behaviors are only used privately, they must | 9 // NOTE(dbeam): even though these behaviors are only used privately, they must |
| 12 // be globally accessible for Closure's --polymer_pass to compile happily. | 10 // be globally accessible for Closure's --polymer_pass to compile happily. |
| 13 | 11 |
| 14 /** @polymerBehavior */ | 12 /** @polymerBehavior */ |
| 15 settings.BluetoothAddDeviceBehavior = { | 13 settings.BluetoothAddDeviceBehavior = { |
| 16 properties: { | 14 properties: { |
| 17 /** | 15 /** |
| 18 * The cached bluetooth adapter state. | 16 * The cached bluetooth adapter state. |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 38 /** | 36 /** |
| 39 * Reflects the iron-list selecteditem property. | 37 * Reflects the iron-list selecteditem property. |
| 40 * @type {!chrome.bluetooth.Device} | 38 * @type {!chrome.bluetooth.Device} |
| 41 */ | 39 */ |
| 42 selectedItem: { | 40 selectedItem: { |
| 43 type: Object, | 41 type: Object, |
| 44 observer: 'selectedItemChanged_', | 42 observer: 'selectedItemChanged_', |
| 45 }, | 43 }, |
| 46 }, | 44 }, |
| 47 | 45 |
| 48 /** @type {boolean} */ itemWasFocused_: false, | 46 /** @type {boolean} */ |
| 47 itemWasFocused_: false, | |
| 49 | 48 |
| 50 /** @private */ | 49 /** @private */ |
| 51 adapterStateChanged_: function() { | 50 adapterStateChanged_: function() { |
| 52 if (!this.adapterState.powered) | 51 if (!this.adapterState.powered) |
| 53 this.close(); | 52 this.close(); |
| 54 }, | 53 }, |
| 55 | 54 |
| 56 /** @private */ | 55 /** @private */ |
| 57 deviceListChanged_: function() { | 56 deviceListChanged_: function() { |
| 58 this.updateScrollableContents(); | 57 this.updateScrollableContents(); |
| 59 if (this.itemWasFocused_ || !this.getUnpaired_().length) | 58 if (this.itemWasFocused_ || !this.getUnpaired_().length) |
| 60 return; | 59 return; |
| 61 // If the iron-list is populated with at least one visible item then | 60 // If the iron-list is populated with at least one visible item then |
| 62 // focus it. | 61 // focus it. |
| 63 var item = this.$$('iron-list bluetooth-device-list-item'); | 62 var item = this.$$('iron-list bluetooth-device-list-item'); |
| 64 if (item && item.offsetParent != null) { | 63 if (item && item.offsetParent != null) { |
| 65 item.focus(); | 64 item.focus(); |
| 66 this.itemWasFocused_ = true; | 65 this.itemWasFocused_ = true; |
| 67 return; | 66 return; |
| 68 } | 67 } |
| 69 // Otherwise try again. | 68 // Otherwise try again. |
| 70 setTimeout(function() { this.deviceListChanged_(); }.bind(this), 100); | 69 setTimeout(function() { |
| 70 this.deviceListChanged_(); | |
| 71 }.bind(this), 100); | |
| 71 }, | 72 }, |
| 72 | 73 |
| 73 /** @private */ | 74 /** @private */ |
| 74 selectedItemChanged_: function() { | 75 selectedItemChanged_: function() { |
| 75 if (this.selectedItem) | 76 if (this.selectedItem) |
| 76 this.fire('device-event', {action: 'connect', device: this.selectedItem}); | 77 this.fire('device-event', {action: 'connect', device: this.selectedItem}); |
| 77 }, | 78 }, |
| 78 | 79 |
| 79 /** | 80 /** |
| 80 * @return {!Array<!chrome.bluetooth.Device>} | 81 * @return {!Array<!chrome.bluetooth.Device>} |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 93 haveUnpaired_: function(deviceList) { | 94 haveUnpaired_: function(deviceList) { |
| 94 return this.getUnpaired_().length > 0; | 95 return this.getUnpaired_().length > 0; |
| 95 }, | 96 }, |
| 96 }; | 97 }; |
| 97 | 98 |
| 98 /** @polymerBehavior */ | 99 /** @polymerBehavior */ |
| 99 settings.BluetoothPairDeviceBehavior = { | 100 settings.BluetoothPairDeviceBehavior = { |
| 100 properties: { | 101 properties: { |
| 101 /** | 102 /** |
| 102 * Current Pairing device. | 103 * Current Pairing device. |
| 103 * @type {?chrome.bluetooth.Device|undefined} | 104 * @type {!chrome.bluetooth.Device|undefined} |
| 104 */ | 105 */ |
| 105 pairingDevice: Object, | 106 pairingDevice: Object, |
| 106 | 107 |
| 107 /** | 108 /** |
| 108 * Current Pairing event. | 109 * Current Pairing event. |
| 109 * @type {?chrome.bluetoothPrivate.PairingEvent|undefined} | 110 * @type {?chrome.bluetoothPrivate.PairingEvent} |
| 110 */ | 111 */ |
| 111 pairingEvent: Object, | 112 pairingEvent_: { |
| 113 type: Object, | |
| 114 value: null, | |
| 115 }, | |
| 112 | 116 |
| 113 /** Pincode or passkey value, used to trigger connect enabled changes. */ | 117 /** Pincode or passkey value, used to trigger connect enabled changes. */ |
| 114 pinOrPass: String, | 118 pinOrPass: String, |
| 115 | 119 |
| 116 /** | 120 /** |
| 121 * Interface for bluetoothPrivate calls. Set in bluetooth-page. | |
| 122 * @type {BluetoothPrivate} | |
| 123 * @private | |
| 124 */ | |
| 125 bluetoothPrivate: { | |
| 126 type: Object, | |
| 127 value: chrome.bluetoothPrivate, | |
| 128 }, | |
| 129 | |
| 130 /** | |
| 117 * @const | 131 * @const |
| 118 * @type {!Array<number>} | 132 * @type {!Array<number>} |
| 119 */ | 133 */ |
| 120 digits: { | 134 digits: { |
| 121 type: Array, | 135 type: Array, |
| 122 readOnly: true, | 136 readOnly: true, |
| 123 value: [0, 1, 2, 3, 4, 5], | 137 value: [0, 1, 2, 3, 4, 5], |
| 124 }, | 138 }, |
| 125 }, | 139 }, |
| 126 | 140 |
| 127 observers: [ | 141 observers: [ |
| 128 'pairingChanged_(pairingDevice, pairingEvent)', | 142 'pairingChanged_(pairingDevice, pairingEvent_)', |
| 129 ], | 143 ], |
| 130 | 144 |
| 145 /** | |
| 146 * Listener for chrome.bluetoothPrivate.onPairing events. | |
| 147 * @type {?function(!chrome.bluetoothPrivate.PairingEvent)} | |
| 148 * @private | |
| 149 */ | |
| 150 bluetoothPrivateOnPairingListener_: null, | |
| 151 | |
| 152 /** Called when the dialog is opened. Starts listening for pairing events. */ | |
| 153 startPairing: function() { | |
|
fukino
2017/01/30 08:44:01
Can we make this function as @private?
stevenjb
2017/01/30 19:19:26
This is actually part of a behavior, and the metho
| |
| 154 if (!this.bluetoothPrivateOnPairingListener_) { | |
| 155 this.bluetoothPrivateOnPairingListener_ = | |
| 156 this.onBluetoothPrivateOnPairing_.bind(this); | |
| 157 this.bluetoothPrivate.onPairing.addListener( | |
| 158 this.bluetoothPrivateOnPairingListener_); | |
| 159 } | |
| 160 }, | |
| 161 | |
| 162 /** Called when the dialog is closed. */ | |
| 163 endPairing: function() { | |
|
fukino
2017/01/30 08:44:01
Can we make this function as @private?
stevenjb
2017/01/30 19:19:26
Ditto.
| |
| 164 if (this.bluetoothPrivateOnPairingListener_) { | |
| 165 this.bluetoothPrivate.onPairing.removeListener( | |
| 166 this.bluetoothPrivateOnPairingListener_); | |
| 167 this.bluetoothPrivateOnPairingListener_ = null; | |
| 168 } | |
| 169 this.pairingEvent_ = null; | |
| 170 }, | |
| 171 | |
| 172 /** | |
| 173 * Process bluetoothPrivate.onPairing events. | |
| 174 * @param {!chrome.bluetoothPrivate.PairingEvent} event | |
| 175 * @private | |
| 176 */ | |
| 177 onBluetoothPrivateOnPairing_: function(event) { | |
| 178 if (event.device.address != this.pairingDevice.address) | |
|
fukino
2017/01/30 08:44:01
I think we should check the existence of |this.pai
stevenjb
2017/01/30 19:19:26
Yeah, there are some new edge cases here that I di
| |
| 179 return; | |
| 180 if (event.pairing == PairingEventType.KEYS_ENTERED && | |
| 181 event.passkey === undefined && this.pairingEvent_) { | |
| 182 // 'keysEntered' event might not include the updated passkey so preserve | |
| 183 // the current one. | |
| 184 event.passkey = this.pairingEvent_.passkey; | |
| 185 } | |
| 186 this.pairingEvent_ = event; | |
| 187 }, | |
| 188 | |
| 131 /** @private */ | 189 /** @private */ |
| 132 pairingChanged_: function() { | 190 pairingChanged_: function() { |
| 133 // Auto-close the dialog when pairing completes. | 191 // Auto-close the dialog when pairing completes. |
| 134 if (this.pairingDevice && this.pairingDevice.connected) { | 192 if (this.pairingDevice.connected) { |
| 135 this.close(); | 193 this.close(); |
| 136 return; | 194 return; |
| 137 } | 195 } |
| 138 this.pinOrPass = ''; | 196 this.pinOrPass = ''; |
| 139 }, | 197 }, |
| 140 | 198 |
| 141 /** | 199 /** |
| 142 * @return {string} | 200 * @return {string} |
| 143 * @private | 201 * @private |
| 144 */ | 202 */ |
| 145 getMessage_: function() { | 203 getMessage_: function() { |
| 146 if (!this.pairingDevice) | |
| 147 return ''; | |
| 148 var message; | 204 var message; |
| 149 if (!this.pairingEvent) | 205 if (!this.pairingEvent_) |
| 150 message = 'bluetoothStartConnecting'; | 206 message = 'bluetoothStartConnecting'; |
| 151 else | 207 else |
| 152 message = this.getEventDesc_(this.pairingEvent.pairing); | 208 message = this.getEventDesc_(this.pairingEvent_.pairing); |
| 153 return this.i18n(message, this.pairingDevice.name); | 209 return this.i18n(message, this.pairingDevice.name); |
| 154 }, | 210 }, |
| 155 | 211 |
| 156 /** | 212 /** |
| 157 * @return {boolean} | 213 * @return {boolean} |
| 158 * @private | 214 * @private |
| 159 */ | 215 */ |
| 160 showEnterPincode_: function() { | 216 showEnterPincode_: function() { |
| 161 return !!this.pairingEvent && | 217 return !!this.pairingEvent_ && |
| 162 this.pairingEvent.pairing == PairingEventType.REQUEST_PINCODE; | 218 this.pairingEvent_.pairing == PairingEventType.REQUEST_PINCODE; |
| 163 }, | 219 }, |
| 164 | 220 |
| 165 /** | 221 /** |
| 166 * @return {boolean} | 222 * @return {boolean} |
| 167 * @private | 223 * @private |
| 168 */ | 224 */ |
| 169 showEnterPasskey_: function() { | 225 showEnterPasskey_: function() { |
| 170 return !!this.pairingEvent && | 226 return !!this.pairingEvent_ && |
| 171 this.pairingEvent.pairing == PairingEventType.REQUEST_PASSKEY; | 227 this.pairingEvent_.pairing == PairingEventType.REQUEST_PASSKEY; |
| 172 }, | 228 }, |
| 173 | 229 |
| 174 /** | 230 /** |
| 175 * @return {boolean} | 231 * @return {boolean} |
| 176 * @private | 232 * @private |
| 177 */ | 233 */ |
| 178 showDisplayPassOrPin_: function() { | 234 showDisplayPassOrPin_: function() { |
| 179 if (!this.pairingEvent) | 235 if (!this.pairingEvent_) |
| 180 return false; | 236 return false; |
| 181 var pairing = this.pairingEvent.pairing; | 237 var pairing = this.pairingEvent_.pairing; |
| 182 return ( | 238 return ( |
| 183 pairing == PairingEventType.DISPLAY_PINCODE || | 239 pairing == PairingEventType.DISPLAY_PINCODE || |
| 184 pairing == PairingEventType.DISPLAY_PASSKEY || | 240 pairing == PairingEventType.DISPLAY_PASSKEY || |
| 185 pairing == PairingEventType.CONFIRM_PASSKEY || | 241 pairing == PairingEventType.CONFIRM_PASSKEY || |
| 186 pairing == PairingEventType.KEYS_ENTERED); | 242 pairing == PairingEventType.KEYS_ENTERED); |
| 187 }, | 243 }, |
| 188 | 244 |
| 189 /** | 245 /** |
| 190 * @return {boolean} | 246 * @return {boolean} |
| 191 * @private | 247 * @private |
| 192 */ | 248 */ |
| 193 showAcceptReject_: function() { | 249 showAcceptReject_: function() { |
| 194 return !!this.pairingEvent && | 250 return !!this.pairingEvent_ && |
| 195 this.pairingEvent.pairing == PairingEventType.CONFIRM_PASSKEY; | 251 this.pairingEvent_.pairing == PairingEventType.CONFIRM_PASSKEY; |
| 196 }, | 252 }, |
| 197 | 253 |
| 198 /** | 254 /** |
| 199 * @return {boolean} | 255 * @return {boolean} |
| 200 * @private | 256 * @private |
| 201 */ | 257 */ |
| 202 showConnect_: function() { | 258 showConnect_: function() { |
| 203 if (!this.pairingEvent) | 259 if (!this.pairingEvent_) |
| 204 return false; | 260 return false; |
| 205 var pairing = this.pairingEvent.pairing; | 261 var pairing = this.pairingEvent_.pairing; |
| 206 return pairing == PairingEventType.REQUEST_PINCODE || | 262 return pairing == PairingEventType.REQUEST_PINCODE || |
| 207 pairing == PairingEventType.REQUEST_PASSKEY; | 263 pairing == PairingEventType.REQUEST_PASSKEY; |
| 208 }, | 264 }, |
| 209 | 265 |
| 210 /** | 266 /** |
| 211 * @return {boolean} | 267 * @return {boolean} |
| 212 * @private | 268 * @private |
| 213 */ | 269 */ |
| 214 enableConnect_: function() { | 270 enableConnect_: function() { |
| 215 if (!this.showConnect_()) | 271 if (!this.showConnect_()) |
| 216 return false; | 272 return false; |
| 217 var inputId = | 273 var inputId = |
| 218 (this.pairingEvent.pairing == PairingEventType.REQUEST_PINCODE) ? | 274 (this.pairingEvent_.pairing == PairingEventType.REQUEST_PINCODE) ? |
| 219 '#pincode' : | 275 '#pincode' : |
| 220 '#passkey'; | 276 '#passkey'; |
| 221 var paperInput = /** @type {!PaperInputElement} */ (this.$$(inputId)); | 277 var paperInput = /** @type {!PaperInputElement} */ (this.$$(inputId)); |
| 222 assert(paperInput); | 278 assert(paperInput); |
| 223 /** @type {string} */ var value = paperInput.value; | 279 /** @type {string} */ var value = paperInput.value; |
| 224 return !!value && paperInput.validate(); | 280 return !!value && paperInput.validate(); |
| 225 }, | 281 }, |
| 226 | 282 |
| 227 /** | 283 /** |
| 228 * @return {boolean} | 284 * @return {boolean} |
| 229 * @private | 285 * @private |
| 230 */ | 286 */ |
| 231 showDismiss_: function() { | 287 showDismiss_: function() { |
| 232 return (!!this.paringDevice && this.pairingDevice.paired) || | 288 return this.pairingDevice.paired || |
| 233 (!!this.pairingEvent && | 289 (!!this.pairingEvent_ && |
| 234 this.pairingEvent.pairing == PairingEventType.COMPLETE); | 290 this.pairingEvent_.pairing == PairingEventType.COMPLETE); |
| 235 }, | 291 }, |
| 236 | 292 |
| 237 /** @private */ | 293 /** @private */ |
| 238 onAcceptTap_: function() { | 294 onAcceptTap_: function() { |
| 239 this.sendResponse_(chrome.bluetoothPrivate.PairingResponse.CONFIRM); | 295 this.sendResponse_(chrome.bluetoothPrivate.PairingResponse.CONFIRM); |
| 240 }, | 296 }, |
| 241 | 297 |
| 242 /** @private */ | 298 /** @private */ |
| 243 onConnectTap_: function() { | 299 onConnectTap_: function() { |
| 244 this.sendResponse_(chrome.bluetoothPrivate.PairingResponse.CONFIRM); | 300 this.sendResponse_(chrome.bluetoothPrivate.PairingResponse.CONFIRM); |
| 245 }, | 301 }, |
| 246 | 302 |
| 247 /** @private */ | 303 /** @private */ |
| 248 onRejectTap_: function() { | 304 onRejectTap_: function() { |
| 249 this.sendResponse_(chrome.bluetoothPrivate.PairingResponse.REJECT); | 305 this.sendResponse_(chrome.bluetoothPrivate.PairingResponse.REJECT); |
| 250 }, | 306 }, |
| 251 | 307 |
| 252 /** | 308 /** |
| 253 * @param {!chrome.bluetoothPrivate.PairingResponse} response | 309 * @param {!chrome.bluetoothPrivate.PairingResponse} response |
| 254 * @private | 310 * @private |
| 255 */ | 311 */ |
| 256 sendResponse_: function(response) { | 312 sendResponse_: function(response) { |
| 257 if (!this.pairingDevice) | |
| 258 return; | |
| 259 var options = | 313 var options = |
| 260 /** @type {!chrome.bluetoothPrivate.SetPairingResponseOptions} */ { | 314 /** @type {!chrome.bluetoothPrivate.SetPairingResponseOptions} */ { |
| 261 device: this.pairingDevice, | 315 device: this.pairingDevice, |
| 262 response: response | 316 response: response |
| 263 }; | 317 }; |
| 264 if (response == chrome.bluetoothPrivate.PairingResponse.CONFIRM) { | 318 if (response == chrome.bluetoothPrivate.PairingResponse.CONFIRM) { |
| 265 var pairing = this.pairingEvent.pairing; | 319 var pairing = this.pairingEvent_.pairing; |
| 266 if (pairing == PairingEventType.REQUEST_PINCODE) | 320 if (pairing == PairingEventType.REQUEST_PINCODE) |
| 267 options.pincode = this.$$('#pincode').value; | 321 options.pincode = this.$$('#pincode').value; |
| 268 else if (pairing == PairingEventType.REQUEST_PASSKEY) | 322 else if (pairing == PairingEventType.REQUEST_PASSKEY) |
| 269 options.passkey = parseInt(this.$$('#passkey').value, 10); | 323 options.passkey = parseInt(this.$$('#passkey').value, 10); |
| 270 } | 324 } |
| 271 this.fire('response', options); | 325 this.fire('response', options); |
| 272 }, | 326 }, |
| 273 | 327 |
| 274 /** | 328 /** |
| 275 * @param {!PairingEventType} eventType | 329 * @param {!PairingEventType} eventType |
| 276 * @return {string} | 330 * @return {string} |
| 277 * @private | 331 * @private |
| 278 */ | 332 */ |
| 279 getEventDesc_: function(eventType) { | 333 getEventDesc_: function(eventType) { |
| 280 assert(eventType); | 334 assert(eventType); |
| 281 if (eventType == PairingEventType.COMPLETE || | 335 if (eventType == PairingEventType.COMPLETE || |
| 282 eventType == PairingEventType.KEYS_ENTERED || | 336 eventType == PairingEventType.KEYS_ENTERED || |
| 283 eventType == PairingEventType.REQUEST_AUTHORIZATION) { | 337 eventType == PairingEventType.REQUEST_AUTHORIZATION) { |
| 284 return 'bluetoothStartConnecting'; | 338 return 'bluetoothStartConnecting'; |
| 285 } | 339 } |
| 286 return 'bluetooth_' + /** @type {string} */ (eventType); | 340 return 'bluetooth_' + /** @type {string} */ (eventType); |
| 287 }, | 341 }, |
| 288 | 342 |
| 289 /** | 343 /** |
| 290 * @param {number} index | 344 * @param {number} index |
| 291 * @return {string} | 345 * @return {string} |
| 292 * @private | 346 * @private |
| 293 */ | 347 */ |
| 294 getPinDigit_: function(index) { | 348 getPinDigit_: function(index) { |
| 295 if (!this.pairingEvent) | 349 if (!this.pairingEvent_) |
| 296 return ''; | 350 return ''; |
| 297 var digit = '0'; | 351 var digit = '0'; |
| 298 var pairing = this.pairingEvent.pairing; | 352 var pairing = this.pairingEvent_.pairing; |
| 299 if (pairing == PairingEventType.DISPLAY_PINCODE && | 353 if (pairing == PairingEventType.DISPLAY_PINCODE && |
| 300 this.pairingEvent.pincode && index < this.pairingEvent.pincode.length) { | 354 this.pairingEvent_.pincode && |
| 301 digit = this.pairingEvent.pincode[index]; | 355 index < this.pairingEvent_.pincode.length) { |
| 356 digit = this.pairingEvent_.pincode[index]; | |
| 302 } else if ( | 357 } else if ( |
| 303 this.pairingEvent.passkey && | 358 this.pairingEvent_.passkey && |
| 304 (pairing == PairingEventType.DISPLAY_PASSKEY || | 359 (pairing == PairingEventType.DISPLAY_PASSKEY || |
| 305 pairing == PairingEventType.KEYS_ENTERED || | 360 pairing == PairingEventType.KEYS_ENTERED || |
| 306 pairing == PairingEventType.CONFIRM_PASSKEY)) { | 361 pairing == PairingEventType.CONFIRM_PASSKEY)) { |
| 307 var passkeyString = String(this.pairingEvent.passkey); | 362 var passkeyString = String(this.pairingEvent_.passkey); |
| 308 if (index < passkeyString.length) | 363 if (index < passkeyString.length) |
| 309 digit = passkeyString[index]; | 364 digit = passkeyString[index]; |
| 310 } | 365 } |
| 311 return digit; | 366 return digit; |
| 312 }, | 367 }, |
| 313 | 368 |
| 314 /** | 369 /** |
| 315 * @param {number} index | 370 * @param {number} index |
| 316 * @return {string} | 371 * @return {string} |
| 317 * @private | 372 * @private |
| 318 */ | 373 */ |
| 319 getPinClass_: function(index) { | 374 getPinClass_: function(index) { |
| 320 if (!this.pairingEvent) | 375 if (!this.pairingEvent_) |
| 321 return ''; | 376 return ''; |
| 322 if (this.pairingEvent.pairing == PairingEventType.CONFIRM_PASSKEY) | 377 if (this.pairingEvent_.pairing == PairingEventType.CONFIRM_PASSKEY) |
| 323 return 'confirm'; | 378 return 'confirm'; |
| 324 var cssClass = 'display'; | 379 var cssClass = 'display'; |
| 325 if (this.pairingEvent.pairing == PairingEventType.DISPLAY_PASSKEY) { | 380 if (this.pairingEvent_.pairing == PairingEventType.DISPLAY_PASSKEY) { |
| 326 if (index == 0) | 381 if (index == 0) |
| 327 cssClass += ' next'; | 382 cssClass += ' next'; |
| 328 else | 383 else |
| 329 cssClass += ' untyped'; | 384 cssClass += ' untyped'; |
| 330 } else if ( | 385 } else if ( |
| 331 this.pairingEvent.pairing == PairingEventType.KEYS_ENTERED && | 386 this.pairingEvent_.pairing == PairingEventType.KEYS_ENTERED && |
| 332 this.pairingEvent.enteredKey) { | 387 this.pairingEvent_.enteredKey) { |
| 333 var enteredKey = this.pairingEvent.enteredKey; // 1-7 | 388 var enteredKey = this.pairingEvent_.enteredKey; // 1-7 |
| 334 var lastKey = this.digits.length; // 6 | 389 var lastKey = this.digits.length; // 6 |
| 335 if ((index == -1 && enteredKey > lastKey) || (index + 1 == enteredKey)) | 390 if ((index == -1 && enteredKey > lastKey) || (index + 1 == enteredKey)) |
| 336 cssClass += ' next'; | 391 cssClass += ' next'; |
| 337 else if (index > enteredKey) | 392 else if (index > enteredKey) |
| 338 cssClass += ' untyped'; | 393 cssClass += ' untyped'; |
| 339 } | 394 } |
| 340 return cssClass; | 395 return cssClass; |
| 341 }, | 396 }, |
| 342 }; | 397 }; |
| 343 | 398 |
| 344 Polymer({ | 399 Polymer({ |
| 345 is: 'bluetooth-device-dialog', | 400 is: 'bluetooth-device-dialog', |
| 346 | 401 |
| 347 behaviors: [ | 402 behaviors: [ |
| 348 I18nBehavior, | 403 I18nBehavior, |
| 349 CrScrollableBehavior, | 404 CrScrollableBehavior, |
| 350 settings.BluetoothAddDeviceBehavior, | 405 settings.BluetoothAddDeviceBehavior, |
| 351 settings.BluetoothPairDeviceBehavior, | 406 settings.BluetoothPairDeviceBehavior, |
| 352 ], | 407 ], |
| 353 | 408 |
| 354 properties: { | 409 properties: { |
| 355 /** | 410 /** |
| 356 * The version of this dialog to show: 'addDevice', 'pairDevice', or | 411 * The version of this dialog to show: 'addDevice', 'pairDevice', or |
| 357 * 'connectError'. Must be set before the dialog is opened. | 412 * 'connectError'. Must be set before the dialog is opened. |
| 358 */ | 413 */ |
| 359 dialogId: String, | 414 dialogId: String, |
| 360 }, | 415 }, |
| 361 | 416 |
| 362 observers: [ | 417 observers: [ |
| 363 'dialogUpdated_(dialogId, pairingEvent)', | 418 'dialogUpdated_(dialogId, pairingEvent_)', |
| 364 ], | 419 ], |
| 365 | 420 |
| 366 open: function() { | 421 open: function() { |
| 422 this.startPairing(); | |
| 367 this.pinOrPass = ''; | 423 this.pinOrPass = ''; |
| 368 this.getDialog_().showModal(); | 424 this.getDialog_().showModal(); |
| 369 this.itemWasFocused_ = false; | 425 this.itemWasFocused_ = false; |
| 370 }, | 426 }, |
| 371 | 427 |
| 372 close: function() { | 428 close: function() { |
|
fukino
2017/01/30 08:44:01
close() is not called when the dialog is closed by
stevenjb
2017/01/30 19:19:26
Right, thanks. Fixed.
| |
| 429 this.endPairing(); | |
| 373 var dialog = this.getDialog_(); | 430 var dialog = this.getDialog_(); |
| 374 if (dialog.open) | 431 if (dialog.open) |
| 375 dialog.close(); | 432 dialog.close(); |
| 376 }, | 433 }, |
| 377 | 434 |
| 378 /** @private */ | 435 /** @private */ |
| 379 dialogUpdated_: function() { | 436 dialogUpdated_: function() { |
| 380 if (this.showEnterPincode_()) | 437 if (this.showEnterPincode_()) |
| 381 this.$$('#pincode').focus(); | 438 this.$$('#pincode').focus(); |
| 382 else if (this.showEnterPasskey_()) | 439 else if (this.showEnterPasskey_()) |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 404 onCancelTap_: function() { | 461 onCancelTap_: function() { |
| 405 this.getDialog_().cancel(); | 462 this.getDialog_().cancel(); |
| 406 }, | 463 }, |
| 407 | 464 |
| 408 /** @private */ | 465 /** @private */ |
| 409 onDialogCanceled_: function() { | 466 onDialogCanceled_: function() { |
| 410 if (this.dialogId == 'pairDevice') | 467 if (this.dialogId == 'pairDevice') |
| 411 this.sendResponse_(chrome.bluetoothPrivate.PairingResponse.CANCEL); | 468 this.sendResponse_(chrome.bluetoothPrivate.PairingResponse.CANCEL); |
| 412 }, | 469 }, |
| 413 }); | 470 }); |
| 414 | |
| 415 })(); | |
| OLD | NEW |