| 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() { | 7 (function() { |
| 8 | 8 |
| 9 var PairingEventType = chrome.bluetoothPrivate.PairingEventType; | 9 var PairingEventType = chrome.bluetoothPrivate.PairingEventType; |
| 10 | 10 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 deviceList: { | 30 deviceList: { |
| 31 type: Array, | 31 type: Array, |
| 32 value: /** @return {Array} */ function() { return []; }, | 32 value: /** @return {Array} */ function() { return []; }, |
| 33 }, | 33 }, |
| 34 }, | 34 }, |
| 35 | 35 |
| 36 observers: ['deviceListChanged_(deviceList.*)'], | 36 observers: ['deviceListChanged_(deviceList.*)'], |
| 37 | 37 |
| 38 /** @private */ | 38 /** @private */ |
| 39 adapterStateChanged_: function() { | 39 adapterStateChanged_: function() { |
| 40 if (!this.adapterState.powered) | 40 if (!this.adapterState.powered && this.$.dialog.opened) |
| 41 this.fire('close-dialog'); | 41 this.close(); |
| 42 }, | 42 }, |
| 43 | 43 |
| 44 /** | 44 /** |
| 45 * @param {!chrome.bluetooth.Device} device | 45 * @param {!chrome.bluetooth.Device} device |
| 46 * @return {boolean} | 46 * @return {boolean} |
| 47 * @private | 47 * @private |
| 48 */ | 48 */ |
| 49 deviceNotPaired_: function(device) { return !device.paired; }, | 49 deviceNotPaired_: function(device) { return !device.paired; }, |
| 50 | 50 |
| 51 /** | 51 /** |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 ], | 101 ], |
| 102 | 102 |
| 103 /** | 103 /** |
| 104 * @param {?chrome.bluetooth.Device} pairingDevice | 104 * @param {?chrome.bluetooth.Device} pairingDevice |
| 105 * @param {?chrome.bluetoothPrivate.PairingEvent} pairingEvent | 105 * @param {?chrome.bluetoothPrivate.PairingEvent} pairingEvent |
| 106 * @private | 106 * @private |
| 107 */ | 107 */ |
| 108 pairingChanged_: function(pairingDevice, pairingEvent) { | 108 pairingChanged_: function(pairingDevice, pairingEvent) { |
| 109 // Auto-close the dialog when pairing completes. | 109 // Auto-close the dialog when pairing completes. |
| 110 if (pairingDevice && pairingDevice.connected) { | 110 if (pairingDevice && pairingDevice.connected) { |
| 111 this.fire('close-dialog', ''); | 111 this.close(); |
| 112 return; | 112 return; |
| 113 } | 113 } |
| 114 this.pinOrPass = ''; | 114 this.pinOrPass = ''; |
| 115 }, | 115 }, |
| 116 | 116 |
| 117 /** | 117 /** |
| 118 * @param {?chrome.bluetooth.Device} device | 118 * @param {?chrome.bluetooth.Device} device |
| 119 * @param {?chrome.bluetoothPrivate.PairingEvent} pairingEvent | 119 * @param {?chrome.bluetoothPrivate.PairingEvent} pairingEvent |
| 120 * @return {string} | 120 * @return {string} |
| 121 * @private | 121 * @private |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 onConnectTap_: function() { | 229 onConnectTap_: function() { |
| 230 this.sendResponse_(chrome.bluetoothPrivate.PairingResponse.CONFIRM); | 230 this.sendResponse_(chrome.bluetoothPrivate.PairingResponse.CONFIRM); |
| 231 }, | 231 }, |
| 232 | 232 |
| 233 /** @private */ | 233 /** @private */ |
| 234 onRejectTap_: function() { | 234 onRejectTap_: function() { |
| 235 this.sendResponse_(chrome.bluetoothPrivate.PairingResponse.REJECT); | 235 this.sendResponse_(chrome.bluetoothPrivate.PairingResponse.REJECT); |
| 236 }, | 236 }, |
| 237 | 237 |
| 238 /** @private */ | 238 /** @private */ |
| 239 onDismissTap_: function() { this.fire('close-dialog', ''); }, | |
| 240 | |
| 241 /** @private */ | |
| 242 sendResponse_: function(response) { | 239 sendResponse_: function(response) { |
| 243 if (!this.pairingDevice) | 240 if (!this.pairingDevice) |
| 244 return; | 241 return; |
| 245 var options = | 242 var options = |
| 246 /** @type {!chrome.bluetoothPrivate.SetPairingResponseOptions} */ { | 243 /** @type {!chrome.bluetoothPrivate.SetPairingResponseOptions} */ { |
| 247 device: this.pairingDevice, | 244 device: this.pairingDevice, |
| 248 response: response | 245 response: response |
| 249 }; | 246 }; |
| 250 if (response == chrome.bluetoothPrivate.PairingResponse.CONFIRM) { | 247 if (response == chrome.bluetoothPrivate.PairingResponse.CONFIRM) { |
| 251 var pairing = this.pairingEvent.pairing; | 248 var pairing = this.pairingEvent.pairing; |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 379 // iron-overlay-cancel event, whereas tapping (X) or pressing Esc does. | 376 // iron-overlay-cancel event, whereas tapping (X) or pressing Esc does. |
| 380 // Using cancel() ensures all 3 ways to close the dialog run the same code. | 377 // Using cancel() ensures all 3 ways to close the dialog run the same code. |
| 381 this.$.dialog.cancel(); | 378 this.$.dialog.cancel(); |
| 382 }, | 379 }, |
| 383 | 380 |
| 384 /** @private */ | 381 /** @private */ |
| 385 onIronOverlayCanceled_: function() { | 382 onIronOverlayCanceled_: function() { |
| 386 if (this.dialogId == 'pairDevice') | 383 if (this.dialogId == 'pairDevice') |
| 387 this.sendResponse_(chrome.bluetoothPrivate.PairingResponse.CANCEL); | 384 this.sendResponse_(chrome.bluetoothPrivate.PairingResponse.CANCEL); |
| 388 }, | 385 }, |
| 389 | |
| 390 /** @private */ | |
| 391 onIronOverlayClosed_: function() { this.fire('close-dialog', ''); }, | |
| 392 }); | 386 }); |
| 393 | 387 |
| 394 })(); | 388 })(); |
| OLD | NEW |