| Index: chrome/browser/resources/settings/bluetooth_page/bluetooth_subpage.js
|
| diff --git a/chrome/browser/resources/settings/bluetooth_page/bluetooth_subpage.js b/chrome/browser/resources/settings/bluetooth_page/bluetooth_subpage.js
|
| index eec93c88966f03604539f1f3f60bfe940e0d67b8..bbff7a444320c4665809a22a8290ce354dec454f 100644
|
| --- a/chrome/browser/resources/settings/bluetooth_page/bluetooth_subpage.js
|
| +++ b/chrome/browser/resources/settings/bluetooth_page/bluetooth_subpage.js
|
| @@ -24,7 +24,6 @@ Polymer({
|
| /** Reflects the bluetooth-page property. */
|
| bluetoothEnabled: {
|
| type: Boolean,
|
| - observer: 'bluetoothEnabledChanged_',
|
| notify: true,
|
| },
|
|
|
| @@ -148,21 +147,22 @@ Polymer({
|
|
|
| /**
|
| * Listener for chrome.bluetooth.onBluetoothDeviceAdded/Changed events.
|
| - * @type {function(!chrome.bluetooth.Device)|undefined}
|
| + * @type {?function(!chrome.bluetooth.Device)}
|
| * @private
|
| */
|
| - bluetoothDeviceUpdatedListener_: undefined,
|
| + bluetoothDeviceUpdatedListener_: null,
|
|
|
| /**
|
| * Listener for chrome.bluetooth.onBluetoothDeviceRemoved events.
|
| - * @type {function(!chrome.bluetooth.Device)|undefined}
|
| + * @type {?function(!chrome.bluetooth.Device)}
|
| * @private
|
| */
|
| - bluetoothDeviceRemovedListener_: undefined,
|
| + bluetoothDeviceRemovedListener_: null,
|
|
|
| /** @override */
|
| attached: function() {
|
| this.bluetoothDeviceUpdatedListener_ =
|
| + this.bluetoothDeviceUpdatedListener_ ||
|
| this.onBluetoothDeviceUpdated_.bind(this);
|
| this.bluetooth.onDeviceAdded.addListener(
|
| this.bluetoothDeviceUpdatedListener_);
|
| @@ -170,6 +170,7 @@ Polymer({
|
| this.bluetoothDeviceUpdatedListener_);
|
|
|
| this.bluetoothDeviceRemovedListener_ =
|
| + this.bluetoothDeviceRemovedListener_ ||
|
| this.onBluetoothDeviceRemoved_.bind(this);
|
| this.bluetooth.onDeviceRemoved.addListener(
|
| this.bluetoothDeviceRemovedListener_);
|
| @@ -177,16 +178,12 @@ Polymer({
|
|
|
| /** @override */
|
| detached: function() {
|
| - if (this.bluetoothAdapterStateChangedListener_) {
|
| - this.bluetooth.onAdapterStateChanged.removeListener(
|
| - this.bluetoothAdapterStateChangedListener_);
|
| - }
|
| - if (this.bluetoothDeviceUpdatedListener_) {
|
| - this.bluetooth.onDeviceAdded.removeListener(
|
| - this.bluetoothDeviceUpdatedListener_);
|
| - this.bluetooth.onDeviceChanged.removeListener(
|
| - this.bluetoothDeviceUpdatedListener_);
|
| - }
|
| + this.bluetooth.onDeviceAdded.removeListener(
|
| + assert(this.bluetoothDeviceUpdatedListener_));
|
| + this.bluetooth.onDeviceChanged.removeListener(
|
| + assert(this.bluetoothDeviceUpdatedListener_));
|
| + this.bluetooth.onDeviceRemoved.removeListener(
|
| + assert(this.bluetoothDeviceRemovedListener_));
|
| },
|
|
|
| /**
|
| @@ -195,12 +192,7 @@ Polymer({
|
| * @protected
|
| */
|
| currentRouteChanged: function(route) {
|
| - if (route == settings.Route.BLUETOOTH_DEVICES) {
|
| - if (this.bluetoothEnabled)
|
| - this.startDiscovery_();
|
| - } else {
|
| - this.stopDiscovery_();
|
| - }
|
| + this.updateDiscovery_();
|
| },
|
|
|
| /** @private */
|
| @@ -210,20 +202,11 @@ Polymer({
|
|
|
| /** @private */
|
| adapterStateChanged_: function() {
|
| + this.updateDiscovery_();
|
| this.updateDeviceList_();
|
| },
|
|
|
| /** @private */
|
| - bluetoothEnabledChanged_: function() {
|
| - if (settings.getCurrentRoute() == settings.Route.BLUETOOTH_DEVICES &&
|
| - this.bluetoothEnabled) {
|
| - this.startDiscovery_();
|
| - } else {
|
| - this.stopDiscovery_();
|
| - }
|
| - },
|
| -
|
| - /** @private */
|
| deviceListChanged_: function() {
|
| this.saveScroll(this.$.pairedDevices);
|
| this.saveScroll(this.$.unpairedDevices);
|
| @@ -250,6 +233,16 @@ Polymer({
|
| this.connectDevice_(this.selectedUnpairedItem_);
|
| },
|
|
|
| + /** @private */
|
| + updateDiscovery_: function() {
|
| + if (!this.adapterState || !this.adapterState.powered)
|
| + return;
|
| + if (settings.getCurrentRoute() == settings.Route.BLUETOOTH_DEVICES)
|
| + this.startDiscovery_();
|
| + else
|
| + this.stopDiscovery_();
|
| + },
|
| +
|
| /**
|
| * If bluetooth is enabled, request the complete list of devices and update
|
| * this.deviceList_.
|
|
|