diff options
author | kevers@chromium.org <kevers@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-30 15:04:50 +0000 |
---|---|---|
committer | kevers@chromium.org <kevers@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-30 15:04:50 +0000 |
commit | b50597ac4a26d3f5cc4edc2336103bd5d89f8b7c (patch) | |
tree | 86440884c88fe13a1eca83f2c3558d1a408a90eb /chrome/browser/resources | |
parent | 34b5a45597184ca072589e334448314ee4449208 (diff) | |
download | chromium_src-b50597ac4a26d3f5cc4edc2336103bd5d89f8b7c.zip chromium_src-b50597ac4a26d3f5cc4edc2336103bd5d89f8b7c.tar.gz chromium_src-b50597ac4a26d3f5cc4edc2336103bd5d89f8b7c.tar.bz2 |
Update bluetooth settings for uber-page.
BUG=chromium:102139
TEST=
Review URL: http://codereview.chromium.org/9298029
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@119672 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/resources')
-rw-r--r-- | chrome/browser/resources/options2/advanced_options.html | 20 | ||||
-rw-r--r-- | chrome/browser/resources/options2/advanced_options.js | 64 | ||||
-rw-r--r-- | chrome/browser/resources/options2/options.html | 2 |
3 files changed, 48 insertions, 38 deletions
diff --git a/chrome/browser/resources/options2/advanced_options.html b/chrome/browser/resources/options2/advanced_options.html index 8199b20..ef1b9a7 100644 --- a/chrome/browser/resources/options2/advanced_options.html +++ b/chrome/browser/resources/options2/advanced_options.html @@ -95,15 +95,25 @@ <section id="bluetooth-devices" hidden> <h3 i18n-content="bluetooth"></h3> <div id="bluetooth-options-div"> - <div id="bluetooth-buttons"> - <button id="enable-bluetooth" i18n-content="enableBluetooth" hidden> - <button id="disable-bluetooth" i18n-content="disableBluetooth"> + <div class="checkbox"> + <label> + <input type="checkbox" id="enable-bluetooth"> + <span i18n-content="enableBluetooth"> + </label> </div> <div class="settings-list bluetooth-device-list" hidden> <list id="bluetooth-paired-devices-list"></list> + <div id="bluetooth-paired-devices-list-empty-placeholder" + class="bluetooth-empty-list-label" hidden> + <span i18n-content="bluetoothNoDevices"></span> + </div> + </div> + <div id="bluetooth-button-group"> + <button id="bluetooth-add-device" + i18n-content="addBluetoothDevice" hidden></button> + <button id="bluetooth-reconnect-device" + i18n-content="bluetoothConnectDevice" disabled hidden></button> </div> - <button id="bluetooth-add-device" hidden - i18n-content="addBluetoothDevice"></button> </div> </section> </if> diff --git a/chrome/browser/resources/options2/advanced_options.js b/chrome/browser/resources/options2/advanced_options.js index 28dc311..915ba53 100644 --- a/chrome/browser/resources/options2/advanced_options.js +++ b/chrome/browser/resources/options2/advanced_options.js @@ -22,12 +22,6 @@ cr.define('options', function() { __proto__: options.OptionsPage.prototype, /** - * Flag indicating if currently scanning for Bluetooth devices. - * @type {boolean} - */ - isScanning_: false, - - /** * Initializes the page. */ initializePage: function() { @@ -67,16 +61,34 @@ cr.define('options', function() { $('bluetooth-paired-devices-list')); $('bluetooth-add-device').onclick = function(event) { - if (!this.isScanning_) - findBluetoothDevices_(true); + findBluetoothDevices_(true); OptionsPage.navigateToPage('bluetooth'); }; - $('enable-bluetooth').onclick = function(event) { - chrome.send('bluetoothEnableChange', [Boolean(true)]); + + $('enable-bluetooth').onchange = function(event) { + var state = $('enable-bluetooth').checked; + chrome.send('bluetoothEnableChange', [Boolean(state)]); }; - $('disable-bluetooth').onclick = function(event) { - chrome.send('bluetoothEnableChange', [Boolean(false)]); + + $('bluetooth-reconnect-device').onclick = function(event) { + var device = $('bluetooth-paired-devices-list').selectedItem; + var address = device.address; + chrome.send('updateBluetoothDevice', [address, 'connect']); + OptionsPage.closeOverlay(); }; + + $('bluetooth-reconnect-device').onmousedown = function(event) { + // Prevent 'blur' event, which would reset the list selection, + // thereby disabling the apply button. + event.preventDefault(); + }; + + $('bluetooth-paired-devices-list').addEventListener('change', + function() { + var item = $('bluetooth-paired-devices-list').selectedItem; + var disabled = !item || !item.paired || item.connected; + $('bluetooth-reconnect-device').disabled = disabled; + }); } // Passwords and Forms section. @@ -229,9 +241,7 @@ cr.define('options', function() { * @private */ function findBluetoothDevices_(reset) { - this.isScanning_ = true; - if (reset) - $('bluetooth-unpaired-devices-list').clear(); + $('bluetooth-unpaired-devices-list').clear(); chrome.send('findBluetoothDevices'); } @@ -411,18 +421,16 @@ cr.define('options', function() { * @param {boolean} checked Flag Indicating if Bluetooth is turned on. */ AdvancedOptions.setBluetoothState = function(checked) { - $('disable-bluetooth').hidden = !checked; - $('enable-bluetooth').hidden = checked; + $('enable-bluetooth').checked = checked; $('bluetooth-paired-devices-list').parentNode.hidden = !checked; $('bluetooth-add-device').hidden = !checked; + $('bluetooth-reconnect-device').hidden = !checked; // Flush list of previously discovered devices if bluetooth is turned off. if (!checked) { $('bluetooth-paired-devices-list').clear(); $('bluetooth-unpaired-devices-list').clear(); } - if (checked && ! this.isScanning_) - findBluetoothDevices_(true); - }; + } /** * Adds an element to the list of available bluetooth devices. If an element @@ -435,31 +443,23 @@ cr.define('options', function() { * Decription of the bluetooth device. */ AdvancedOptions.addBluetoothDevice = function(device) { + var list = $('bluetooth-unpaired-devices-list'); if (device.paired) { // Test to see if the device is currently in the unpaired list, in which // case it should be removed from that list. var index = $('bluetooth-unpaired-devices-list').find(device.address); if (index != undefined) $('bluetooth-unpaired-devices-list').deleteItemAtIndex(index); - $('bluetooth-paired-devices-list').appendDevice(device); - } else { - $('bluetooth-unpaired-devices-list').appendDevice(device); + list = $('bluetooth-paired-devices-list'); } + list.appendDevice(device); + // One device can be in the process of pairing. If found, display // the Bluetooth pairing overlay. if (device.pairing) BluetoothPairing.showDialog(device); }; - /** - * Notification that a single pass of device discovery has completed. - */ - AdvancedOptions.notifyBluetoothSearchComplete = function() { - // TODO(kevers): Determine the fate of this method once continuous - // scanning is implemented in the Bluetooth code. - this.isScanning_ = false; - }; - // Export return { AdvancedOptions: AdvancedOptions diff --git a/chrome/browser/resources/options2/options.html b/chrome/browser/resources/options2/options.html index c55121e..bae0f6e 100644 --- a/chrome/browser/resources/options2/options.html +++ b/chrome/browser/resources/options2/options.html @@ -43,7 +43,7 @@ <link rel="stylesheet" href="../sync_setup_overlay.css"> <if expr="pp_ifdef('chromeos')"> <link rel="stylesheet" href="chromeos/accounts_options_page.css"> - <link rel="stylesheet" herf="chromeos/bluetooth.css"> + <link rel="stylesheet" href="chromeos/bluetooth.css"> <link rel="stylesheet" href="chromeos/change_picture_options.css"> <link rel="stylesheet" href="chromeos/internet_options_page.css"> <link rel="stylesheet" href="chromeos/pointer_overlay.css"> |