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', function() { | 5 cr.define('options', function() { |
6 /** @const */ var Page = cr.ui.pageManager.Page; | 6 /** @const */ var Page = cr.ui.pageManager.Page; |
7 /** @const */ var PageManager = cr.ui.pageManager.PageManager; | 7 /** @const */ var PageManager = cr.ui.pageManager.PageManager; |
8 | 8 |
9 /** | 9 /** |
10 * Enumeration of possible states during pairing. The value associated with | 10 * Enumeration of possible states during pairing. The value associated with |
(...skipping 24 matching lines...) Expand all Loading... |
35 'bluetooth-pairing-pincode-entry', | 35 'bluetooth-pairing-pincode-entry', |
36 'bluetooth-pair-device-connect-button', | 36 'bluetooth-pair-device-connect-button', |
37 'bluetooth-pair-device-cancel-button', | 37 'bluetooth-pair-device-cancel-button', |
38 'bluetooth-pair-device-accept-button', | 38 'bluetooth-pair-device-accept-button', |
39 'bluetooth-pair-device-reject-button', | 39 'bluetooth-pair-device-reject-button', |
40 'bluetooth-pair-device-dismiss-button']; | 40 'bluetooth-pair-device-dismiss-button']; |
41 | 41 |
42 /** | 42 /** |
43 * Encapsulated handling of the Bluetooth device pairing page. | 43 * Encapsulated handling of the Bluetooth device pairing page. |
44 * @constructor | 44 * @constructor |
| 45 * @extends {cr.ui.pageManager.Page} |
45 */ | 46 */ |
46 function BluetoothPairing() { | 47 function BluetoothPairing() { |
47 Page.call(this, 'bluetoothPairing', | 48 Page.call(this, 'bluetoothPairing', |
48 loadTimeData.getString('bluetoothOptionsPageTabTitle'), | 49 loadTimeData.getString('bluetoothOptionsPageTabTitle'), |
49 'bluetooth-pairing'); | 50 'bluetooth-pairing'); |
50 } | 51 } |
51 | 52 |
52 cr.addSingletonGetter(BluetoothPairing); | 53 cr.addSingletonGetter(BluetoothPairing); |
53 | 54 |
54 BluetoothPairing.prototype = { | 55 BluetoothPairing.prototype = { |
55 __proto__: Page.prototype, | 56 __proto__: Page.prototype, |
56 | 57 |
57 /** | 58 /** |
58 * Description of the bluetooth device. | 59 * Description of the bluetooth device. |
59 * @type {{name: string, | 60 * @type {{name: string, |
60 * address: string, | 61 * address: string, |
61 * paired: boolean, | 62 * paired: boolean, |
62 * connected: boolean, | 63 * connected: boolean, |
63 * connecting: boolean, | 64 * connecting: boolean, |
64 * connectable: boolean, | 65 * connectable: boolean, |
65 * pairing: string|undefined, | 66 * pairing: (string|undefined), |
66 * passkey: number|undefined, | 67 * passkey: (number|undefined), |
67 * pincode: string|undefined, | 68 * pincode: (string|undefined), |
68 * entered: number|undefined}} | 69 * entered: (number|undefined)}} |
69 * @private | 70 * @private |
70 */ | 71 */ |
71 device_: null, | 72 device_: null, |
72 | 73 |
73 /** | 74 /** |
74 * Can the dialog be programmatically dismissed. | 75 * Can the dialog be programmatically dismissed. |
75 * @type {boolean} | 76 * @type {boolean} |
76 */ | 77 */ |
77 dismissible_: true, | 78 dismissible_: true, |
78 | 79 |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 else if (!$('bluetooth-passkey').hidden) | 164 else if (!$('bluetooth-passkey').hidden) |
164 $('bluetooth-passkey').focus(); | 165 $('bluetooth-passkey').focus(); |
165 }, | 166 }, |
166 | 167 |
167 /** | 168 /** |
168 * Configures the overlay for pairing a device. | 169 * Configures the overlay for pairing a device. |
169 * @param {Object} device Description of the bluetooth device. | 170 * @param {Object} device Description of the bluetooth device. |
170 */ | 171 */ |
171 update: function(device) { | 172 update: function(device) { |
172 this.device_ = {}; | 173 this.device_ = {}; |
173 for (key in device) | 174 for (var key in device) |
174 this.device_[key] = device[key]; | 175 this.device_[key] = device[key]; |
175 // Update the pairing instructions. | 176 // Update the pairing instructions. |
176 var instructionsEl = $('bluetooth-pairing-instructions'); | 177 var instructionsEl = $('bluetooth-pairing-instructions'); |
177 this.clearElement_(instructionsEl); | 178 this.clearElement_(instructionsEl); |
178 this.dismissible_ = ('dismissible' in device) ? | 179 this.dismissible_ = ('dismissible' in device) ? |
179 device.dismissible : true; | 180 device.dismissible : true; |
180 | 181 |
181 var message = loadTimeData.getString(device.pairing); | 182 var message = loadTimeData.getString(device.pairing); |
182 message = message.replace('%1', this.device_.name); | 183 message = message.replace('%1', this.device_.name); |
183 instructionsEl.textContent = message; | 184 instructionsEl.textContent = message; |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
323 * overlay. | 324 * overlay. |
324 * @param {Object} device Description of the Bluetooth device. | 325 * @param {Object} device Description of the Bluetooth device. |
325 */ | 326 */ |
326 BluetoothPairing.showDialog = function(device) { | 327 BluetoothPairing.showDialog = function(device) { |
327 BluetoothPairing.getInstance().update(device); | 328 BluetoothPairing.getInstance().update(device); |
328 PageManager.showPageByName('bluetoothPairing', false); | 329 PageManager.showPageByName('bluetoothPairing', false); |
329 }; | 330 }; |
330 | 331 |
331 /** | 332 /** |
332 * Displays a message from the Bluetooth adapter. | 333 * Displays a message from the Bluetooth adapter. |
333 * @param {Object} data Data for constructing the message. | 334 * @param {{message: string, address: string}} data Data for constructing the |
334 * @param {string} data.message Name of message to show. | 335 * message. |data.message| is the name of message to show. |data.address| |
335 * @param {string} data.address Device address. | 336 * is the device address. |
336 */ | 337 */ |
337 BluetoothPairing.showMessage = function(data) { | 338 BluetoothPairing.showMessage = function(data) { |
338 var name = data.address; | 339 var name = data.address; |
339 if (name.length == 0) | 340 if (name.length == 0) |
340 return; | 341 return; |
341 var dialog = BluetoothPairing.getInstance(); | 342 var dialog = BluetoothPairing.getInstance(); |
342 if (dialog.device_ && name == dialog.device_.address && | 343 if (dialog.device_ && name == dialog.device_.address && |
343 dialog.device_.pairing == PAIRING.CANCELED) { | 344 dialog.device_.pairing == PAIRING.CANCELED) { |
344 // Do not show any error message after cancelation of the pairing. | 345 // Do not show any error message after cancelation of the pairing. |
345 return; | 346 return; |
(...skipping 28 matching lines...) Expand all Loading... |
374 dialog.device_.pairing = PAIRING.DISMISSED; | 375 dialog.device_.pairing = PAIRING.DISMISSED; |
375 PageManager.closeOverlay(); | 376 PageManager.closeOverlay(); |
376 } | 377 } |
377 }; | 378 }; |
378 | 379 |
379 // Export | 380 // Export |
380 return { | 381 return { |
381 BluetoothPairing: BluetoothPairing | 382 BluetoothPairing: BluetoothPairing |
382 }; | 383 }; |
383 }); | 384 }); |
OLD | NEW |