| OLD | NEW |
| (Empty) |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 /** | |
| 6 * @fileoverview | |
| 7 * 'settings-bluetooth-add-device-dialog' is the settings subpage for adding | |
| 8 * bluetooth devices. | |
| 9 */ | |
| 10 Polymer({ | |
| 11 is: 'settings-bluetooth-add-device-dialog', | |
| 12 | |
| 13 properties: { | |
| 14 /** | |
| 15 * The cached bluetooth adapter state. | |
| 16 * @type {!chrome.bluetooth.AdapterState|undefined} | |
| 17 */ | |
| 18 adapterState: { | |
| 19 type: Object, | |
| 20 observer: 'adapterStateChanged_', | |
| 21 }, | |
| 22 | |
| 23 /** | |
| 24 * The ordered list of bluetooth devices. | |
| 25 * @type {!Array<!chrome.bluetooth.Device>} | |
| 26 */ | |
| 27 deviceList: { | |
| 28 type: Array, | |
| 29 value: function() { return []; }, | |
| 30 }, | |
| 31 }, | |
| 32 | |
| 33 /** @private */ | |
| 34 adapterStateChanged_: function() { | |
| 35 if (!this.adapterState.powered) | |
| 36 this.fire('close-dialog'); | |
| 37 }, | |
| 38 | |
| 39 /** | |
| 40 * @param {!chrome.bluetooth.Device} device | |
| 41 * @return {boolean} | |
| 42 * @private | |
| 43 */ | |
| 44 deviceNotPaired_: function(device) { | |
| 45 return !device.paired; | |
| 46 }, | |
| 47 | |
| 48 /** | |
| 49 * @param {!Array<!chrome.bluetooth.Device>} deviceList | |
| 50 * @return {boolean} True if deviceList contains any unpaired devices. | |
| 51 * @private | |
| 52 */ | |
| 53 haveDevices_: function(deviceList) { | |
| 54 return this.deviceList.findIndex(function(d) { return !d.paired; }) != -1; | |
| 55 }, | |
| 56 | |
| 57 /** | |
| 58 * @param {!{detail: {action: string, device: !chrome.bluetooth.Device}}} e | |
| 59 * @private | |
| 60 */ | |
| 61 onDeviceEvent_: function(e) { | |
| 62 this.fire('device-event', e.detail); | |
| 63 /** @type {Event} */(e).stopPropagation(); | |
| 64 }, | |
| 65 | |
| 66 /** @private */ | |
| 67 onCancelTap_: function() { this.fire('close-dialog'); }, | |
| 68 }); | |
| OLD | NEW |