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

Side by Side Diff: chrome/browser/resources/options/chromeos/system_options.js

Issue 9814030: get rid of old options pages (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: more fixes Created 8 years, 9 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 cr.define('options', function() {
6
7 var OptionsPage = options.OptionsPage;
8 var RepeatingButton = cr.ui.RepeatingButton;
9
10 /////////////////////////////////////////////////////////////////////////////
11 // SystemOptions class:
12
13 /**
14 * Encapsulated handling of ChromeOS system options page.
15 * @constructor
16 */
17 function SystemOptions() {
18 OptionsPage.call(this, 'system', templateData.systemPageTabTitle,
19 'systemPage');
20 }
21
22 cr.addSingletonGetter(SystemOptions);
23
24 // Inherit SystemOptions from OptionsPage.
25 SystemOptions.prototype = {
26 __proto__: options.OptionsPage.prototype,
27
28 /**
29 * Flag indicating if currently scanning for Bluetooth devices.
30 * @type {boolean}
31 */
32 isScanning_: false,
33
34 /**
35 * Initializes SystemOptions page.
36 * Calls base class implementation to starts preference initialization.
37 */
38 initializePage: function() {
39 OptionsPage.prototype.initializePage.call(this);
40
41 // Disable time-related settings if we're not logged in as a real user.
42 if (AccountsOptions.loggedInAsGuest()) {
43 var timezone = $('timezone-select');
44 if (timezone)
45 timezone.disabled = true;
46 var use_24hour_clock = $('use-24hour-clock');
47 if (use_24hour_clock)
48 use_24hour_clock.disabled = true;
49 }
50
51 options.system.bluetooth.BluetoothDeviceList.decorate(
52 $('bluetooth-paired-devices-list'));
53
54 $('bluetooth-add-device').onclick = function(event) {
55 if (! this.isScanning_)
56 findBluetoothDevices_(true);
57 OptionsPage.navigateToPage('bluetooth');
58 };
59
60 $('enable-bluetooth').onchange = function(event) {
61 var state = $('enable-bluetooth').checked;
62 chrome.send('bluetoothEnableChange', [Boolean(state)]);
63 };
64
65 $('bluetooth-reconnect-device').onclick = function(event) {
66 var device = $('bluetooth-paired-devices-list').selectedItem;
67 var address = device.address;
68 chrome.send('updateBluetoothDevice', [address, 'connect']);
69 OptionsPage.closeOverlay();
70 };
71
72 $('bluetooth-reconnect-device').onmousedown = function(event) {
73 // Prevent 'blur' event, which would reset the list selection,
74 // thereby disabling the apply button.
75 event.preventDefault();
76 };
77
78 $('bluetooth-paired-devices-list').addEventListener('change', function() {
79 var item = $('bluetooth-paired-devices-list').selectedItem;
80 var disabled = !item || !item.paired || item.connected;
81 $('bluetooth-reconnect-device').disabled = disabled;
82 });
83
84 $('language-button').onclick = function(event) {
85 OptionsPage.navigateToPage('language');
86 };
87 $('modifier-keys-button').onclick = function(event) {
88 OptionsPage.navigateToPage('languageCustomizeModifierKeysOverlay');
89 };
90 $('accessibility-spoken-feedback-check').onchange = function(event) {
91 chrome.send('spokenFeedbackChange',
92 [$('accessibility-spoken-feedback-check').checked]);
93 };
94 initializeBrightnessButton_('brightness-decrease-button',
95 'decreaseScreenBrightness');
96 initializeBrightnessButton_('brightness-increase-button',
97 'increaseScreenBrightness');
98 }
99 };
100
101 /**
102 * Initializes a button for controlling screen brightness.
103 * @param {string} id Button ID.
104 * @param {string} callback Name of the callback function.
105 */
106 function initializeBrightnessButton_(id, callback) {
107 var button = $(id);
108 cr.ui.decorate(button, RepeatingButton);
109 button.repeatInterval = 300;
110 button.addEventListener(RepeatingButton.Event.BUTTON_HELD, function(e) {
111 chrome.send(callback);
112 });
113 }
114
115 /**
116 * Scan for bluetooth devices.
117 * @param {boolean} reset Indicates if the list of unpaired devices should be
118 * cleared.
119 * @private
120 */
121 function findBluetoothDevices_(reset) {
122 this.isScanning_ = true;
123 if (reset)
124 $('bluetooth-unpaired-devices-list').clear();
125 chrome.send('findBluetoothDevices');
126 }
127
128 //
129 // Chrome callbacks
130 //
131
132 /**
133 * Set the initial state of the spoken feedback checkbox.
134 */
135 SystemOptions.setSpokenFeedbackCheckboxState = function(checked) {
136 $('accessibility-spoken-feedback-check').checked = checked;
137 };
138
139 /**
140 * Set the initial state of the high contrast checkbox.
141 */
142 SystemOptions.setHighContrastCheckboxState = function(checked) {
143 // TODO(zork): Update UI
144 };
145
146 /**
147 * Set the initial state of the screen magnifier checkbox.
148 */
149 SystemOptions.setScreenMagnifierCheckboxState = function(checked) {
150 // TODO(zork): Update UI
151 };
152
153 /**
154 * Set the initial state of the virtual keyboard checkbox.
155 */
156 SystemOptions.setVirtualKeyboardCheckboxState = function(checked) {
157 // TODO(zork): Update UI
158 };
159
160 /**
161 * Activate the bluetooth settings section on the System settings page.
162 */
163 SystemOptions.showBluetoothSettings = function() {
164 $('bluetooth-devices').hidden = false;
165 };
166
167 /**
168 * Sets the state of the checkbox indicating if bluetooth is turned on. The
169 * state of the "Find devices" button and the list of discovered devices may
170 * also be affected by a change to the state.
171 * @param {boolean} checked Flag Indicating if Bluetooth is turned on.
172 */
173 SystemOptions.setBluetoothState = function(checked) {
174 $('enable-bluetooth').checked = checked;
175 $('bluetooth-paired-devices-list').parentNode.hidden = !checked;
176 $('bluetooth-add-device').hidden = !checked;
177 $('bluetooth-reconnect-device').hidden = !checked;
178 // Flush list of previously discovered devices if bluetooth is turned off.
179 if (!checked) {
180 $('bluetooth-paired-devices-list').clear();
181 $('bluetooth-unpaired-devices-list').clear();
182 }
183 // TODO(kevers): Replace following with a call to fetch the list of
184 // previously discovered devices rather than searching for all available
185 // devices.
186 if (checked && ! this.isScanning_)
187 findBluetoothDevices_(true);
188 }
189
190 /**
191 * Adds an element to the list of available bluetooth devices. If an element
192 * with a matching address is found, the existing element is updated.
193 * @param {{name: string,
194 * address: string,
195 * icon: string,
196 * paired: boolean,
197 * connected: boolean}} device
198 * Decription of the bluetooth device.
199 */
200 SystemOptions.addBluetoothDevice = function(device) {
201 var list = $('bluetooth-unpaired-devices-list');
202 if (device.paired) {
203 // Test to see if the device is currently in the unpaired list, in which
204 // case it should be removed from that list.
205 var index = $('bluetooth-unpaired-devices-list').find(device.address);
206 if (index != undefined)
207 $('bluetooth-unpaired-devices-list').deleteItemAtIndex(index);
208 list = $('bluetooth-paired-devices-list');
209 }
210 list.appendDevice(device);
211
212 // One device can be in the process of pairing. If found, display
213 // the Bluetooth pairing overlay.
214 if (device.pairing)
215 BluetoothPairing.showDialog(device);
216 };
217
218 /**
219 * Notification that a single pass of device discovery has completed.
220 */
221 SystemOptions.notifyBluetoothSearchComplete = function() {
222 // TODO(kevers): Determine the fate of this method once continuous
223 // scanning is implemented in the Bluetooth code.
224 this.isScanning_ = false;
225 };
226
227 /**
228 * Displays the touchpad controls section when we detect a touchpad, hides it
229 * otherwise.
230 */
231 SystemOptions.showTouchpadControls = function(show) {
232 $('touchpad-controls').hidden = !show;
233 };
234
235 /**
236 * Displays the mouse controls section when we detect a mouse, hides it
237 * otherwise.
238 */
239 SystemOptions.showMouseControls = function(show) {
240 $('mouse-controls').hidden = !show;
241 };
242
243 // Export
244 return {
245 SystemOptions: SystemOptions
246 };
247
248 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698