/**
* Encapsulated handling of the Bluetooth device pairing page.
* @constructor
+ * @extends {cr.ui.pageManager.Page}
*/
function BluetoothPairing() {
Page.call(this, 'bluetoothPairing',
/**
* Description of the bluetooth device.
- * @type {{name: string,
- * address: string,
- * paired: boolean,
- * connected: boolean,
- * connecting: boolean,
- * connectable: boolean,
- * pairing: string|undefined,
- * passkey: number|undefined,
- * pincode: string|undefined,
- * entered: number|undefined}}
+ * @type {?BluetoothDevice}
* @private
*/
device_: null,
* @return {boolean} True if the overlay can be displayed.
*/
canShowPage: function() {
- return this.device_ && this.device_.address && this.device_.pairing;
+ return !!(this.device_ && this.device_.address && this.device_.pairing);
},
/**
* @param {Object} device Description of the bluetooth device.
*/
update: function(device) {
- this.device_ = {};
- for (key in device)
+ this.device_ = /** @type {BluetoothDevice} */({});
+ for (var key in device)
this.device_[key] = device[key];
// Update the pairing instructions.
- var instructionsEl = $('bluetooth-pairing-instructions');
+ var instructionsEl = assert($('bluetooth-pairing-instructions'));
this.clearElement_(instructionsEl);
this.dismissible_ = ('dismissible' in device) ?
device.dismissible : true;
/**
* Handles the ENTER key for the passkey or pincode entry field.
- * @return {Event} a keydown event.
+ * @param {Event} event A keydown event.
* @private
*/
keyDownEventHandler_: function(event) {
* @param {string} key Passkey or PIN to display.
*/
updatePasskey_: function(key) {
- var passkeyEl = $('bluetooth-pairing-passkey-display');
+ var passkeyEl = assert($('bluetooth-pairing-passkey-display'));
var keyClass = (this.device_.pairing == PAIRING.REMOTE_PASSKEY ||
this.device_.pairing == PAIRING.REMOTE_PIN_CODE) ?
'bluetooth-keyboard-button' : 'bluetooth-passkey-char';
/**
* Displays a message from the Bluetooth adapter.
- * @param {Object} data Data for constructing the message.
- * @param {string} data.message Name of message to show.
- * @param {string} data.address Device address.
+ * @param {{message: string, address: string}} data Data for constructing the
+ * message. |data.message| is the name of message to show. |data.address|
+ * is the device address.
*/
BluetoothPairing.showMessage = function(data) {
var name = data.address;