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

Side by Side Diff: chrome/browser/resources/sync_setup_overlay.js

Issue 494973003: Disable checkboxes in the advanced sync settings overlay whose type is force-enabled. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 3 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
« no previous file with comments | « no previous file | chrome/browser/sync/profile_sync_service.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 cr.define('options', function() { 5 cr.define('options', function() {
6 /** @const */ var Page = cr.ui.pageManager.Page; 6 /** @const */ var Page = cr.ui.pageManager.Page;
7 /** @const */ var PageManager = cr.ui.pageManager.PageManager; 7 /** @const */ var PageManager = cr.ui.pageManager.PageManager;
8 8
9 // True if the synced account uses a custom passphrase. 9 // True if the synced account uses a custom passphrase.
10 var usePassphrase_ = false; 10 var usePassphrase_ = false;
11 11
12 // True if the synced account uses 'encrypt everything'. 12 // True if the synced account uses 'encrypt everything'.
13 var useEncryptEverything_ = false; 13 var useEncryptEverything_ = false;
14 14
15 // An object used as a cache of the arguments passed in while initially 15 // An object used as a cache of the arguments passed in while initially
16 // displaying the advanced sync settings dialog. Used to switch between the 16 // displaying the advanced sync settings dialog. Used to switch between the
17 // options in the main drop-down menu. Reset when the dialog is closed. 17 // options in the main drop-down menu. Reset when the dialog is closed.
18 var syncConfigureArgs_ = null; 18 var syncConfigureArgs_ = null;
19 19
20 // A dictionary that maps the sync data type checkbox names to their checked 20 // A dictionary that maps the sync data type checkbox names to their checked
21 // state. Initialized when the advanced settings dialog is first brought up, 21 // state. Initialized when the advanced settings dialog is first brought up,
22 // updated any time a box is checked / unchecked, and reset when the dialog is 22 // updated any time a box is checked / unchecked, and reset when the dialog is
23 // closed. Used to restore checkbox state while switching between the options 23 // closed. Used to restore checkbox state while switching between the options
24 // in the main drop-down menu. All checkboxes are checked and disabled when 24 // in the main drop-down menu. All checkboxes are checked and disabled when
25 // the "Sync everything" menu-item is selected, and unchecked and disabled 25 // the "Sync everything" menu-item is selected, and unchecked and disabled
26 // when "Sync nothing" is selected. When "Choose what to sync" is selected, 26 // when "Sync nothing" is selected. When "Choose what to sync" is selected,
27 // the boxes are restored to their most recent checked state from this cache. 27 // the boxes are restored to their most recent checked state from this cache.
28 var dataTypeBoxes_ = {}; 28 var dataTypeBoxesChecked_ = {};
29
30 // A dictionary that maps the sync data type checkbox names to their disabled
31 // state (when a data type is enabled programmatically without user choice).
32 // Initialized when the advanced settings dialog is first brought up, and
33 // reset when the dialog is closed.
34 var dataTypeBoxesDisabled_ = {};
29 35
30 // Used to determine whether to bring the OK button / passphrase field into 36 // Used to determine whether to bring the OK button / passphrase field into
31 // focus. 37 // focus.
32 var confirmPageVisible_ = false; 38 var confirmPageVisible_ = false;
33 var customizePageVisible_ = false; 39 var customizePageVisible_ = false;
34 40
35 /** 41 /**
36 * The user's selection in the synced data type drop-down menu, as an index. 42 * The user's selection in the synced data type drop-down menu, as an index.
37 * @enum {number} 43 * @enum {number}
38 * @const 44 * @const
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 self.closeOverlay_(); 94 self.closeOverlay_();
89 }; 95 };
90 }, 96 },
91 97
92 showOverlay_: function() { 98 showOverlay_: function() {
93 PageManager.showPageByName('syncSetup'); 99 PageManager.showPageByName('syncSetup');
94 }, 100 },
95 101
96 closeOverlay_: function() { 102 closeOverlay_: function() {
97 this.syncConfigureArgs_ = null; 103 this.syncConfigureArgs_ = null;
98 this.dataTypeBoxes_ = {}; 104 this.dataTypeBoxesChecked_ = {};
105 this.dataTypeBoxesDisabled_ = {};
99 106
100 var overlay = $('sync-setup-overlay'); 107 var overlay = $('sync-setup-overlay');
101 if (!overlay.hidden) 108 if (!overlay.hidden)
102 PageManager.closeOverlay(); 109 PageManager.closeOverlay();
103 }, 110 },
104 111
105 /** @override */ 112 /** @override */
106 didShowPage: function() { 113 didShowPage: function() {
107 chrome.send('SyncSetupShowSetupUI'); 114 chrome.send('SyncSetupShowSetupUI');
108 }, 115 },
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 * advanced sync settings dialog. Called when "Choose what to sync" is 147 * advanced sync settings dialog. Called when "Choose what to sync" is
141 * selected. Required because all the checkboxes are checked when 148 * selected. Required because all the checkboxes are checked when
142 * "Sync everything" is selected, and unchecked when "Sync nothing" is 149 * "Sync everything" is selected, and unchecked when "Sync nothing" is
143 * selected. Note: We only restore checkboxes for data types that are 150 * selected. Note: We only restore checkboxes for data types that are
144 * actually visible and whose old values are found in the cache, since it's 151 * actually visible and whose old values are found in the cache, since it's
145 * possible for some data types to not be registered, and therefore, their 152 * possible for some data types to not be registered, and therefore, their
146 * checkboxes remain hidden, and never get cached. 153 * checkboxes remain hidden, and never get cached.
147 * @private 154 * @private
148 */ 155 */
149 restoreDataTypeCheckboxes_: function() { 156 restoreDataTypeCheckboxes_: function() {
150 for (dataType in dataTypeBoxes_) { 157 for (dataType in dataTypeBoxesChecked_) {
151 $(dataType).checked = dataTypeBoxes_[dataType]; 158 $(dataType).checked = dataTypeBoxesChecked_[dataType];
152 } 159 }
153 }, 160 },
154 161
155 /** 162 /**
156 * Enables / grays out the sync data type checkboxes in the advanced 163 * Enables / grays out the sync data type checkboxes in the advanced
157 * settings dialog. 164 * settings dialog.
158 * @param {boolean} enabled True for enabled, false for grayed out. 165 * @param {boolean} enabled True for enabled, false for grayed out.
159 * @private 166 * @private
160 */ 167 */
161 setDataTypeCheckboxesEnabled_: function(enabled) { 168 setDataTypeCheckboxesEnabled_: function(enabled) {
162 var checkboxes = $('choose-data-types-body').querySelectorAll('input'); 169 for (dataType in dataTypeBoxesDisabled_) {
163 for (var i = 0; i < checkboxes.length; i++) { 170 $(dataType).disabled = !enabled || dataTypeBoxesDisabled_[dataType];
164 checkboxes[i].disabled = !enabled;
165 } 171 }
166 }, 172 },
167 173
168 /** 174 /**
169 * Sets the state of the sync data type checkboxes based on whether "Sync 175 * Sets the state of the sync data type checkboxes based on whether "Sync
170 * everything", "Choose what to sync", or "Sync nothing" are selected in the 176 * everything", "Choose what to sync", or "Sync nothing" are selected in the
171 * drop-down menu of the advanced settings dialog. 177 * drop-down menu of the advanced settings dialog.
172 * @param {cr.DataTypeSelection} selectedIndex Index of user's selection. 178 * @param {cr.DataTypeSelection} selectedIndex Index of user's selection.
173 * @private 179 * @private
174 */ 180 */
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 $('customize-link').disabled = disabled; 299 $('customize-link').disabled = disabled;
294 $('customize-link').onclick = disabled ? null : function() { 300 $('customize-link').onclick = disabled ? null : function() {
295 SyncSetupOverlay.showCustomizePage(self.syncConfigureArgs_, 301 SyncSetupOverlay.showCustomizePage(self.syncConfigureArgs_,
296 DataTypeSelection.SYNC_EVERYTHING); 302 DataTypeSelection.SYNC_EVERYTHING);
297 return false; 303 return false;
298 }; 304 };
299 }, 305 },
300 306
301 /** 307 /**
302 * Shows or hides the sync data type checkboxes in the advanced sync 308 * Shows or hides the sync data type checkboxes in the advanced sync
303 * settings dialog. Also initializes |dataTypeBoxes_| with their values, and 309 * settings dialog. Also initializes |dataTypeBoxesChecked_| and
304 * makes their onclick handlers update |dataTypeBoxes_|. 310 * |dataTypeBoxedDisabled_| with their values, and makes their onclick
311 * handlers update |dataTypeBoxesChecked_|.
305 * @param {Object} args The configuration data used to show/hide UI. 312 * @param {Object} args The configuration data used to show/hide UI.
306 * @private 313 * @private
307 */ 314 */
308 setChooseDataTypesCheckboxes_: function(args) { 315 setChooseDataTypesCheckboxes_: function(args) {
309 var datatypeSelect = $('sync-select-datatypes'); 316 var datatypeSelect = $('sync-select-datatypes');
310 datatypeSelect.selectedIndex = args.syncAllDataTypes ? 317 datatypeSelect.selectedIndex = args.syncAllDataTypes ?
311 DataTypeSelection.SYNC_EVERYTHING : 318 DataTypeSelection.SYNC_EVERYTHING :
312 DataTypeSelection.CHOOSE_WHAT_TO_SYNC; 319 DataTypeSelection.CHOOSE_WHAT_TO_SYNC;
313 320
314 $('bookmarks-checkbox').checked = args.bookmarksSynced; 321 $('bookmarks-checkbox').checked = args.bookmarksSynced;
315 dataTypeBoxes_['bookmarks-checkbox'] = args.bookmarksSynced; 322 dataTypeBoxesChecked_['bookmarks-checkbox'] = args.bookmarksSynced;
323 dataTypeBoxesDisabled_['bookmarks-checkbox'] = args.bookmarksEnforced;
316 $('bookmarks-checkbox').onclick = this.handleDataTypeClick_; 324 $('bookmarks-checkbox').onclick = this.handleDataTypeClick_;
317 325
318 $('preferences-checkbox').checked = args.preferencesSynced; 326 $('preferences-checkbox').checked = args.preferencesSynced;
319 dataTypeBoxes_['preferences-checkbox'] = args.preferencesSynced; 327 dataTypeBoxesChecked_['preferences-checkbox'] = args.preferencesSynced;
328 dataTypeBoxesDisabled_['preferences-checkbox'] = args.preferencesEnforced;
320 $('preferences-checkbox').onclick = this.handleDataTypeClick_; 329 $('preferences-checkbox').onclick = this.handleDataTypeClick_;
321 330
322 $('themes-checkbox').checked = args.themesSynced; 331 $('themes-checkbox').checked = args.themesSynced;
323 dataTypeBoxes_['themes-checkbox'] = args.themesSynced; 332 dataTypeBoxesChecked_['themes-checkbox'] = args.themesSynced;
333 dataTypeBoxesDisabled_['themes-checkbox'] = args.themesEnforced;
324 $('themes-checkbox').onclick = this.handleDataTypeClick_; 334 $('themes-checkbox').onclick = this.handleDataTypeClick_;
325 335
326 if (args.passwordsRegistered) { 336 if (args.passwordsRegistered) {
327 $('passwords-checkbox').checked = args.passwordsSynced; 337 $('passwords-checkbox').checked = args.passwordsSynced;
328 dataTypeBoxes_['passwords-checkbox'] = args.passwordsSynced; 338 dataTypeBoxesChecked_['passwords-checkbox'] = args.passwordsSynced;
339 dataTypeBoxesDisabled_['passwords-checkbox'] = args.passwordsEnforced;
329 $('passwords-checkbox').onclick = this.handleDataTypeClick_; 340 $('passwords-checkbox').onclick = this.handleDataTypeClick_;
330 $('passwords-item').hidden = false; 341 $('passwords-item').hidden = false;
331 } else { 342 } else {
332 $('passwords-item').hidden = true; 343 $('passwords-item').hidden = true;
333 } 344 }
334 if (args.autofillRegistered) { 345 if (args.autofillRegistered) {
335 $('autofill-checkbox').checked = args.autofillSynced; 346 $('autofill-checkbox').checked = args.autofillSynced;
336 dataTypeBoxes_['autofill-checkbox'] = args.autofillSynced; 347 dataTypeBoxesChecked_['autofill-checkbox'] = args.autofillSynced;
348 dataTypeBoxesDisabled_['autofill-checkbox'] = args.autofillEnforced;
337 $('autofill-checkbox').onclick = this.handleDataTypeClick_; 349 $('autofill-checkbox').onclick = this.handleDataTypeClick_;
338 $('autofill-item').hidden = false; 350 $('autofill-item').hidden = false;
339 } else { 351 } else {
340 $('autofill-item').hidden = true; 352 $('autofill-item').hidden = true;
341 } 353 }
342 if (args.extensionsRegistered) { 354 if (args.extensionsRegistered) {
343 $('extensions-checkbox').checked = args.extensionsSynced; 355 $('extensions-checkbox').checked = args.extensionsSynced;
344 dataTypeBoxes_['extensions-checkbox'] = args.extensionsSynced; 356 dataTypeBoxesChecked_['extensions-checkbox'] = args.extensionsSynced;
357 dataTypeBoxesDisabled_['extensions-checkbox'] = args.extensionsEnforced;
345 $('extensions-checkbox').onclick = this.handleDataTypeClick_; 358 $('extensions-checkbox').onclick = this.handleDataTypeClick_;
346 $('extensions-item').hidden = false; 359 $('extensions-item').hidden = false;
347 } else { 360 } else {
348 $('extensions-item').hidden = true; 361 $('extensions-item').hidden = true;
349 } 362 }
350 if (args.typedUrlsRegistered) { 363 if (args.typedUrlsRegistered) {
351 $('typed-urls-checkbox').checked = args.typedUrlsSynced; 364 $('typed-urls-checkbox').checked = args.typedUrlsSynced;
352 dataTypeBoxes_['typed-urls-checkbox'] = args.typedUrlsSynced; 365 dataTypeBoxesChecked_['typed-urls-checkbox'] = args.typedUrlsSynced;
366 dataTypeBoxesDisabled_['typed-urls-checkbox'] = args.typedUrlsEnforced;
353 $('typed-urls-checkbox').onclick = this.handleDataTypeClick_; 367 $('typed-urls-checkbox').onclick = this.handleDataTypeClick_;
354 $('omnibox-item').hidden = false; 368 $('omnibox-item').hidden = false;
355 } else { 369 } else {
356 $('omnibox-item').hidden = true; 370 $('omnibox-item').hidden = true;
357 } 371 }
358 if (args.appsRegistered) { 372 if (args.appsRegistered) {
359 $('apps-checkbox').checked = args.appsSynced; 373 $('apps-checkbox').checked = args.appsSynced;
360 dataTypeBoxes_['apps-checkbox'] = args.appsSynced; 374 dataTypeBoxesChecked_['apps-checkbox'] = args.appsSynced;
375 dataTypeBoxesDisabled_['apps-checkbox'] = args.appsEnforced;
361 $('apps-checkbox').onclick = this.handleDataTypeClick_; 376 $('apps-checkbox').onclick = this.handleDataTypeClick_;
362 $('apps-item').hidden = false; 377 $('apps-item').hidden = false;
363 } else { 378 } else {
364 $('apps-item').hidden = true; 379 $('apps-item').hidden = true;
365 } 380 }
366 if (args.tabsRegistered) { 381 if (args.tabsRegistered) {
367 $('tabs-checkbox').checked = args.tabsSynced; 382 $('tabs-checkbox').checked = args.tabsSynced;
368 dataTypeBoxes_['tabs-checkbox'] = args.tabsSynced; 383 dataTypeBoxesChecked_['tabs-checkbox'] = args.tabsSynced;
384 dataTypeBoxesDisabled_['tabs-checkbox'] = args.tabsEnforced;
369 $('tabs-checkbox').onclick = this.handleDataTypeClick_; 385 $('tabs-checkbox').onclick = this.handleDataTypeClick_;
370 $('tabs-item').hidden = false; 386 $('tabs-item').hidden = false;
371 } else { 387 } else {
372 $('tabs-item').hidden = true; 388 $('tabs-item').hidden = true;
373 } 389 }
374 390
375 this.setDataTypeCheckboxes_(datatypeSelect.selectedIndex); 391 this.setDataTypeCheckboxes_(datatypeSelect.selectedIndex);
376 }, 392 },
377 393
378 /** 394 /**
379 * Updates the cached values of the sync data type checkboxes stored in 395 * Updates the cached values of the sync data type checkboxes stored in
380 * |dataTypeBoxes_|. Used as an onclick handler for each data type checkbox. 396 * |dataTypeBoxesChecked_|. Used as an onclick handler for each data type
397 * checkbox.
381 * @private 398 * @private
382 */ 399 */
383 handleDataTypeClick_: function() { 400 handleDataTypeClick_: function() {
384 dataTypeBoxes_[this.id] = this.checked; 401 dataTypeBoxesChecked_[this.id] = this.checked;
385 chrome.send('coreOptionsUserMetricsAction', 402 chrome.send('coreOptionsUserMetricsAction',
386 ['Options_SyncToggleDataType']); 403 ['Options_SyncToggleDataType']);
387 }, 404 },
388 405
389 setEncryptionRadios_: function(args) { 406 setEncryptionRadios_: function(args) {
390 if (!args.encryptAllData && !args.usePassphrase) { 407 if (!args.encryptAllData && !args.usePassphrase) {
391 $('basic-encryption-option').checked = true; 408 $('basic-encryption-option').checked = true;
392 } else { 409 } else {
393 $('full-encryption-option').checked = true; 410 $('full-encryption-option').checked = true;
394 $('full-encryption-option').disabled = true; 411 $('full-encryption-option').disabled = true;
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after
787 804
788 SyncSetupOverlay.showStopSyncingUI = function() { 805 SyncSetupOverlay.showStopSyncingUI = function() {
789 SyncSetupOverlay.getInstance().showStopSyncingUI_(); 806 SyncSetupOverlay.getInstance().showStopSyncingUI_();
790 }; 807 };
791 808
792 // Export 809 // Export
793 return { 810 return {
794 SyncSetupOverlay: SyncSetupOverlay 811 SyncSetupOverlay: SyncSetupOverlay
795 }; 812 };
796 }); 813 });
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/sync/profile_sync_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698