summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkevers@chromium.org <kevers@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-30 15:04:50 +0000
committerkevers@chromium.org <kevers@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-30 15:04:50 +0000
commitb50597ac4a26d3f5cc4edc2336103bd5d89f8b7c (patch)
tree86440884c88fe13a1eca83f2c3558d1a408a90eb
parent34b5a45597184ca072589e334448314ee4449208 (diff)
downloadchromium_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
-rw-r--r--chrome/browser/resources/options2/advanced_options.html20
-rw-r--r--chrome/browser/resources/options2/advanced_options.js64
-rw-r--r--chrome/browser/resources/options2/options.html2
-rw-r--r--chrome/browser/ui/webui/options2/chromeos/bluetooth_options_handler2.cc13
4 files changed, 52 insertions, 47 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">
diff --git a/chrome/browser/ui/webui/options2/chromeos/bluetooth_options_handler2.cc b/chrome/browser/ui/webui/options2/chromeos/bluetooth_options_handler2.cc
index 891401a..2b6caaa 100644
--- a/chrome/browser/ui/webui/options2/chromeos/bluetooth_options_handler2.cc
+++ b/chrome/browser/ui/webui/options2/chromeos/bluetooth_options_handler2.cc
@@ -57,7 +57,6 @@ BluetoothOptionsHandler::~BluetoothOptionsHandler() {
void BluetoothOptionsHandler::GetLocalizedValues(
DictionaryValue* localized_strings) {
DCHECK(localized_strings);
-
localized_strings->SetString("bluetooth",
l10n_util::GetStringUTF16(IDS_OPTIONS_SETTINGS_SECTION_TITLE_BLUETOOTH));
localized_strings->SetString("disableBluetooth",
@@ -137,13 +136,13 @@ void BluetoothOptionsHandler::Initialize() {
}
web_ui()->CallJavascriptFunction(
- "options.SystemOptions.showBluetoothSettings");
+ "options.AdvancedOptions.showBluetoothSettings");
// TODO(kevers): Determine whether bluetooth adapter is powered.
bool bluetooth_on = false;
base::FundamentalValue checked(bluetooth_on);
web_ui()->CallJavascriptFunction(
- "options.SystemOptions.setBluetoothState", checked);
+ "options.AdvancedOptions.setBluetoothState", checked);
chromeos::BluetoothManager* bluetooth_manager =
chromeos::BluetoothManager::GetInstance();
@@ -174,7 +173,7 @@ void BluetoothOptionsHandler::EnableChangeCallback(
// TODO(kevers): Call Bluetooth API to enable or disable.
base::FundamentalValue checked(bluetooth_enabled);
web_ui()->CallJavascriptFunction(
- "options.SystemOptions.setBluetoothState", checked);
+ "options.AdvancedOptions.setBluetoothState", checked);
}
void BluetoothOptionsHandler::FindDevicesCallback(
@@ -245,7 +244,7 @@ void BluetoothOptionsHandler::SendDeviceNotification(
js_properties.MergeDictionary(params);
}
web_ui()->CallJavascriptFunction(
- "options.SystemOptions.addBluetoothDevice",
+ "options.AdvancedOptions.addBluetoothDevice",
js_properties);
}
@@ -328,8 +327,6 @@ void BluetoothOptionsHandler::DiscoveryStarted(const std::string& adapter_id) {
void BluetoothOptionsHandler::DiscoveryEnded(const std::string& adapter_id) {
VLOG(2) << "Discovery ended on " << adapter_id;
- web_ui()->CallJavascriptFunction(
- "options.SystemOptions.notifyBluetoothSearchComplete");
// Stop the discovery session.
// TODO(vlaviano): We may want to expose DeviceDisappeared, remove the
@@ -392,8 +389,6 @@ void BluetoothOptionsHandler::GenerateFakeDeviceList() {
false,
false,
"");
- web_ui()->CallJavascriptFunction(
- "options.SystemOptions.notifyBluetoothSearchComplete");
}
void BluetoothOptionsHandler::GenerateFakeDevice(