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

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

Issue 8895023: Options2: Pull the trigger. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: DIAF. Created 9 years 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/options2/chromeos/system_options.js
diff --git a/chrome/browser/resources/options2/chromeos/system_options.js b/chrome/browser/resources/options2/chromeos/system_options.js
new file mode 100644
index 0000000000000000000000000000000000000000..0a9faeb5c4a55476f49ffd5c93b5c5f7754d764f
--- /dev/null
+++ b/chrome/browser/resources/options2/chromeos/system_options.js
@@ -0,0 +1,202 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+cr.define('options', function() {
+
+ var OptionsPage = options.OptionsPage;
+ var RepeatingButton = cr.ui.RepeatingButton;
+
+ /////////////////////////////////////////////////////////////////////////////
+ // SystemOptions class:
+
+ /**
+ * Encapsulated handling of ChromeOS system options page.
+ * @constructor
+ */
+
+ function SystemOptions() {
+ OptionsPage.call(this, 'system', templateData.systemPageTabTitle,
+ 'systemPage');
+ }
+
+ cr.addSingletonGetter(SystemOptions);
+
+ // Inherit SystemOptions from OptionsPage.
+ SystemOptions.prototype = {
+ __proto__: options.OptionsPage.prototype,
+
+ /**
+ * Initializes SystemOptions page.
+ * Calls base class implementation to starts preference initialization.
+ */
+ initializePage: function() {
+ OptionsPage.prototype.initializePage.call(this);
+
+ // Disable time-related settings if we're not logged in as a real user.
+ if (AccountsOptions.loggedInAsGuest()) {
+ var timezone = $('timezone-select');
+ if (timezone)
+ timezone.disabled = true;
+ var use_24hour_clock = $('use-24hour-clock');
+ if (use_24hour_clock)
+ 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.
+ $('bluetooth-find-devices').onclick = function(event) {
+ findBluetoothDevices_();
+ };
+ $('enable-bluetooth').onclick = function(event) {
+ chrome.send('bluetoothEnableChange', [Boolean(true)]);
+ };
+ $('disable-bluetooth').onclick = function(event) {
+ chrome.send('bluetoothEnableChange', [Boolean(false)]);
+ };
+ $('language-button').onclick = function(event) {
+ OptionsPage.navigateToPage('language');
+ };
+ $('modifier-keys-button').onclick = function(event) {
+ OptionsPage.navigateToPage('languageCustomizeModifierKeysOverlay');
+ };
+ $('accesibility-check').onchange = function(event) {
+ chrome.send('accessibilityChange',
+ [String($('accesibility-check').checked)]);
+ };
+ initializeBrightnessButton_('brightness-decrease-button',
+ 'decreaseScreenBrightness');
+ initializeBrightnessButton_('brightness-increase-button',
+ 'increaseScreenBrightness');
+ }
+ };
+
+ /**
+ * Initializes a button for controlling screen brightness.
+ * @param {string} id Button ID.
+ * @param {string} callback Name of the callback function.
+ */
+ function initializeBrightnessButton_(id, callback) {
+ var button = $(id);
+ cr.ui.decorate(button, RepeatingButton);
+ button.repeatInterval = 300;
+ button.addEventListener(RepeatingButton.Event.BUTTON_HELD, function(e) {
+ chrome.send(callback);
+ });
+ }
+
+ /**
+ * 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);
+ }
+ 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
+ //
+
+ /**
+ * Set the initial state of the accessibility checkbox.
+ */
+ SystemOptions.SetAccessibilityCheckboxState = function(checked) {
+ $('accesibility-check').checked = checked;
+ };
+
+ /**
+ * Activate the bluetooth settings section on the System settings page.
+ */
+ SystemOptions.showBluetoothSettings = function() {
+ $('bluetooth-devices').hidden = false;
+ };
+
+ /**
+ * Sets the state of the checkbox indicating if bluetooth is turned on. The
+ * state of the "Find devices" button and the list of discovered devices may
+ * also be affected by a change to the state.
+ * @param {boolean} checked Flag Indicating if Bluetooth is turned on.
+ */
+ SystemOptions.setBluetoothState = function(checked) {
+ $('disable-bluetooth').hidden = !checked;
+ $('enable-bluetooth').hidden = checked;
+ $('bluetooth-finder-container').hidden = !checked;
+ $('no-bluetooth-devices-label').hidden = !checked;
+ if (!checked) {
+ setVisibility_('bluetooth-scanning-label', false);
+ setVisibility_('bluetooth-scanning-icon', false);
+ }
+ // Flush list of previously discovered devices if bluetooth is turned off.
+ if (!checked) {
+ var devices = $('bluetooth-device-list').childNodes;
+ for (var i = devices.length - 1; i >= 0; i--) {
+ var device = devices.item(i);
+ $('bluetooth-device-list').removeChild(device);
+ }
+ }
+ }
+
+ /**
+ * Adds an element to the list of available bluetooth devices. If an element
+ * with a matching address is found, the existing element is updated.
+ * @param {{name: string,
+ * address: string,
+ * icon: string,
+ * paired: boolean,
+ * connected: boolean}} device
+ * Decription of the bluetooth device.
+ */
+ SystemOptions.addBluetoothDevice = function(device) {
+ if ($('bluetooth-device-list').appendDevice(device))
+ $('no-bluetooth-devices-label').hidden = true;
+ };
+
+ /**
+ * Hides the scanning label and icon that are used to indicate that a device
+ * search is in progress.
+ */
+ SystemOptions.notifyBluetoothSearchComplete = function() {
+ setVisibility_('bluetooth-scanning-label', false);
+ setVisibility_('bluetooth-scanning-icon', false);
+ };
+
+ /**
+ * Displays the Touchpad Controls section when we detect a touchpad.
+ */
+ SystemOptions.showTouchpadControls = function() {
+ $('touchpad-controls').hidden = false;
+ };
+
+ // Export
+ return {
+ SystemOptions: SystemOptions
+ };
+
+});

Powered by Google App Engine
This is Rietveld 408576698