| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 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 /** | 5 /** |
| 6 * @fileoverview | 6 * @fileoverview |
| 7 * 'settings-bluetooth-page' is the settings page for managing bluetooth | 7 * 'settings-bluetooth-page' is the settings page for managing bluetooth |
| 8 * properties and devices. | 8 * properties and devices. |
| 9 * | 9 * |
| 10 * Example: | 10 * Example: |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 }, | 55 }, |
| 56 | 56 |
| 57 /** | 57 /** |
| 58 * The cached bluetooth adapter state. | 58 * The cached bluetooth adapter state. |
| 59 * @type {!chrome.bluetooth.AdapterState|undefined} | 59 * @type {!chrome.bluetooth.AdapterState|undefined} |
| 60 * @private | 60 * @private |
| 61 */ | 61 */ |
| 62 adapterState_: Object, | 62 adapterState_: Object, |
| 63 | 63 |
| 64 /** | 64 /** |
| 65 * Whether or not a bluetooth device is connected. |
| 66 * @private |
| 67 */ |
| 68 deviceConnected_: Boolean, |
| 69 |
| 70 /** |
| 65 * The ordered list of bluetooth devices. | 71 * The ordered list of bluetooth devices. |
| 66 * @type {!Array<!chrome.bluetooth.Device>} | 72 * @type {!Array<!chrome.bluetooth.Device>} |
| 67 * @private | 73 * @private |
| 68 */ | 74 */ |
| 69 deviceList_: { | 75 deviceList_: { |
| 70 type: Array, | 76 type: Array, |
| 71 value: function() { | 77 value: function() { |
| 72 return []; | 78 return []; |
| 73 }, | 79 }, |
| 74 }, | 80 }, |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 * Interface for bluetoothPrivate calls. May be overriden by tests. | 133 * Interface for bluetoothPrivate calls. May be overriden by tests. |
| 128 * @type {BluetoothPrivate} | 134 * @type {BluetoothPrivate} |
| 129 * @private | 135 * @private |
| 130 */ | 136 */ |
| 131 bluetoothPrivate: { | 137 bluetoothPrivate: { |
| 132 type: Object, | 138 type: Object, |
| 133 value: chrome.bluetoothPrivate, | 139 value: chrome.bluetoothPrivate, |
| 134 }, | 140 }, |
| 135 }, | 141 }, |
| 136 | 142 |
| 143 observers: ['deviceListChanged_(deviceList_.*)'], |
| 144 |
| 137 /** | 145 /** |
| 138 * Listener for chrome.bluetooth.onAdapterStateChanged events. | 146 * Listener for chrome.bluetooth.onAdapterStateChanged events. |
| 139 * @type {function(!chrome.bluetooth.AdapterState)|undefined} | 147 * @type {function(!chrome.bluetooth.AdapterState)|undefined} |
| 140 * @private | 148 * @private |
| 141 */ | 149 */ |
| 142 bluetoothAdapterStateChangedListener_: undefined, | 150 bluetoothAdapterStateChangedListener_: undefined, |
| 143 | 151 |
| 144 /** | 152 /** |
| 145 * Listener for chrome.bluetooth.onBluetoothDeviceAdded/Changed events. | 153 * Listener for chrome.bluetooth.onBluetoothDeviceAdded/Changed events. |
| 146 * @type {function(!chrome.bluetooth.Device)|undefined} | 154 * @type {function(!chrome.bluetooth.Device)|undefined} |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 }, | 220 }, |
| 213 | 221 |
| 214 /** @private */ | 222 /** @private */ |
| 215 bluetoothEnabledChanged_: function() { | 223 bluetoothEnabledChanged_: function() { |
| 216 // When bluetooth is enabled, auto-expand the device list. | 224 // When bluetooth is enabled, auto-expand the device list. |
| 217 if (this.bluetoothEnabled_) | 225 if (this.bluetoothEnabled_) |
| 218 this.deviceListExpanded_ = true; | 226 this.deviceListExpanded_ = true; |
| 219 }, | 227 }, |
| 220 | 228 |
| 221 /** @private */ | 229 /** @private */ |
| 230 deviceListChanged_: function() { |
| 231 for (let device of this.deviceList_) { |
| 232 if (device.connected) { |
| 233 this.deviceConnected_ = true; |
| 234 return; |
| 235 } |
| 236 } |
| 237 this.deviceConnected_ = false; |
| 238 }, |
| 239 |
| 240 /** @private */ |
| 222 selectedItemChanged_: function() { | 241 selectedItemChanged_: function() { |
| 223 if (this.selectedItem_) | 242 if (this.selectedItem_) |
| 224 this.connectDevice_(this.selectedItem_); | 243 this.connectDevice_(this.selectedItem_); |
| 225 }, | 244 }, |
| 226 | 245 |
| 246 /** |
| 247 * @return {string} |
| 248 * @private |
| 249 */ |
| 250 getIcon_: function() { |
| 251 if (!this.bluetoothEnabled_) |
| 252 return 'settings:bluetooth-disabled'; |
| 253 if (this.deviceConnected_) |
| 254 return 'settings:bluetooth-connected'; |
| 255 return 'settings:bluetooth'; |
| 256 }, |
| 257 |
| 258 /** |
| 259 * @return {string} |
| 260 * @private |
| 261 */ |
| 262 getTitle_: function() { |
| 263 return this.i18n( |
| 264 this.bluetoothEnabled_ ? 'bluetoothEnabled' : 'bluetoothDisabled'); |
| 265 }, |
| 266 |
| 227 /** @private */ | 267 /** @private */ |
| 228 toggleDeviceListExpanded_: function() { | 268 toggleDeviceListExpanded_: function() { |
| 229 this.deviceListExpanded_ = !this.deviceListExpanded_; | 269 this.deviceListExpanded_ = !this.deviceListExpanded_; |
| 230 }, | 270 }, |
| 231 | 271 |
| 232 /** | 272 /** |
| 233 * @return {boolean} Whether the <iron-collapse> can be shown. | 273 * @return {boolean} Whether the <iron-collapse> can be shown. |
| 234 * @private | 274 * @private |
| 235 */ | 275 */ |
| 236 canShowDeviceList_: function() { | 276 canShowDeviceList_: function() { |
| (...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 578 }, | 618 }, |
| 579 | 619 |
| 580 /** | 620 /** |
| 581 * @param {Event} e | 621 * @param {Event} e |
| 582 * @private | 622 * @private |
| 583 */ | 623 */ |
| 584 stopTap_: function(e) { | 624 stopTap_: function(e) { |
| 585 e.stopPropagation(); | 625 e.stopPropagation(); |
| 586 }, | 626 }, |
| 587 }); | 627 }); |
| OLD | NEW |