Chromium Code Reviews| Index: chrome/browser/resources/settings/bluetooth_page/bluetooth_device_dialog.js |
| diff --git a/chrome/browser/resources/settings/bluetooth_page/bluetooth_pair_device_dialog.js b/chrome/browser/resources/settings/bluetooth_page/bluetooth_device_dialog.js |
| similarity index 77% |
| rename from chrome/browser/resources/settings/bluetooth_page/bluetooth_pair_device_dialog.js |
| rename to chrome/browser/resources/settings/bluetooth_page/bluetooth_device_dialog.js |
| index e31d5a42835309871069941f5906038e87ac1f74..359396eb86313b531744ed2b2ab18e8777e14e03 100644 |
| --- a/chrome/browser/resources/settings/bluetooth_page/bluetooth_pair_device_dialog.js |
| +++ b/chrome/browser/resources/settings/bluetooth_page/bluetooth_device_dialog.js |
| @@ -1,23 +1,40 @@ |
| -// Copyright 2015 The Chromium Authors. All rights reserved. |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| -/** |
| - * @fileoverview |
| - * 'settings-bluetooth-pair-device-dialog' is the settings dialog for pairing |
| - * a bluetooth device. |
| - */ |
| - |
| (function() { |
| var PairingEventType = chrome.bluetoothPrivate.PairingEventType; |
| Polymer({ |
| - is: 'settings-bluetooth-pair-device-dialog', |
| + is: 'bluetooth-device-dialog', |
| behaviors: [I18nBehavior], |
| properties: { |
| + /** Which version of this dialog to show (adding or pairing). */ |
| + dialog: String, |
|
stevenjb
2016/05/09 16:58:10
I was confused by |dialog| in the html, maybe dial
Dan Beam
2016/05/10 23:55:22
Done.
|
| + |
| +// ================================== Add ====================================== |
|
stevenjb
2016/05/09 16:58:10
The necessity of these comments for readability su
Dan Beam
2016/05/10 23:55:22
Done.
|
| + /** |
| + * The cached bluetooth adapter state. |
| + * @type {!chrome.bluetooth.AdapterState|undefined} |
| + */ |
| + adapterState: { |
| + type: Object, |
| + observer: 'adapterStateChanged_', |
| + }, |
| + |
| + /** |
| + * The ordered list of bluetooth devices. |
| + * @type {!Array<!chrome.bluetooth.Device>} |
| + */ |
| + deviceList: { |
| + type: Array, |
| + value: function() { return []; }, |
| + }, |
| + |
| +// ================================= Pair ====================================== |
| /** |
| * Current Pairing device. |
| * @type {?chrome.bluetooth.Device|undefined} |
| @@ -44,8 +61,63 @@ Polymer({ |
| observers: [ |
| 'pairingChanged_(pairingDevice, pairingEvent)', |
| ], |
| +// ============================================================================= |
| /** |
| + * @return {boolean} |
| + * @private |
| + */ |
| + isDialog_: function(currentDialog, wantedDialog) { |
|
stevenjb
2016/05/09 16:58:10
Types for num-member args?
Dan Beam
2016/05/10 23:55:22
Done.
|
| + return currentDialog == wantedDialog; |
| + }, |
| + |
| + open: function() { |
| + this.$.dialog.open(); |
| + }, |
| + |
| + close: function() { |
| + this.$.dialog.close(); |
| + }, |
| + |
| +// ================================== Add ====================================== |
| + /** @private */ |
| + adapterStateChanged_: function() { |
| + if (!this.adapterState.powered) |
| + this.fire('close-dialog'); |
| + }, |
| + |
| + /** |
| + * @param {!chrome.bluetooth.Device} device |
| + * @return {boolean} |
| + * @private |
| + */ |
| + deviceNotPaired_: function(device) { |
| + return !device.paired; |
| + }, |
| + |
| + /** |
| + * @param {!Array<!chrome.bluetooth.Device>} deviceList |
| + * @return {boolean} True if deviceList contains any unpaired devices. |
| + * @private |
| + */ |
| + haveDevices_: function(deviceList) { |
| + return this.deviceList.findIndex(function(d) { return !d.paired; }) != -1; |
| + }, |
| + |
| + /** |
| + * @param {!{detail: {action: string, device: !chrome.bluetooth.Device}}} e |
| + * @private |
| + */ |
| + onDeviceEvent_: function(e) { |
| + this.fire('device-event', e.detail); |
| + /** @type {Event} */(e).stopPropagation(); |
| + }, |
| + |
| + /** @private */ |
| + onAddCancelTap_: function() { this.fire('close-dialog'); }, |
| + |
| +// ================================= Pair ====================================== |
| + /** |
| * @param {?chrome.bluetooth.Device} pairingDevice |
| * @param {?chrome.bluetoothPrivate.PairingEvent} pairingEvent |
| * @private |
| @@ -167,7 +239,7 @@ Polymer({ |
| }, |
| /** @private */ |
| - onCancelTap_: function() { |
| + onPairCancelTap_: function() { |
| this.sendResponse_(chrome.bluetoothPrivate.PairingResponse.CANCEL); |
| // Close the dialog immediately. |
| this.fire('close-dialog', ''); |
| @@ -265,4 +337,5 @@ Polymer({ |
| return cssClass; |
| }, |
| }); |
| + |
| })(); |