| 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
|
|
|