| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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.define('options.system.bluetooth', function() { | 5 cr.define('options.system.bluetooth', function() { |
| 6 /** @const */ var ArrayDataModel = cr.ui.ArrayDataModel; | 6 /** @const */ var ArrayDataModel = cr.ui.ArrayDataModel; |
| 7 /** @const */ var DeletableItem = options.DeletableItem; | 7 /** @const */ var DeletableItem = options.DeletableItem; |
| 8 /** @const */ var DeletableItemList = options.DeletableItemList; | 8 /** @const */ var DeletableItemList = options.DeletableItemList; |
| 9 | 9 |
| 10 /** | 10 /** |
| 11 * Bluetooth settings constants. | 11 * Bluetooth settings constants. |
| 12 */ | 12 */ |
| 13 function Constants() {} | 13 function Constants() {} |
| 14 | 14 |
| 15 /** | 15 /** |
| 16 * Creates a new bluetooth list item. | 16 * Creates a new bluetooth list item. |
| 17 * @param {{name: string, | 17 * @param {{name: string, |
| 18 * address: string, | 18 * address: string, |
| 19 * paired: boolean, | 19 * paired: boolean, |
| 20 * bonded: boolean, | |
| 21 * connected: boolean, | 20 * connected: boolean, |
| 22 * pairing: string|undefined, | 21 * pairing: string|undefined, |
| 23 * passkey: number|undefined, | 22 * passkey: number|undefined, |
| 24 * entered: number|undefined}} device | 23 * entered: number|undefined}} device |
| 25 * Description of the Bluetooth device. | 24 * Description of the Bluetooth device. |
| 26 * @constructor | 25 * @constructor |
| 27 * @extends {options.DeletableItem} | 26 * @extends {options.DeletableItem} |
| 28 */ | 27 */ |
| 29 function BluetoothListItem(device) { | 28 function BluetoothListItem(device) { |
| 30 var el = cr.doc.createElement('div'); | 29 var el = cr.doc.createElement('div'); |
| 31 el.__proto__ = BluetoothListItem.prototype; | 30 el.__proto__ = BluetoothListItem.prototype; |
| 32 el.data = {}; | 31 el.data = {}; |
| 33 for (var key in device) | 32 for (var key in device) |
| 34 el.data[key] = device[key]; | 33 el.data[key] = device[key]; |
| 35 el.decorate(); | 34 el.decorate(); |
| 36 // Only show the close button for paired devices. | 35 // Only show the close button for paired devices. |
| 37 el.deletable = device.paired; | 36 el.deletable = device.paired; |
| 38 return el; | 37 return el; |
| 39 } | 38 } |
| 40 | 39 |
| 41 BluetoothListItem.prototype = { | 40 BluetoothListItem.prototype = { |
| 42 __proto__: DeletableItem.prototype, | 41 __proto__: DeletableItem.prototype, |
| 43 | 42 |
| 44 /** | 43 /** |
| 45 * Description of the Bluetooth device. | 44 * Description of the Bluetooth device. |
| 46 * @type {{name: string, | 45 * @type {{name: string, |
| 47 * address: string, | 46 * address: string, |
| 48 * paired: boolean, | 47 * paired: boolean, |
| 49 * bonded: boolean, | |
| 50 * connected: boolean, | 48 * connected: boolean, |
| 51 * pairing: string|undefined, | 49 * pairing: string|undefined, |
| 52 * passkey: number|undefined, | 50 * passkey: number|undefined, |
| 53 * entered: number|undefined}} | 51 * entered: number|undefined}} |
| 54 */ | 52 */ |
| 55 data: null, | 53 data: null, |
| 56 | 54 |
| 57 /** @override */ | 55 /** @override */ |
| 58 decorate: function() { | 56 decorate: function() { |
| 59 DeletableItem.prototype.decorate.call(this); | 57 DeletableItem.prototype.decorate.call(this); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 this.selectionModel.unselectAll(); | 119 this.selectionModel.unselectAll(); |
| 122 }, | 120 }, |
| 123 | 121 |
| 124 /** | 122 /** |
| 125 * Adds a bluetooth device to the list of available devices. A check is | 123 * Adds a bluetooth device to the list of available devices. A check is |
| 126 * made to see if the device is already in the list, in which case the | 124 * made to see if the device is already in the list, in which case the |
| 127 * existing device is updated. | 125 * existing device is updated. |
| 128 * @param {{name: string, | 126 * @param {{name: string, |
| 129 * address: string, | 127 * address: string, |
| 130 * paired: boolean, | 128 * paired: boolean, |
| 131 * bonded: boolean, | |
| 132 * connected: boolean, | 129 * connected: boolean, |
| 133 * pairing: string|undefined, | 130 * pairing: string|undefined, |
| 134 * passkey: number|undefined, | 131 * passkey: number|undefined, |
| 135 * entered: number|undefined}} device | 132 * entered: number|undefined}} device |
| 136 * Description of the bluetooth device. | 133 * Description of the bluetooth device. |
| 137 * @return {boolean} True if the devies was successfully added or updated. | 134 * @return {boolean} True if the devies was successfully added or updated. |
| 138 */ | 135 */ |
| 139 appendDevice: function(device) { | 136 appendDevice: function(device) { |
| 140 var selectedDevice = this.getSelectedDevice_(); | 137 var selectedDevice = this.getSelectedDevice_(); |
| 141 var index = this.find(device.address); | 138 var index = this.find(device.address); |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 cr.defineProperty(BluetoothListItem, 'paired', cr.PropertyKind.BOOL_ATTR); | 326 cr.defineProperty(BluetoothListItem, 'paired', cr.PropertyKind.BOOL_ATTR); |
| 330 | 327 |
| 331 cr.defineProperty(BluetoothListItem, 'connecting', cr.PropertyKind.BOOL_ATTR); | 328 cr.defineProperty(BluetoothListItem, 'connecting', cr.PropertyKind.BOOL_ATTR); |
| 332 | 329 |
| 333 return { | 330 return { |
| 334 BluetoothListItem: BluetoothListItem, | 331 BluetoothListItem: BluetoothListItem, |
| 335 BluetoothDeviceList: BluetoothDeviceList, | 332 BluetoothDeviceList: BluetoothDeviceList, |
| 336 Constants: Constants | 333 Constants: Constants |
| 337 }; | 334 }; |
| 338 }); | 335 }); |
| OLD | NEW |