summaryrefslogtreecommitdiffstats
path: root/chrome/browser/resources
diff options
context:
space:
mode:
authorkevers@chromium.org <kevers@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-20 17:43:54 +0000
committerkevers@chromium.org <kevers@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-20 17:43:54 +0000
commit74c17287690f59a03f833fc634c75d59fc437762 (patch)
treee649eb1f41f78647d2ca4e56984258372c69d802 /chrome/browser/resources
parentd3086252752eb3782db8b8953833ba4fdbb14cfa (diff)
downloadchromium_src-74c17287690f59a03f833fc634c75d59fc437762.zip
chromium_src-74c17287690f59a03f833fc634c75d59fc437762.tar.gz
chromium_src-74c17287690f59a03f833fc634c75d59fc437762.tar.bz2
Add buttons for connect and disconnect or bluetooth devices. Test for duplicate devices.
BUG=Partial fix for chromium:100392. TEST=Launch ChromeOS with the flag enable-bluetooth. Navigate to the System settings page. Click on "Find devices". Each device has a "Connect" button visible on mouse over. Review URL: http://codereview.chromium.org/8342045 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@106518 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/resources')
-rw-r--r--chrome/browser/resources/options/chromeos/bluetooth_list_element.js58
-rw-r--r--chrome/browser/resources/options/chromeos/system_options_page.css6
2 files changed, 52 insertions, 12 deletions
diff --git a/chrome/browser/resources/options/chromeos/bluetooth_list_element.js b/chrome/browser/resources/options/chromeos/bluetooth_list_element.js
index d3aad94..5323645 100644
--- a/chrome/browser/resources/options/chromeos/bluetooth_list_element.js
+++ b/chrome/browser/resources/options/chromeos/bluetooth_list_element.js
@@ -16,7 +16,7 @@ cr.define('options.system.bluetooth', function() {
Constants.DEVICE_TYPE = {
HEADSET: 'headset',
KEYBOARD: 'keyboard',
- MOUSE: 'mouse',
+ MOUSE: 'mouse'
};
/**
@@ -43,7 +43,6 @@ cr.define('options.system.bluetooth', function() {
/** @inheritDoc */
decorate: function() {
- // TODO (kevers) - Implement me.
},
/**
@@ -61,16 +60,26 @@ cr.define('options.system.bluetooth', function() {
},
/**
- * Adds a bluetooth device to the list of available devices.
+ * Adds a bluetooth device to the list of available devices. A check is
+ * made to see if the device is already in the list, in which case the
+ * existing device is updated.
* @param {Object.<string,string>} device Description of the bluetooth
* device.
*/
appendDevice: function(device) {
- // TODO (kevers) - check device ID to determine if already in list, in
- // which case we should be updating the existing element.
- // Display connected devices at the top of the list.
- if (this.isSupported_(device))
- this.appendChild(new BluetoothItem(device));
+ if (!this.isSupported_(device))
+ return;
+
+ var item = new BluetoothItem(device);
+ var candidate = this.firstChild;
+ while (candidate) {
+ if (candidate.data.deviceId == device.deviceId) {
+ this.replaceChild(item, candidate);
+ return;
+ }
+ candidate = candidate.nextSibling;
+ }
+ this.appendChild(item);
},
/**
@@ -137,17 +146,44 @@ cr.define('options.system.bluetooth', function() {
nameEl.className = 'network-name-label';
nameEl.textContent = this.data.deviceName;
textDiv.appendChild(nameEl);
+ var buttonsDiv = null;
- if (this.data.deviceStatus) {
- var statusMessage = templateData[this.data.deviceStatus];
+ var status = this.data.deviceStatus;
+ if (status) {
+ var statusMessage = templateData[status];
if (statusMessage) {
var statusEl = this.ownerDocument.createElement('div');
statusEl.className = 'network-status-label';
statusEl.textContent = statusMessage;
textDiv.appendChild(statusEl);
}
+ buttonsDiv = this.ownerDocument.createElement('div');
+ buttonsDiv.className = 'bluetooth-button-group';
+ var buttonLabelKey = null;
+ var callbackType = null;
+ if (status == Constants.DEVICE_STATUS.CONNECTED) {
+ this.connected = true;
+ buttonLabelKey = 'bluetoothDisconnectDevice';
+ callbackType = 'disconnect';
+ } else if (status == Constants.DEVICE_STATUS.NOT_PAIRED) {
+ buttonLabelKey = 'bluetoothConnectDevice';
+ callbackType = 'connect';
+ }
+ if (buttonLabelKey && callbackType) {
+ var buttonEl = this.ownerDocument.createElement('button');
+ buttonEl.textContent = localStrings.getString(buttonLabelKey);
+ var self = this;
+ var callback = function(e) {
+ chrome.send('updateBluetoothDevice',
+ [self.data.deviceId, callbackType]);
+ }
+ buttonEl.addEventListener('click', callback);
+ buttonsDiv.appendChild(buttonEl);
+ }
}
this.appendChild(textDiv);
+ if (buttonsDiv)
+ this.appendChild(buttonsDiv);
}
};
@@ -156,5 +192,3 @@ cr.define('options.system.bluetooth', function() {
BluetoothListElement: BluetoothListElement
};
});
-
-
diff --git a/chrome/browser/resources/options/chromeos/system_options_page.css b/chrome/browser/resources/options/chromeos/system_options_page.css
index a832129..f840ca3 100644
--- a/chrome/browser/resources/options/chromeos/system_options_page.css
+++ b/chrome/browser/resources/options/chromeos/system_options_page.css
@@ -48,6 +48,12 @@ html[dir=rtl] .touchpad-sensitivity-more {
vertical-align: middle;
}
+.bluetooth-button-group {
+ -webkit-box-flex: 1;
+ -webkit-box-pack: end;
+ display: -webkit-box;
+}
+
.bluetooth-headset,
.bluetooth-keyboard,
.bluetooth-mouse {