Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6983)

Unified Diff: chrome/browser/resources/options/chromeos/system_options.js

Issue 8137003: Add display of available bluetooth devices, and mechanism for retrieving the list. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Remove addition of animated spinner in favour of reusing an existing throbber class. Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/resources/options/chromeos/system_options.js
diff --git a/chrome/browser/resources/options/chromeos/system_options.js b/chrome/browser/resources/options/chromeos/system_options.js
index 959e8a0945c5f03aaa5a03bb599865ac9dc7bb25..d5076c03658d0048195dd9beb015e6628d7bd2cc 100644
--- a/chrome/browser/resources/options/chromeos/system_options.js
+++ b/chrome/browser/resources/options/chromeos/system_options.js
@@ -41,9 +41,17 @@ cr.define('options', function() {
use_24hour_clock.disabled = true;
}
+ options.system.bluetooth.BluetoothListElement.decorate(
+ $('bluetooth-device-list'));
+
// TODO (kevers) - Populate list of connected bluetooth devices.
// Set state of 'Enable bluetooth' checkbox.
- // Set state of 'Find devices' button.
+
+ $('bluetooth-find-devices').disabled =
+ $('enable-bluetooth-label') ? false : true;
+ $('bluetooth-find-devices').onclick = function(event) {
+ findBluetoothDevices_();
+ };
$('language-button').onclick = function(event) {
OptionsPage.navigateToPage('language');
@@ -58,6 +66,40 @@ cr.define('options', function() {
}
};
+ /**
+ * Scan for bluetooth devices.
+ * @private
+ */
+ function findBluetoothDevices_() {
+ setVisibility_('bluetooth-scanning-label', true);
+ setVisibility_('bluetooth-scanning-icon', true);
+
+ // Remove devices that are not currently connected.
+ var devices = $('bluetooth-device-list').childNodes;
+ for (var i = devices.length - 1; i >= 0; i--) {
+ var device = devices.item(i);
+ var data = device.data;
+ if (!data || data.status !== 'connected')
+ $('bluetooth-device-list').removeChild(device);
+ }
+ // TODO (kevers) - Set arguments to a list of the currently connected
+ // devices.
+ chrome.send('findBluetoothDevices');
+ }
+
+ /**
+ * Sets the visibility of an element.
+ * @param {string} id The id of the element.
+ * @param {boolean} visible True if the element should be made visible.
+ * @private
+ */
+ function setVisibility_(id, visible) {
+ if (visible)
+ $(id).classList.remove("transparent");
+ else
+ $(id).classList.add("transparent");
+ }
+
//
// Chrome callbacks
//
@@ -72,10 +114,35 @@ cr.define('options', function() {
/**
* Activate the bluetooth settings section on the System settings page.
*/
- SystemOptions.ShowBluetoothSettings = function() {
+ SystemOptions.showBluetoothSettings = function() {
$('bluetooth-devices').hidden = false;
}
+ /**
+ * Adds an element to the list of available bluetooth devices.
+ * @param{{'deviceName': string,
+ * 'deviceId': string,
+ * 'deviceType': Constants.DEVICE_TYPE,
+ * 'deviceStatus': Constants.DEVICE_STATUS} device
+ * Decription of the bluetooth device.
+ */
+ SystemOptions.addBluetoothDevice = function(device) {
+ $('bluetooth-device-list').appendDevice(device);
+ }
+
+ /**
+ * Hides the scanning label and icon that are used to indicate that a device
+ * search is in progress.
+ */
+ SystemOptions.notifyBluetoothSearchComplete = function() {
+ // TDOO (kevers) - Reset state immediately once results are received
+ // asynchronously.
+ setTimeout(function() {
+ setVisibility_('bluetooth-scanning-label', false);
+ setVisibility_('bluetooth-scanning-icon', false);
+ }, 2000);
+ }
+
// Export
return {
SystemOptions: SystemOptions

Powered by Google App Engine
This is Rietveld 408576698