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

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

Issue 14691004: [sync] Separate sign in from sync on Desktop Chrome (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 7 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
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 OptionsPage = options.OptionsPage; 6 /** @const */ var OptionsPage = options.OptionsPage;
7 7
8 // Variable to track if a captcha challenge was issued. If this gets set to 8 // Variable to track if a captcha challenge was issued. If this gets set to
9 // true, it stays that way until we are told about successful login from 9 // true, it stays that way until we are told about successful login from
10 // the browser. This means subsequent errors (like invalid password) are 10 // the browser. This means subsequent errors (like invalid password) are
(...skipping 17 matching lines...) Expand all
28 // the new unified encryption UI is displayed instead of the old encryption 28 // the new unified encryption UI is displayed instead of the old encryption
29 // ui (where passphrase and encrypted types could be set independently of 29 // ui (where passphrase and encrypted types could be set independently of
30 // each other). 30 // each other).
31 var keystoreEncryptionEnabled_ = false; 31 var keystoreEncryptionEnabled_ = false;
32 32
33 // The last email address that this profile was connected to. If the profile 33 // The last email address that this profile was connected to. If the profile
34 // was never connected this is an empty string. Otherwise it is a normalized 34 // was never connected this is an empty string. Otherwise it is a normalized
35 // email address. 35 // email address.
36 var lastEmailAddress_ = ''; 36 var lastEmailAddress_ = '';
37 37
38 // An object used as a cache of the arguments passed in while initially
39 // displaying the advanced sync settings dialog. Used to switch between the
40 // options in the main drop-down menu. Reset when the dialog is closed.
41 var syncConfigureArgs_ = null;
42
43 // A dictionary used as a cache of the checked states of the sync data type
44 // checkboxes. Used while switching between the options in the main drop-down
45 // menu of the advanced sync settings dialog. Reset when the dialog is closed.
46 var dataTypeBoxes_ = {};
Andrew T Wilson (Slow) 2013/05/14 16:48:27 Can you describe what the dictionary holds (what a
Raghu Simha 2013/05/15 02:09:54 Done. I've beefed up this comment to include what
47
48 /**
49 * The user's selection in the synced data type drop-down menu, as an index.
50 * @enum {number}
51 * @const
52 */
53 var DataTypeSelection = {
54 SYNC_EVERYTHING: 0,
55 CHOOSE_WHAT_TO_SYNC: 1,
56 SYNC_NOTHING: 2
57 };
58
38 /** 59 /**
39 * SyncSetupOverlay class 60 * SyncSetupOverlay class
40 * Encapsulated handling of the 'Sync Setup' overlay page. 61 * Encapsulated handling of the 'Sync Setup' overlay page.
41 * @class 62 * @class
42 */ 63 */
43 function SyncSetupOverlay() { 64 function SyncSetupOverlay() {
44 OptionsPage.call(this, 'syncSetup', 65 OptionsPage.call(this, 'syncSetup',
45 loadTimeData.getString('syncSetupOverlayTabTitle'), 66 loadTimeData.getString('syncSetupOverlayTabTitle'),
46 'sync-setup-overlay'); 67 'sync-setup-overlay');
47 } 68 }
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 self.closeOverlay_(); 109 self.closeOverlay_();
89 }; 110 };
90 $('different-email').innerHTML = loadTimeData.getString('differentEmail'); 111 $('different-email').innerHTML = loadTimeData.getString('differentEmail');
91 }, 112 },
92 113
93 showOverlay_: function() { 114 showOverlay_: function() {
94 OptionsPage.navigateToPage('syncSetup'); 115 OptionsPage.navigateToPage('syncSetup');
95 }, 116 },
96 117
97 closeOverlay_: function() { 118 closeOverlay_: function() {
119 this.syncConfigureArgs_ = null;
120 this.dataTypeBoxes_ = {};
98 OptionsPage.closeOverlay(); 121 OptionsPage.closeOverlay();
99 }, 122 },
100 123
101 /** @override */ 124 /** @override */
102 didShowPage: function() { 125 didShowPage: function() {
103 chrome.send('SyncSetupShowSetupUI'); 126 chrome.send('SyncSetupShowSetupUI');
104 }, 127 },
105 128
106 /** @override */ 129 /** @override */
107 didClosePage: function() { 130 didClosePage: function() {
(...skipping 30 matching lines...) Expand all
138 onPassphraseRadioChanged_: function() { 161 onPassphraseRadioChanged_: function() {
139 var visible = this.getPassphraseRadioCheckedValue_() == 'explicit'; 162 var visible = this.getPassphraseRadioCheckedValue_() == 'explicit';
140 $('sync-custom-passphrase').hidden = !visible; 163 $('sync-custom-passphrase').hidden = !visible;
141 }, 164 },
142 165
143 onEncryptionRadioChanged_: function() { 166 onEncryptionRadioChanged_: function() {
144 var visible = $('full-encryption-option').checked; 167 var visible = $('full-encryption-option').checked;
145 $('sync-custom-passphrase').hidden = !visible; 168 $('sync-custom-passphrase').hidden = !visible;
146 }, 169 },
147 170
148 checkAllDataTypeCheckboxes_: function() { 171 /**
149 // Only check the visible ones (since there's no way to uncheck 172 * Sets the checked state of the individual sync data type checkboxes in the
150 // the invisible ones). 173 * advanced sync settings dialog.
174 * @param {boolean} value True for checked, false for unchecked.
175 * @private
176 */
177 checkAllDataTypeCheckboxes_: function(value) {
178 // Only check / uncheck the visible ones (since there's no way to uncheck
179 // / check the invisible ones).
151 var checkboxes = $('choose-data-types-body').querySelectorAll( 180 var checkboxes = $('choose-data-types-body').querySelectorAll(
152 '.sync-type-checkbox:not([hidden]) input'); 181 '.sync-type-checkbox:not([hidden]) input');
153 for (var i = 0; i < checkboxes.length; i++) { 182 for (var i = 0; i < checkboxes.length; i++) {
154 checkboxes[i].checked = true; 183 checkboxes[i].checked = value;
155 } 184 }
156 }, 185 },
157 186
187 /**
188 * Restores the checked states of the sync data type checkboxes in the
189 * advanced sync settings dialog when "Choose what to sync" is selected.
190 * Required because all the checkboxes are checked when "Sync everything" is
191 * selected, and unchecked when "Sync nothing" is selected.
192 * @private
193 */
194 restoreDataTypeCheckboxes_: function() {
195 if ('bookmarksSynced' in dataTypeBoxes_)
Andrew T Wilson (Slow) 2013/05/14 16:48:27 What does it mean to not have 'bookmarksSynced' in
Raghu Simha 2013/05/15 02:09:54 This is to prevent us from trying to modify any hi
196 $('bookmarks-checkbox').checked = dataTypeBoxes_['bookmarksSynced'];
197 if ('preferencesSynced' in dataTypeBoxes_)
198 $('preferences-checkbox').checked = dataTypeBoxes_['preferencesSynced'];
199 if ('themesSynced' in dataTypeBoxes_)
200 $('themes-checkbox').checked = dataTypeBoxes_['themesSynced'];
201 if ('passwordsSynced' in dataTypeBoxes_)
202 $('passwords-checkbox').checked = dataTypeBoxes_['passwordsSynced'];
203 if ('autofillSynced' in dataTypeBoxes_)
204 $('autofill-checkbox').checked = dataTypeBoxes_['autofillSynced'];
205 if ('extensionsSynced' in dataTypeBoxes_)
206 $('extensions-checkbox').checked = dataTypeBoxes_['extensionsSynced'];
207 if ('typedUrlsSynced' in dataTypeBoxes_)
208 $('typed-urls-checkbox').checked = dataTypeBoxes_['typedUrlsSynced'];
209 if ('appsSynced' in dataTypeBoxes_)
210 $('apps-checkbox').checked = dataTypeBoxes_['appsSynced'];
211 if ('tabsSynced' in dataTypeBoxes_)
212 $('tabs-checkbox').checked = dataTypeBoxes_['tabsSynced'];
213 },
214
215 /**
216 * Enables / grays out the sync data type checkboxes in the advanced
217 * settings dialog.
218 * @param {boolean} enabled True for enabled, false for grayed out.
219 * @private
220 */
158 setDataTypeCheckboxesEnabled_: function(enabled) { 221 setDataTypeCheckboxesEnabled_: function(enabled) {
159 var checkboxes = $('choose-data-types-body').querySelectorAll('input'); 222 var checkboxes = $('choose-data-types-body').querySelectorAll('input');
160 for (var i = 0; i < checkboxes.length; i++) { 223 for (var i = 0; i < checkboxes.length; i++) {
161 checkboxes[i].disabled = !enabled; 224 checkboxes[i].disabled = !enabled;
162 } 225 }
163 }, 226 },
164 227
165 setCheckboxesToKeepEverythingSynced_: function(value) { 228 /**
166 this.setDataTypeCheckboxesEnabled_(!value); 229 * Sets the state of the sync data type checkboxes based on whether "Sync
167 if (value) 230 * everything", "Choose what to sync", or "Sync nothing" are selected in the
168 this.checkAllDataTypeCheckboxes_(); 231 * drop-down menu of the advanced settings dialog.
232 * @param {cr.DataTypeSelection} selectedIndex Index of user's selection.
233 * @private
234 */
235 setDataTypeCheckboxes_: function(selectedIndex) {
236 if (selectedIndex == DataTypeSelection.CHOOSE_WHAT_TO_SYNC) {
237 this.setDataTypeCheckboxesEnabled_(true);
238 this.restoreDataTypeCheckboxes_();
239 } else {
240 this.setDataTypeCheckboxesEnabled_(false);
241 this.checkAllDataTypeCheckboxes_(selectedIndex ==
242 DataTypeSelection.SYNC_EVERYTHING);
243 }
169 }, 244 },
170 245
171 // Returns true if none of the visible checkboxes are checked. 246 // Returns true if none of the visible checkboxes are checked.
172 noDataTypesChecked_: function() { 247 noDataTypesChecked_: function() {
173 var query = '.sync-type-checkbox:not([hidden]) input:checked'; 248 var query = '.sync-type-checkbox:not([hidden]) input:checked';
174 var checkboxes = $('choose-data-types-body').querySelectorAll(query); 249 var checkboxes = $('choose-data-types-body').querySelectorAll(query);
175 return checkboxes.length == 0; 250 return checkboxes.length == 0;
176 }, 251 },
177 252
178 checkPassphraseMatch_: function() { 253 checkPassphraseMatch_: function() {
(...skipping 22 matching lines...) Expand all
201 return false; 276 return false;
202 } 277 }
203 278
204 return true; 279 return true;
205 }, 280 },
206 281
207 sendConfiguration_: function() { 282 sendConfiguration_: function() {
208 // Trying to submit, so hide previous errors. 283 // Trying to submit, so hide previous errors.
209 $('error-text').hidden = true; 284 $('error-text').hidden = true;
210 285
211 var syncAll = $('sync-select-datatypes').selectedIndex == 0; 286 var chooseWhatToSync = $('sync-select-datatypes').selectedIndex ==
212 if (!syncAll && this.noDataTypesChecked_()) { 287 DataTypeSelection.CHOOSE_WHAT_TO_SYNC;
288 if (chooseWhatToSync && this.noDataTypesChecked_()) {
213 $('error-text').hidden = false; 289 $('error-text').hidden = false;
214 return; 290 return;
215 } 291 }
216 292
217 var encryptAllData = this.getEncryptionRadioCheckedValue_() == 'all'; 293 var encryptAllData = this.getEncryptionRadioCheckedValue_() == 'all';
218 if (!encryptAllData && 294 if (!encryptAllData &&
219 $('full-encryption-option').checked && 295 $('full-encryption-option').checked &&
220 this.keystoreEncryptionEnabled_) { 296 this.keystoreEncryptionEnabled_) {
221 encryptAllData = true; 297 encryptAllData = true;
222 } 298 }
(...skipping 27 matching lines...) Expand all
250 usePassphrase = false; 326 usePassphrase = false;
251 } 327 }
252 328
253 // Don't allow the user to tweak the settings once we send the 329 // Don't allow the user to tweak the settings once we send the
254 // configuration to the backend. 330 // configuration to the backend.
255 this.setInputElementsDisabledState_(true); 331 this.setInputElementsDisabledState_(true);
256 this.animateDisableLink_($('use-default-link'), true, null); 332 this.animateDisableLink_($('use-default-link'), true, null);
257 333
258 // These values need to be kept in sync with where they are read in 334 // These values need to be kept in sync with where they are read in
259 // SyncSetupFlow::GetDataTypeChoiceData(). 335 // SyncSetupFlow::GetDataTypeChoiceData().
336 var syncAll = $('sync-select-datatypes').selectedIndex ==
337 DataTypeSelection.SYNC_EVERYTHING;
338 var syncNothing = $('sync-select-datatypes').selectedIndex ==
339 DataTypeSelection.SYNC_NOTHING;
260 var result = JSON.stringify({ 340 var result = JSON.stringify({
261 'syncAllDataTypes': syncAll, 341 'syncAllDataTypes': syncAll,
342 'syncNothing': syncNothing,
Andrew T Wilson (Slow) 2013/05/14 16:48:27 nit: I'm slightly nervous about this because it's
Raghu Simha 2013/05/15 02:09:54 It's impossible for both values to be true, since
262 'bookmarksSynced': syncAll || $('bookmarks-checkbox').checked, 343 'bookmarksSynced': syncAll || $('bookmarks-checkbox').checked,
263 'preferencesSynced': syncAll || $('preferences-checkbox').checked, 344 'preferencesSynced': syncAll || $('preferences-checkbox').checked,
264 'themesSynced': syncAll || $('themes-checkbox').checked, 345 'themesSynced': syncAll || $('themes-checkbox').checked,
265 'passwordsSynced': syncAll || $('passwords-checkbox').checked, 346 'passwordsSynced': syncAll || $('passwords-checkbox').checked,
266 'autofillSynced': syncAll || $('autofill-checkbox').checked, 347 'autofillSynced': syncAll || $('autofill-checkbox').checked,
267 'extensionsSynced': syncAll || $('extensions-checkbox').checked, 348 'extensionsSynced': syncAll || $('extensions-checkbox').checked,
268 'typedUrlsSynced': syncAll || $('typed-urls-checkbox').checked, 349 'typedUrlsSynced': syncAll || $('typed-urls-checkbox').checked,
269 'appsSynced': syncAll || $('apps-checkbox').checked, 350 'appsSynced': syncAll || $('apps-checkbox').checked,
270 'tabsSynced': syncAll || $('tabs-checkbox').checked, 351 'tabsSynced': syncAll || $('tabs-checkbox').checked,
271 'encryptAllData': encryptAllData, 352 'encryptAllData': encryptAllData,
(...skipping 14 matching lines...) Expand all
286 */ 367 */
287 setInputElementsDisabledState_: function(disabled) { 368 setInputElementsDisabledState_: function(disabled) {
288 var configureElements = 369 var configureElements =
289 $('customize-sync-preferences').querySelectorAll('input'); 370 $('customize-sync-preferences').querySelectorAll('input');
290 for (var i = 0; i < configureElements.length; i++) 371 for (var i = 0; i < configureElements.length; i++)
291 configureElements[i].disabled = disabled; 372 configureElements[i].disabled = disabled;
292 $('sync-select-datatypes').disabled = disabled; 373 $('sync-select-datatypes').disabled = disabled;
293 374
294 var self = this; 375 var self = this;
295 this.animateDisableLink_($('customize-link'), disabled, function() { 376 this.animateDisableLink_($('customize-link'), disabled, function() {
296 self.showCustomizePage_(null, true); 377 self.showCustomizePage_(null, DataTypeSelection.SYNC_EVERYTHING);
297 }); 378 });
298 }, 379 },
299 380
300 /** 381 /**
301 * Animate a link being enabled/disabled. The link is hidden by animating 382 * Animate a link being enabled/disabled. The link is hidden by animating
302 * its opacity, but to ensure the user doesn't click it during that time, 383 * its opacity, but to ensure the user doesn't click it during that time,
303 * its onclick handler is changed to null as well. 384 * its onclick handler is changed to null as well.
304 * @param {HTMLElement} elt The anchor element to enable/disable. 385 * @param {HTMLElement} elt The anchor element to enable/disable.
305 * @param {boolean} disabled True if the link should be disabled. 386 * @param {boolean} disabled True if the link should be disabled.
306 * @param {function} enabledFunction The onclick handler when the link is 387 * @param {function} enabledFunction The onclick handler when the link is
(...skipping 11 matching lines...) Expand all
318 elt.classList.remove('transparent'); 399 elt.classList.remove('transparent');
319 elt.hidden = true; 400 elt.hidden = true;
320 }); 401 });
321 } else { 402 } else {
322 elt.hidden = false; 403 elt.hidden = false;
323 elt.onclick = enabledFunction; 404 elt.onclick = enabledFunction;
324 } 405 }
325 }, 406 },
326 407
327 /** 408 /**
328 * Shows or hides the Sync data type checkboxes in the advanced 409 * Shows or hides the sync data type checkboxes in the advanced sync
329 * configuration screen. 410 * settings dialog. Also initializes |dataTypeBoxes_| with their values, and
411 * makes their onclick handlers update |dataTypeBoxes_|.
330 * @param {Object} args The configuration data used to show/hide UI. 412 * @param {Object} args The configuration data used to show/hide UI.
331 * @private 413 * @private
332 */ 414 */
333 setChooseDataTypesCheckboxes_: function(args) { 415 setChooseDataTypesCheckboxes_: function(args) {
334 var datatypeSelect = $('sync-select-datatypes'); 416 var datatypeSelect = $('sync-select-datatypes');
335 datatypeSelect.selectedIndex = args.syncAllDataTypes ? 0 : 1; 417 datatypeSelect.selectedIndex = args.syncAllDataTypes ?
418 DataTypeSelection.SYNC_EVERYTHING :
419 DataTypeSelection.CHOOSE_WHAT_TO_SYNC;
336 420
337 $('bookmarks-checkbox').checked = args.bookmarksSynced; 421 $('bookmarks-checkbox').checked = args.bookmarksSynced;
422 dataTypeBoxes_['bookmarksSynced'] = args.bookmarksSynced;
423 $('bookmarks-checkbox').onclick = function() {
424 dataTypeBoxes_['bookmarksSynced'] = $('bookmarks-checkbox').checked;
Andrew T Wilson (Slow) 2013/05/14 16:48:27 I'm OK with this, but I'm wondering if there's som
Raghu Simha 2013/05/15 02:09:54 The DOM elements already have an "id" attribute th
425 };
426
338 $('preferences-checkbox').checked = args.preferencesSynced; 427 $('preferences-checkbox').checked = args.preferencesSynced;
428 dataTypeBoxes_['preferencesSynced'] = args.preferencesSynced;
429 $('preferences-checkbox').onclick = function() {
430 dataTypeBoxes_['preferencesSynced'] = $('preferences-checkbox').checked;
431 };
432
339 $('themes-checkbox').checked = args.themesSynced; 433 $('themes-checkbox').checked = args.themesSynced;
434 dataTypeBoxes_['themesSynced'] = args.themesSynced;
435 $('themes-checkbox').onclick = function() {
436 dataTypeBoxes_['themesSynced'] = $('themes-checkbox').checked;
437 };
340 438
341 if (args.passwordsRegistered) { 439 if (args.passwordsRegistered) {
342 $('passwords-checkbox').checked = args.passwordsSynced; 440 $('passwords-checkbox').checked = args.passwordsSynced;
441 dataTypeBoxes_['passwordsSynced'] = args.passwordsSynced;
442 $('passwords-checkbox').onclick = function() {
443 dataTypeBoxes_['passwordsSynced'] = $('passwords-checkbox').checked;
444 };
343 $('passwords-item').hidden = false; 445 $('passwords-item').hidden = false;
344 } else { 446 } else {
345 $('passwords-item').hidden = true; 447 $('passwords-item').hidden = true;
346 } 448 }
347 if (args.autofillRegistered) { 449 if (args.autofillRegistered) {
348 $('autofill-checkbox').checked = args.autofillSynced; 450 $('autofill-checkbox').checked = args.autofillSynced;
451 dataTypeBoxes_['autofillSynced'] = args.autofillSynced;
452 $('autofill-checkbox').onclick = function() {
453 dataTypeBoxes_['autofillSynced'] = $('autofill-checkbox').checked;
454 };
349 $('autofill-item').hidden = false; 455 $('autofill-item').hidden = false;
350 } else { 456 } else {
351 $('autofill-item').hidden = true; 457 $('autofill-item').hidden = true;
352 } 458 }
353 if (args.extensionsRegistered) { 459 if (args.extensionsRegistered) {
354 $('extensions-checkbox').checked = args.extensionsSynced; 460 $('extensions-checkbox').checked = args.extensionsSynced;
461 dataTypeBoxes_['extensionsSynced'] = args.extensionsSynced;
462 $('extensions-checkbox').onclick = function() {
463 dataTypeBoxes_['extensionsSynced'] = $('extensions-checkbox').checked;
464 };
355 $('extensions-item').hidden = false; 465 $('extensions-item').hidden = false;
356 } else { 466 } else {
357 $('extensions-item').hidden = true; 467 $('extensions-item').hidden = true;
358 } 468 }
359 if (args.typedUrlsRegistered) { 469 if (args.typedUrlsRegistered) {
360 $('typed-urls-checkbox').checked = args.typedUrlsSynced; 470 $('typed-urls-checkbox').checked = args.typedUrlsSynced;
471 dataTypeBoxes_['typedUrlsSynced'] = args.typedUrlsSynced;
472 $('typed-urls-checkbox').onclick = function() {
473 dataTypeBoxes_['typedUrlsSynced'] = $('typed-urls-checkbox').checked;
474 };
361 $('omnibox-item').hidden = false; 475 $('omnibox-item').hidden = false;
362 } else { 476 } else {
363 $('omnibox-item').hidden = true; 477 $('omnibox-item').hidden = true;
364 } 478 }
365 if (args.appsRegistered) { 479 if (args.appsRegistered) {
366 $('apps-checkbox').checked = args.appsSynced; 480 $('apps-checkbox').checked = args.appsSynced;
481 dataTypeBoxes_['appsSynced'] = args.appsSynced;
482 $('apps-checkbox').onclick = function() {
483 dataTypeBoxes_['appsSynced'] = $('apps-checkbox').checked;
484 };
367 $('apps-item').hidden = false; 485 $('apps-item').hidden = false;
368 } else { 486 } else {
369 $('apps-item').hidden = true; 487 $('apps-item').hidden = true;
370 } 488 }
371 if (args.tabsRegistered) { 489 if (args.tabsRegistered) {
372 $('tabs-checkbox').checked = args.tabsSynced; 490 $('tabs-checkbox').checked = args.tabsSynced;
491 dataTypeBoxes_['tabsSynced'] = args.tabsSynced;
492 $('tabs-checkbox').onclick = function() {
493 dataTypeBoxes_['tabsSynced'] = $('tabs-checkbox').checked;
494 };
373 $('tabs-item').hidden = false; 495 $('tabs-item').hidden = false;
374 } else { 496 } else {
375 $('tabs-item').hidden = true; 497 $('tabs-item').hidden = true;
376 } 498 }
377 499
378 this.setCheckboxesToKeepEverythingSynced_(args.syncAllDataTypes); 500 this.setDataTypeCheckboxes_(datatypeSelect.selectedIndex);
379 }, 501 },
380 502
381 setEncryptionRadios_: function(args) { 503 setEncryptionRadios_: function(args) {
382 if (args.encryptAllData) { 504 if (args.encryptAllData) {
383 $('encrypt-all-option').checked = true; 505 $('encrypt-all-option').checked = true;
384 this.disableEncryptionRadioGroup_(); 506 this.disableEncryptionRadioGroup_();
385 } else { 507 } else {
386 $('encrypt-sensitive-option').checked = true; 508 $('encrypt-sensitive-option').checked = true;
387 } 509 }
388 510
(...skipping 21 matching lines...) Expand all
410 532
411 setCheckboxesAndErrors_: function(args) { 533 setCheckboxesAndErrors_: function(args) {
412 this.setChooseDataTypesCheckboxes_(args); 534 this.setChooseDataTypesCheckboxes_(args);
413 this.setEncryptionRadios_(args); 535 this.setEncryptionRadios_(args);
414 this.setPassphraseRadios_(args); 536 this.setPassphraseRadios_(args);
415 }, 537 },
416 538
417 showConfigure_: function(args) { 539 showConfigure_: function(args) {
418 var datatypeSelect = $('sync-select-datatypes'); 540 var datatypeSelect = $('sync-select-datatypes');
419 var self = this; 541 var self = this;
542
543 // Cache the sync config args so they can be reused when we transition
544 // between the drop-down menu items in the advanced settings dialog.
545 if (args)
546 this.syncConfigureArgs_ = args;
547
548 // Once the advanced sync settings dialog is visible, we transition
549 // between its drop-down menu items as follows:
550 // "Sync everything": Show encryption and passphrase sections, and disable
551 // and check all data type checkboxes.
552 // "Sync everything": Hide encryption and passphrase sections, and disable
553 // and uncheck all data type checkboxes.
554 // "Choose what to sync": Show encryption and passphrase sections, enable
555 // data type checkboxes, and restore their checked state to the last time
556 // the "Choose what to sync" was selected while the dialog was still up.
420 datatypeSelect.onchange = function() { 557 datatypeSelect.onchange = function() {
421 var syncAll = this.selectedIndex == 0; 558 if (this.selectedIndex == DataTypeSelection.SYNC_NOTHING) {
422 self.setCheckboxesToKeepEverythingSynced_(syncAll); 559 self.showSyncNothingPage_();
560 } else {
561 self.showCustomizePage_(self.syncConfigureArgs_, this.selectedIndex);
562 if (this.selectedIndex == DataTypeSelection.SYNC_EVERYTHING)
563 self.checkAllDataTypeCheckboxes_(true);
564 else
565 self.restoreDataTypeCheckboxes_();
566 }
423 }; 567 };
424 568
425 this.resetPage_('sync-setup-configure'); 569 this.resetPage_('sync-setup-configure');
426 $('sync-setup-configure').hidden = false; 570 $('sync-setup-configure').hidden = false;
427 571
428 // onsubmit is changed when submitting a passphrase. Reset it to its 572 // onsubmit is changed when submitting a passphrase. Reset it to its
429 // default. 573 // default.
430 $('choose-data-types-form').onsubmit = function() { 574 $('choose-data-types-form').onsubmit = function() {
431 self.sendConfiguration_(); 575 self.sendConfiguration_();
432 return false; 576 return false;
433 }; 577 };
434 578
435 if (args) { 579 if (args) {
436 this.setCheckboxesAndErrors_(args); 580 this.setCheckboxesAndErrors_(args);
437 581
438 this.useEncryptEverything_ = args.encryptAllData; 582 this.useEncryptEverything_ = args.encryptAllData;
439 583
440 // Whether to display the 'Sync everything' confirmation page or the 584 // Determine whether to display the 'OK, sync everything' confirmation
441 // customize data types page. 585 // dialog or the advanced sync settings dialog.
442 var syncAllDataTypes = args.syncAllDataTypes;
443 this.usePassphrase_ = args.usePassphrase; 586 this.usePassphrase_ = args.usePassphrase;
444 this.keystoreEncryptionEnabled_ = args.keystoreEncryptionEnabled; 587 this.keystoreEncryptionEnabled_ = args.keystoreEncryptionEnabled;
445 if (args.showSyncEverythingPage == false || this.usePassphrase_ || 588 if (args.showSyncEverythingPage == false || this.usePassphrase_ ||
446 syncAllDataTypes == false || args.showPassphrase) { 589 args.syncAllDataTypes == false || args.showPassphrase) {
447 this.showCustomizePage_(args, syncAllDataTypes); 590 var index = args.syncAllDataTypes ?
591 DataTypeSelection.SYNC_EVERYTHING :
592 DataTypeSelection.CHOOSE_WHAT_TO_SYNC;
593 this.showCustomizePage_(args, index);
448 } else { 594 } else {
449 this.showSyncEverythingPage_(); 595 this.showSyncEverythingPage_();
450 } 596 }
451 } 597 }
452 }, 598 },
453 599
454 showSpinner_: function() { 600 showSpinner_: function() {
455 this.resetPage_('sync-setup-spinner'); 601 this.resetPage_('sync-setup-spinner');
456 $('sync-setup-spinner').hidden = false; 602 $('sync-setup-spinner').hidden = false;
457 }, 603 },
458 604
459 showTimeoutPage_: function() { 605 showTimeoutPage_: function() {
460 this.resetPage_('sync-setup-timeout'); 606 this.resetPage_('sync-setup-timeout');
461 $('sync-setup-timeout').hidden = false; 607 $('sync-setup-timeout').hidden = false;
462 }, 608 },
463 609
464 showSyncEverythingPage_: function() { 610 showSyncEverythingPage_: function() {
465 $('confirm-sync-preferences').hidden = false; 611 $('confirm-sync-preferences').hidden = false;
466 $('customize-sync-preferences').hidden = true; 612 $('customize-sync-preferences').hidden = true;
467 613
468 // Reset the selection to 'Sync everything'. 614 // Reset the selection to 'Sync everything'.
469 $('sync-select-datatypes').selectedIndex = 0; 615 $('sync-select-datatypes').selectedIndex = 0;
470 616
471 // The default state is to sync everything. 617 // The default state is to sync everything.
472 this.setCheckboxesToKeepEverythingSynced_(true); 618 this.setDataTypeCheckboxes_(DataTypeSelection.SYNC_EVERYTHING);
473 619
474 // Encrypt passwords is the default, but don't set it if the previously 620 // Encrypt passwords is the default, but don't set it if the previously
475 // synced account is already set to encrypt everything. 621 // synced account is already set to encrypt everything.
476 if (!this.useEncryptEverything_) 622 if (!this.useEncryptEverything_)
477 $('encrypt-sensitive-option').checked = true; 623 $('encrypt-sensitive-option').checked = true;
478 624
479 // If the account is not synced with a custom passphrase, reset the 625 // If the account is not synced with a custom passphrase, reset the
480 // passphrase radio when switching to the 'Sync everything' page. 626 // passphrase radio when switching to the 'Sync everything' page.
481 if (!this.usePassphrase_) { 627 if (!this.usePassphrase_) {
482 $('google-option').checked = true; 628 $('google-option').checked = true;
483 $('sync-custom-passphrase').hidden = true; 629 $('sync-custom-passphrase').hidden = true;
484 } 630 }
485 631
486 if (!this.useEncryptEverything_ && !this.usePassphrase_) 632 if (!this.useEncryptEverything_ && !this.usePassphrase_)
487 $('basic-encryption-option').checked = true; 633 $('basic-encryption-option').checked = true;
488 634
489 $('confirm-everything-ok').focus(); 635 $('confirm-everything-ok').focus();
490 }, 636 },
491 637
492 /** 638 /**
639 * Reveals the UI for when the user chooses not to sync any data types.
640 * This happens when the user signs in and selects "Sync nothing" in the
641 * advanced sync settings dialog.
642 * @private
643 */
644 showSyncNothingPage_: function() {
645 // Reset the selection to 'Sync nothing'.
646 $('sync-select-datatypes').selectedIndex = 2;
Andrew T Wilson (Slow) 2013/05/14 16:48:27 Consider using something other than '2' here.
Raghu Simha 2013/05/15 02:09:54 Forgot to use the new enum at this spot. Done.
647
648 // Uncheck and disable the individual data type checkboxes.
649 this.checkAllDataTypeCheckboxes_(false);
650 this.setDataTypeCheckboxesEnabled_(false);
651
652 // Hide the encryption section.
653 $('customize-sync-encryption').hidden = true;
654 $('customize-sync-encryption-new').hidden = true;
655 $('sync-custom-passphrase-container').hidden = true;
656 $('sync-existing-passphrase-container').hidden = true;
657
658 // Hide the "use default settings" link.
659 $('use-default-link').hidden = true;
660 },
661
662 /**
493 * Reveals the UI for entering a custom passphrase during initial setup. 663 * Reveals the UI for entering a custom passphrase during initial setup.
494 * This happens if the user has previously enabled a custom passphrase on a 664 * This happens if the user has previously enabled a custom passphrase on a
495 * different machine. 665 * different machine.
496 * @param {Array} args The args that contain the passphrase UI 666 * @param {Array} args The args that contain the passphrase UI
497 * configuration. 667 * configuration.
498 * @private 668 * @private
499 */ 669 */
500 showPassphraseContainer_: function(args) { 670 showPassphraseContainer_: function(args) {
501 // Once we require a passphrase, we prevent the user from returning to 671 // Once we require a passphrase, we prevent the user from returning to
502 // the Sync Everything pane. 672 // the Sync Everything pane.
(...skipping 18 matching lines...) Expand all
521 // Warn the user about their incorrect passphrase if we need a passphrase 691 // Warn the user about their incorrect passphrase if we need a passphrase
522 // and the passphrase field is non-empty (meaning they tried to set it 692 // and the passphrase field is non-empty (meaning they tried to set it
523 // previously but failed). 693 // previously but failed).
524 $('incorrect-passphrase').hidden = 694 $('incorrect-passphrase').hidden =
525 !(args.usePassphrase && args.passphraseFailed); 695 !(args.usePassphrase && args.passphraseFailed);
526 696
527 $('sync-passphrase-warning').hidden = false; 697 $('sync-passphrase-warning').hidden = false;
528 $('passphrase').focus(); 698 $('passphrase').focus();
529 }, 699 },
530 700
531 /** @private */ 701 /**
532 showCustomizePage_: function(args, syncEverything) { 702 * Displays the advanced sync setting dialog, and pre-selects either the
703 * "Sync everything" or the "Choose what to sync" drop-down menu item.
704 * @param {cr.DataTypeSelection} index Index of item to pre-select.
705 * @private
706 */
707 showCustomizePage_: function(args, index) {
533 $('confirm-sync-preferences').hidden = true; 708 $('confirm-sync-preferences').hidden = true;
534 $('customize-sync-preferences').hidden = false; 709 $('customize-sync-preferences').hidden = false;
535 710
536 $('sync-custom-passphrase-container').hidden = false; 711 $('sync-custom-passphrase-container').hidden = false;
537 712
538 if (this.keystoreEncryptionEnabled_) { 713 if (this.keystoreEncryptionEnabled_) {
539 $('customize-sync-encryption').hidden = true; 714 $('customize-sync-encryption').hidden = true;
540 $('sync-custom-passphrase-options').hidden = true; 715 $('sync-custom-passphrase-options').hidden = true;
541 $('sync-new-encryption-section-container').hidden = false; 716 $('sync-new-encryption-section-container').hidden = false;
542 $('customize-sync-encryption-new').hidden = false; 717 $('customize-sync-encryption-new').hidden = false;
543 } else { 718 } else {
544 $('customize-sync-encryption').hidden = false; 719 $('customize-sync-encryption').hidden = false;
545 $('sync-custom-passphrase-options').hidden = false; 720 $('sync-custom-passphrase-options').hidden = false;
546 $('customize-sync-encryption-new').hidden = true; 721 $('customize-sync-encryption-new').hidden = true;
547 } 722 }
548 723
549 $('sync-existing-passphrase-container').hidden = true; 724 $('sync-existing-passphrase-container').hidden = true;
550 725
551 // If the user has selected the 'Customize' page on initial set up, it's
552 // likely he intends to change the data types. Select the
553 // 'Choose data types' option in this case.
554 var index = syncEverything ? 0 : 1;
555 $('sync-select-datatypes').selectedIndex = index; 726 $('sync-select-datatypes').selectedIndex = index;
556 this.setDataTypeCheckboxesEnabled_(!syncEverything); 727 this.setDataTypeCheckboxesEnabled_(
728 index == DataTypeSelection.CHOOSE_WHAT_TO_SYNC);
557 729
558 // The passphrase input may need to take over focus from the OK button, so 730 // The passphrase input may need to take over focus from the OK button, so
559 // set focus before that logic. 731 // set focus before that logic.
560 $('choose-datatypes-ok').focus(); 732 $('choose-datatypes-ok').focus();
561 733
562 if (args && args.showPassphrase) { 734 if (args && args.showPassphrase) {
563 this.showPassphraseContainer_(args); 735 this.showPassphraseContainer_(args);
564 } else { 736 } else {
565 // We only show the 'Use Default' link if we're not prompting for an 737 // We only show the 'Use Default' link if we're not prompting for an
566 // existing passphrase. 738 // existing passphrase.
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after
1020 1192
1021 SyncSetupOverlay.getLoginPasswd = function() { 1193 SyncSetupOverlay.getLoginPasswd = function() {
1022 return SyncSetupOverlay.getInstance().getLoginPasswd_(); 1194 return SyncSetupOverlay.getInstance().getLoginPasswd_();
1023 }; 1195 };
1024 1196
1025 SyncSetupOverlay.getSignInButton = function() { 1197 SyncSetupOverlay.getSignInButton = function() {
1026 return SyncSetupOverlay.getInstance().getSignInButton_(); 1198 return SyncSetupOverlay.getInstance().getSignInButton_();
1027 }; 1199 };
1028 1200
1029 // These methods are for general consumption. 1201 // These methods are for general consumption.
1202 SyncSetupOverlay.closeOverlay = function() {
1203 SyncSetupOverlay.getInstance().closeOverlay_();
1204 };
1205
1030 SyncSetupOverlay.showErrorUI = function() { 1206 SyncSetupOverlay.showErrorUI = function() {
1031 SyncSetupOverlay.getInstance().showErrorUI_(); 1207 SyncSetupOverlay.getInstance().showErrorUI_();
1032 }; 1208 };
1033 1209
1034 SyncSetupOverlay.showSetupUI = function() { 1210 SyncSetupOverlay.showSetupUI = function() {
1035 SyncSetupOverlay.getInstance().showSetupUI_(); 1211 SyncSetupOverlay.getInstance().showSetupUI_();
1036 }; 1212 };
1037 1213
1038 SyncSetupOverlay.startSignIn = function() { 1214 SyncSetupOverlay.startSignIn = function() {
1039 SyncSetupOverlay.getInstance().startSignIn_(); 1215 SyncSetupOverlay.getInstance().startSignIn_();
(...skipping 21 matching lines...) Expand all
1061 1237
1062 SyncSetupOverlay.showStopSyncingUI = function() { 1238 SyncSetupOverlay.showStopSyncingUI = function() {
1063 SyncSetupOverlay.getInstance().showStopSyncingUI_(); 1239 SyncSetupOverlay.getInstance().showStopSyncingUI_();
1064 }; 1240 };
1065 1241
1066 // Export 1242 // Export
1067 return { 1243 return {
1068 SyncSetupOverlay: SyncSetupOverlay 1244 SyncSetupOverlay: SyncSetupOverlay
1069 }; 1245 };
1070 }); 1246 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/sync_setup_overlay.html ('k') | chrome/browser/signin/signin_tracker_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698