| 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 OptionsPage = options.OptionsPage; | 6 /** @const */ var Page = cr.ui.pageManager.Page; |
| 7 /** @const */ var PageManager = cr.ui.pageManager.PageManager; |
| 7 | 8 |
| 8 /** | 9 /** |
| 9 * Encapsulated handling of the Bluetooth options page. | 10 * Encapsulated handling of the Bluetooth options page. |
| 10 * @constructor | 11 * @constructor |
| 11 */ | 12 */ |
| 12 function BluetoothOptions() { | 13 function BluetoothOptions() { |
| 13 OptionsPage.call(this, | 14 Page.call(this, |
| 14 'bluetooth', | 15 'bluetooth', |
| 15 loadTimeData.getString('bluetoothOptionsPageTabTitle'), | 16 loadTimeData.getString('bluetoothOptionsPageTabTitle'), |
| 16 'bluetooth-options'); | 17 'bluetooth-options'); |
| 17 } | 18 } |
| 18 | 19 |
| 19 cr.addSingletonGetter(BluetoothOptions); | 20 cr.addSingletonGetter(BluetoothOptions); |
| 20 | 21 |
| 21 BluetoothOptions.prototype = { | 22 BluetoothOptions.prototype = { |
| 22 __proto__: OptionsPage.prototype, | 23 __proto__: Page.prototype, |
| 23 | 24 |
| 24 /** | 25 /** |
| 25 * The list of available (unpaired) bluetooth devices. | 26 * The list of available (unpaired) bluetooth devices. |
| 26 * @type {DeletableItemList} | 27 * @type {DeletableItemList} |
| 27 * @private | 28 * @private |
| 28 */ | 29 */ |
| 29 deviceList_: null, | 30 deviceList_: null, |
| 30 | 31 |
| 31 /** @override */ | 32 /** @override */ |
| 32 initializePage: function() { | 33 initializePage: function() { |
| 33 OptionsPage.prototype.initializePage.call(this); | 34 Page.prototype.initializePage.call(this); |
| 34 this.createDeviceList_(); | 35 this.createDeviceList_(); |
| 35 | 36 |
| 36 BluetoothOptions.updateDiscoveryState(true); | 37 BluetoothOptions.updateDiscoveryState(true); |
| 37 | 38 |
| 38 $('bluetooth-add-device-cancel-button').onclick = function(event) { | 39 $('bluetooth-add-device-cancel-button').onclick = function(event) { |
| 39 OptionsPage.closeOverlay(); | 40 PageManager.closeOverlay(); |
| 40 }; | 41 }; |
| 41 | 42 |
| 42 var self = this; | 43 var self = this; |
| 43 $('bluetooth-add-device-apply-button').onclick = function(event) { | 44 $('bluetooth-add-device-apply-button').onclick = function(event) { |
| 44 var device = self.deviceList_.selectedItem; | 45 var device = self.deviceList_.selectedItem; |
| 45 var address = device.address; | 46 var address = device.address; |
| 46 OptionsPage.closeOverlay(); | 47 PageManager.closeOverlay(); |
| 47 device.pairing = 'bluetoothStartConnecting'; | 48 device.pairing = 'bluetoothStartConnecting'; |
| 48 options.BluetoothPairing.showDialog(device); | 49 options.BluetoothPairing.showDialog(device); |
| 49 chrome.send('updateBluetoothDevice', [address, 'connect']); | 50 chrome.send('updateBluetoothDevice', [address, 'connect']); |
| 50 }; | 51 }; |
| 51 | 52 |
| 52 $('bluetooth-unpaired-devices-list').addEventListener('change', | 53 $('bluetooth-unpaired-devices-list').addEventListener('change', |
| 53 function() { | 54 function() { |
| 54 var item = $('bluetooth-unpaired-devices-list').selectedItem; | 55 var item = $('bluetooth-unpaired-devices-list').selectedItem; |
| 55 // The "bluetooth-add-device-apply-button" should be enabled for devices | 56 // The "bluetooth-add-device-apply-button" should be enabled for devices |
| 56 // that can be paired or remembered. Devices not supporting pairing will | 57 // that can be paired or remembered. Devices not supporting pairing will |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 $('bluetooth-scanning-icon').hidden = !discovering; | 103 $('bluetooth-scanning-icon').hidden = !discovering; |
| 103 $('bluetooth-scan-stopped-label').hidden = discovering; | 104 $('bluetooth-scan-stopped-label').hidden = discovering; |
| 104 }; | 105 }; |
| 105 | 106 |
| 106 /** | 107 /** |
| 107 * If the "Add device" dialog is visible, dismiss it. | 108 * If the "Add device" dialog is visible, dismiss it. |
| 108 */ | 109 */ |
| 109 BluetoothOptions.dismissOverlay = function() { | 110 BluetoothOptions.dismissOverlay = function() { |
| 110 var page = BluetoothOptions.getInstance(); | 111 var page = BluetoothOptions.getInstance(); |
| 111 if (page && page.visible) | 112 if (page && page.visible) |
| 112 OptionsPage.closeOverlay(); | 113 PageManager.closeOverlay(); |
| 113 }; | 114 }; |
| 114 | 115 |
| 115 // Export | 116 // Export |
| 116 return { | 117 return { |
| 117 BluetoothOptions: BluetoothOptions | 118 BluetoothOptions: BluetoothOptions |
| 118 }; | 119 }; |
| 119 }); | 120 }); |
| OLD | NEW |