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

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: Rebase 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 that maps the sync data type checkbox names to their checked
44 // state. Initialized when the advanced settings dialog is first brought up,
45 // updated any time a box is checked / unchecked, and reset when the dialog is
46 // closed. Used to restore checkbox state while switching between the options
47 // in the main drop-down menu. All checkboxes are checked and disabled when
48 // the "Sync everything" menu-item is selected, and unchecked and disabled
49 // when "Sync nothing" is selected. When "Choose what to sync" is selected,
50 // the boxes are restored to their most recent checked state from this cache.
51 var dataTypeBoxes_ = {};
52
53 /**
54 * The user's selection in the synced data type drop-down menu, as an index.
55 * @enum {number}
56 * @const
57 */
58 var DataTypeSelection = {
59 SYNC_EVERYTHING: 0,
60 CHOOSE_WHAT_TO_SYNC: 1,
61 SYNC_NOTHING: 2
62 };
63
38 /** 64 /**
39 * SyncSetupOverlay class 65 * SyncSetupOverlay class
40 * Encapsulated handling of the 'Sync Setup' overlay page. 66 * Encapsulated handling of the 'Sync Setup' overlay page.
41 * @class 67 * @class
42 */ 68 */
43 function SyncSetupOverlay() { 69 function SyncSetupOverlay() {
44 OptionsPage.call(this, 'syncSetup', 70 OptionsPage.call(this, 'syncSetup',
45 loadTimeData.getString('syncSetupOverlayTabTitle'), 71 loadTimeData.getString('syncSetupOverlayTabTitle'),
46 'sync-setup-overlay'); 72 'sync-setup-overlay');
47 } 73 }
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 self.closeOverlay_(); 114 self.closeOverlay_();
89 }; 115 };
90 $('different-email').innerHTML = loadTimeData.getString('differentEmail'); 116 $('different-email').innerHTML = loadTimeData.getString('differentEmail');
91 }, 117 },
92 118
93 showOverlay_: function() { 119 showOverlay_: function() {
94 OptionsPage.navigateToPage('syncSetup'); 120 OptionsPage.navigateToPage('syncSetup');
95 }, 121 },
96 122
97 closeOverlay_: function() { 123 closeOverlay_: function() {
124 this.syncConfigureArgs_ = null;
125 this.dataTypeBoxes_ = {};
98 OptionsPage.closeOverlay(); 126 OptionsPage.closeOverlay();
99 }, 127 },
100 128
101 /** @override */ 129 /** @override */
102 didShowPage: function() { 130 didShowPage: function() {
103 chrome.send('SyncSetupShowSetupUI'); 131 chrome.send('SyncSetupShowSetupUI');
104 }, 132 },
105 133
106 /** @override */ 134 /** @override */
107 didClosePage: function() { 135 didClosePage: function() {
(...skipping 30 matching lines...) Expand all
138 onPassphraseRadioChanged_: function() { 166 onPassphraseRadioChanged_: function() {
139 var visible = this.getPassphraseRadioCheckedValue_() == 'explicit'; 167 var visible = this.getPassphraseRadioCheckedValue_() == 'explicit';
140 $('sync-custom-passphrase').hidden = !visible; 168 $('sync-custom-passphrase').hidden = !visible;
141 }, 169 },
142 170
143 onEncryptionRadioChanged_: function() { 171 onEncryptionRadioChanged_: function() {
144 var visible = $('full-encryption-option').checked; 172 var visible = $('full-encryption-option').checked;
145 $('sync-custom-passphrase').hidden = !visible; 173 $('sync-custom-passphrase').hidden = !visible;
146 }, 174 },
147 175
148 checkAllDataTypeCheckboxes_: function() { 176 /**
149 // Only check the visible ones (since there's no way to uncheck 177 * Sets the checked state of the individual sync data type checkboxes in the
150 // the invisible ones). 178 * advanced sync settings dialog.
179 * @param {boolean} value True for checked, false for unchecked.
180 * @private
181 */
182 checkAllDataTypeCheckboxes_: function(value) {
183 // Only check / uncheck the visible ones (since there's no way to uncheck
184 // / check the invisible ones).
151 var checkboxes = $('choose-data-types-body').querySelectorAll( 185 var checkboxes = $('choose-data-types-body').querySelectorAll(
152 '.sync-type-checkbox:not([hidden]) input'); 186 '.sync-type-checkbox:not([hidden]) input');
153 for (var i = 0; i < checkboxes.length; i++) { 187 for (var i = 0; i < checkboxes.length; i++) {
154 checkboxes[i].checked = true; 188 checkboxes[i].checked = value;
155 } 189 }
156 }, 190 },
157 191
192 /**
193 * Restores the checked states of the sync data type checkboxes in the
194 * advanced sync settings dialog. Called when "Choose what to sync" is
195 * selected. Required because all the checkboxes are checked when
196 * "Sync everything" is selected, and unchecked when "Sync nothing" is
197 * selected. Note: We only restore checkboxes for data types that are
198 * actually visible and whose old values are found in the cache, since it's
199 * possible for some data types to not be registered, and therefore, their
200 * checkboxes remain hidden, and never get cached.
201 * @private
202 */
203 restoreDataTypeCheckboxes_: function() {
204 for (dataType in dataTypeBoxes_) {
205 $(dataType).checked = dataTypeBoxes_[dataType];
206 }
207 },
208
209 /**
210 * Enables / grays out the sync data type checkboxes in the advanced
211 * settings dialog.
212 * @param {boolean} enabled True for enabled, false for grayed out.
213 * @private
214 */
158 setDataTypeCheckboxesEnabled_: function(enabled) { 215 setDataTypeCheckboxesEnabled_: function(enabled) {
159 var checkboxes = $('choose-data-types-body').querySelectorAll('input'); 216 var checkboxes = $('choose-data-types-body').querySelectorAll('input');
160 for (var i = 0; i < checkboxes.length; i++) { 217 for (var i = 0; i < checkboxes.length; i++) {
161 checkboxes[i].disabled = !enabled; 218 checkboxes[i].disabled = !enabled;
162 } 219 }
163 }, 220 },
164 221
165 setCheckboxesToKeepEverythingSynced_: function(value) { 222 /**
166 this.setDataTypeCheckboxesEnabled_(!value); 223 * Sets the state of the sync data type checkboxes based on whether "Sync
167 if (value) 224 * everything", "Choose what to sync", or "Sync nothing" are selected in the
168 this.checkAllDataTypeCheckboxes_(); 225 * drop-down menu of the advanced settings dialog.
226 * @param {cr.DataTypeSelection} selectedIndex Index of user's selection.
227 * @private
228 */
229 setDataTypeCheckboxes_: function(selectedIndex) {
230 if (selectedIndex == DataTypeSelection.CHOOSE_WHAT_TO_SYNC) {
231 this.setDataTypeCheckboxesEnabled_(true);
232 this.restoreDataTypeCheckboxes_();
233 } else {
234 this.setDataTypeCheckboxesEnabled_(false);
235 this.checkAllDataTypeCheckboxes_(selectedIndex ==
236 DataTypeSelection.SYNC_EVERYTHING);
237 }
169 }, 238 },
170 239
171 // Returns true if none of the visible checkboxes are checked. 240 // Returns true if none of the visible checkboxes are checked.
172 noDataTypesChecked_: function() { 241 noDataTypesChecked_: function() {
173 var query = '.sync-type-checkbox:not([hidden]) input:checked'; 242 var query = '.sync-type-checkbox:not([hidden]) input:checked';
174 var checkboxes = $('choose-data-types-body').querySelectorAll(query); 243 var checkboxes = $('choose-data-types-body').querySelectorAll(query);
175 return checkboxes.length == 0; 244 return checkboxes.length == 0;
176 }, 245 },
177 246
178 checkPassphraseMatch_: function() { 247 checkPassphraseMatch_: function() {
(...skipping 22 matching lines...) Expand all
201 return false; 270 return false;
202 } 271 }
203 272
204 return true; 273 return true;
205 }, 274 },
206 275
207 sendConfiguration_: function() { 276 sendConfiguration_: function() {
208 // Trying to submit, so hide previous errors. 277 // Trying to submit, so hide previous errors.
209 $('error-text').hidden = true; 278 $('error-text').hidden = true;
210 279
211 var syncAll = $('sync-select-datatypes').selectedIndex == 0; 280 var chooseWhatToSync = $('sync-select-datatypes').selectedIndex ==
212 if (!syncAll && this.noDataTypesChecked_()) { 281 DataTypeSelection.CHOOSE_WHAT_TO_SYNC;
282 if (chooseWhatToSync && this.noDataTypesChecked_()) {
213 $('error-text').hidden = false; 283 $('error-text').hidden = false;
214 return; 284 return;
215 } 285 }
216 286
217 var encryptAllData = this.getEncryptionRadioCheckedValue_() == 'all'; 287 var encryptAllData = this.getEncryptionRadioCheckedValue_() == 'all';
218 if (!encryptAllData && 288 if (!encryptAllData &&
219 $('full-encryption-option').checked && 289 $('full-encryption-option').checked &&
220 this.keystoreEncryptionEnabled_) { 290 this.keystoreEncryptionEnabled_) {
221 encryptAllData = true; 291 encryptAllData = true;
222 } 292 }
(...skipping 27 matching lines...) Expand all
250 usePassphrase = false; 320 usePassphrase = false;
251 } 321 }
252 322
253 // Don't allow the user to tweak the settings once we send the 323 // Don't allow the user to tweak the settings once we send the
254 // configuration to the backend. 324 // configuration to the backend.
255 this.setInputElementsDisabledState_(true); 325 this.setInputElementsDisabledState_(true);
256 this.animateDisableLink_($('use-default-link'), true, null); 326 this.animateDisableLink_($('use-default-link'), true, null);
257 327
258 // These values need to be kept in sync with where they are read in 328 // These values need to be kept in sync with where they are read in
259 // SyncSetupFlow::GetDataTypeChoiceData(). 329 // SyncSetupFlow::GetDataTypeChoiceData().
330 var syncAll = $('sync-select-datatypes').selectedIndex ==
331 DataTypeSelection.SYNC_EVERYTHING;
332 var syncNothing = $('sync-select-datatypes').selectedIndex ==
333 DataTypeSelection.SYNC_NOTHING;
260 var result = JSON.stringify({ 334 var result = JSON.stringify({
261 'syncAllDataTypes': syncAll, 335 'syncAllDataTypes': syncAll,
336 'syncNothing': syncNothing,
262 'bookmarksSynced': syncAll || $('bookmarks-checkbox').checked, 337 'bookmarksSynced': syncAll || $('bookmarks-checkbox').checked,
263 'preferencesSynced': syncAll || $('preferences-checkbox').checked, 338 'preferencesSynced': syncAll || $('preferences-checkbox').checked,
264 'themesSynced': syncAll || $('themes-checkbox').checked, 339 'themesSynced': syncAll || $('themes-checkbox').checked,
265 'passwordsSynced': syncAll || $('passwords-checkbox').checked, 340 'passwordsSynced': syncAll || $('passwords-checkbox').checked,
266 'autofillSynced': syncAll || $('autofill-checkbox').checked, 341 'autofillSynced': syncAll || $('autofill-checkbox').checked,
267 'extensionsSynced': syncAll || $('extensions-checkbox').checked, 342 'extensionsSynced': syncAll || $('extensions-checkbox').checked,
268 'typedUrlsSynced': syncAll || $('typed-urls-checkbox').checked, 343 'typedUrlsSynced': syncAll || $('typed-urls-checkbox').checked,
269 'appsSynced': syncAll || $('apps-checkbox').checked, 344 'appsSynced': syncAll || $('apps-checkbox').checked,
270 'tabsSynced': syncAll || $('tabs-checkbox').checked, 345 'tabsSynced': syncAll || $('tabs-checkbox').checked,
271 'encryptAllData': encryptAllData, 346 'encryptAllData': encryptAllData,
(...skipping 14 matching lines...) Expand all
286 */ 361 */
287 setInputElementsDisabledState_: function(disabled) { 362 setInputElementsDisabledState_: function(disabled) {
288 var configureElements = 363 var configureElements =
289 $('customize-sync-preferences').querySelectorAll('input'); 364 $('customize-sync-preferences').querySelectorAll('input');
290 for (var i = 0; i < configureElements.length; i++) 365 for (var i = 0; i < configureElements.length; i++)
291 configureElements[i].disabled = disabled; 366 configureElements[i].disabled = disabled;
292 $('sync-select-datatypes').disabled = disabled; 367 $('sync-select-datatypes').disabled = disabled;
293 368
294 var self = this; 369 var self = this;
295 this.animateDisableLink_($('customize-link'), disabled, function() { 370 this.animateDisableLink_($('customize-link'), disabled, function() {
296 self.showCustomizePage_(null, true); 371 self.showCustomizePage_(null, DataTypeSelection.SYNC_EVERYTHING);
297 }); 372 });
298 }, 373 },
299 374
300 /** 375 /**
301 * Animate a link being enabled/disabled. The link is hidden by animating 376 * 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, 377 * its opacity, but to ensure the user doesn't click it during that time,
303 * its onclick handler is changed to null as well. 378 * its onclick handler is changed to null as well.
304 * @param {HTMLElement} elt The anchor element to enable/disable. 379 * @param {HTMLElement} elt The anchor element to enable/disable.
305 * @param {boolean} disabled True if the link should be disabled. 380 * @param {boolean} disabled True if the link should be disabled.
306 * @param {function} enabledFunction The onclick handler when the link is 381 * @param {function} enabledFunction The onclick handler when the link is
(...skipping 11 matching lines...) Expand all
318 elt.classList.remove('transparent'); 393 elt.classList.remove('transparent');
319 elt.hidden = true; 394 elt.hidden = true;
320 }); 395 });
321 } else { 396 } else {
322 elt.hidden = false; 397 elt.hidden = false;
323 elt.onclick = enabledFunction; 398 elt.onclick = enabledFunction;
324 } 399 }
325 }, 400 },
326 401
327 /** 402 /**
328 * Shows or hides the Sync data type checkboxes in the advanced 403 * Shows or hides the sync data type checkboxes in the advanced sync
329 * configuration screen. 404 * settings dialog. Also initializes |dataTypeBoxes_| with their values, and
405 * makes their onclick handlers update |dataTypeBoxes_|.
330 * @param {Object} args The configuration data used to show/hide UI. 406 * @param {Object} args The configuration data used to show/hide UI.
331 * @private 407 * @private
332 */ 408 */
333 setChooseDataTypesCheckboxes_: function(args) { 409 setChooseDataTypesCheckboxes_: function(args) {
334 var datatypeSelect = $('sync-select-datatypes'); 410 var datatypeSelect = $('sync-select-datatypes');
335 datatypeSelect.selectedIndex = args.syncAllDataTypes ? 0 : 1; 411 datatypeSelect.selectedIndex = args.syncAllDataTypes ?
412 DataTypeSelection.SYNC_EVERYTHING :
413 DataTypeSelection.CHOOSE_WHAT_TO_SYNC;
336 414
337 $('bookmarks-checkbox').checked = args.bookmarksSynced; 415 $('bookmarks-checkbox').checked = args.bookmarksSynced;
416 dataTypeBoxes_['bookmarks-checkbox'] = args.bookmarksSynced;
417 $('bookmarks-checkbox').onclick = this.handleDataTypeClick_;
418
338 $('preferences-checkbox').checked = args.preferencesSynced; 419 $('preferences-checkbox').checked = args.preferencesSynced;
420 dataTypeBoxes_['preferences-checkbox'] = args.preferencesSynced;
421 $('preferences-checkbox').onclick = this.handleDataTypeClick_;
422
339 $('themes-checkbox').checked = args.themesSynced; 423 $('themes-checkbox').checked = args.themesSynced;
424 dataTypeBoxes_['themes-checkbox'] = args.themesSynced;
425 $('themes-checkbox').onclick = this.handleDataTypeClick_;
340 426
341 if (args.passwordsRegistered) { 427 if (args.passwordsRegistered) {
342 $('passwords-checkbox').checked = args.passwordsSynced; 428 $('passwords-checkbox').checked = args.passwordsSynced;
429 dataTypeBoxes_['passwords-checkbox'] = args.passwordsSynced;
430 $('passwords-checkbox').onclick = this.handleDataTypeClick_;
343 $('passwords-item').hidden = false; 431 $('passwords-item').hidden = false;
344 } else { 432 } else {
345 $('passwords-item').hidden = true; 433 $('passwords-item').hidden = true;
346 } 434 }
347 if (args.autofillRegistered) { 435 if (args.autofillRegistered) {
348 $('autofill-checkbox').checked = args.autofillSynced; 436 $('autofill-checkbox').checked = args.autofillSynced;
437 dataTypeBoxes_['autofill-checkbox'] = args.autofillSynced;
438 $('autofill-checkbox').onclick = this.handleDataTypeClick_;
349 $('autofill-item').hidden = false; 439 $('autofill-item').hidden = false;
350 } else { 440 } else {
351 $('autofill-item').hidden = true; 441 $('autofill-item').hidden = true;
352 } 442 }
353 if (args.extensionsRegistered) { 443 if (args.extensionsRegistered) {
354 $('extensions-checkbox').checked = args.extensionsSynced; 444 $('extensions-checkbox').checked = args.extensionsSynced;
445 dataTypeBoxes_['extensions-checkbox'] = args.extensionsSynced;
446 $('extensions-checkbox').onclick = this.handleDataTypeClick_;
355 $('extensions-item').hidden = false; 447 $('extensions-item').hidden = false;
356 } else { 448 } else {
357 $('extensions-item').hidden = true; 449 $('extensions-item').hidden = true;
358 } 450 }
359 if (args.typedUrlsRegistered) { 451 if (args.typedUrlsRegistered) {
360 $('typed-urls-checkbox').checked = args.typedUrlsSynced; 452 $('typed-urls-checkbox').checked = args.typedUrlsSynced;
453 dataTypeBoxes_['typed-urls-checkbox'] = args.typedUrlsSynced;
454 $('typed-urls-checkbox').onclick = this.handleDataTypeClick_;
361 $('omnibox-item').hidden = false; 455 $('omnibox-item').hidden = false;
362 } else { 456 } else {
363 $('omnibox-item').hidden = true; 457 $('omnibox-item').hidden = true;
364 } 458 }
365 if (args.appsRegistered) { 459 if (args.appsRegistered) {
366 $('apps-checkbox').checked = args.appsSynced; 460 $('apps-checkbox').checked = args.appsSynced;
461 dataTypeBoxes_['apps-checkbox'] = args.appsSynced;
462 $('apps-checkbox').onclick = this.handleDataTypeClick_;
367 $('apps-item').hidden = false; 463 $('apps-item').hidden = false;
368 } else { 464 } else {
369 $('apps-item').hidden = true; 465 $('apps-item').hidden = true;
370 } 466 }
371 if (args.tabsRegistered) { 467 if (args.tabsRegistered) {
372 $('tabs-checkbox').checked = args.tabsSynced; 468 $('tabs-checkbox').checked = args.tabsSynced;
469 dataTypeBoxes_['tabs-checkbox'] = args.tabsSynced;
470 $('tabs-checkbox').onclick = this.handleDataTypeClick_;
373 $('tabs-item').hidden = false; 471 $('tabs-item').hidden = false;
374 } else { 472 } else {
375 $('tabs-item').hidden = true; 473 $('tabs-item').hidden = true;
376 } 474 }
377 475
378 this.setCheckboxesToKeepEverythingSynced_(args.syncAllDataTypes); 476 this.setDataTypeCheckboxes_(datatypeSelect.selectedIndex);
477 },
478
479 /**
480 * Updates the cached values of the sync data type checkboxes stored in
481 * |dataTypeBoxes_|. Used as an onclick handler for each data type checkbox.
482 * @private
483 */
484 handleDataTypeClick_: function() {
485 dataTypeBoxes_[this.id] = this.checked;
379 }, 486 },
380 487
381 setEncryptionRadios_: function(args) { 488 setEncryptionRadios_: function(args) {
382 if (args.encryptAllData) { 489 if (args.encryptAllData) {
383 $('encrypt-all-option').checked = true; 490 $('encrypt-all-option').checked = true;
384 this.disableEncryptionRadioGroup_(); 491 this.disableEncryptionRadioGroup_();
385 } else { 492 } else {
386 $('encrypt-sensitive-option').checked = true; 493 $('encrypt-sensitive-option').checked = true;
387 } 494 }
388 495
(...skipping 21 matching lines...) Expand all
410 517
411 setCheckboxesAndErrors_: function(args) { 518 setCheckboxesAndErrors_: function(args) {
412 this.setChooseDataTypesCheckboxes_(args); 519 this.setChooseDataTypesCheckboxes_(args);
413 this.setEncryptionRadios_(args); 520 this.setEncryptionRadios_(args);
414 this.setPassphraseRadios_(args); 521 this.setPassphraseRadios_(args);
415 }, 522 },
416 523
417 showConfigure_: function(args) { 524 showConfigure_: function(args) {
418 var datatypeSelect = $('sync-select-datatypes'); 525 var datatypeSelect = $('sync-select-datatypes');
419 var self = this; 526 var self = this;
527
528 // Cache the sync config args so they can be reused when we transition
529 // between the drop-down menu items in the advanced settings dialog.
530 if (args)
531 this.syncConfigureArgs_ = args;
532
533 // Once the advanced sync settings dialog is visible, we transition
534 // between its drop-down menu items as follows:
535 // "Sync everything": Show encryption and passphrase sections, and disable
536 // and check all data type checkboxes.
537 // "Sync everything": Hide encryption and passphrase sections, and disable
538 // and uncheck all data type checkboxes.
539 // "Choose what to sync": Show encryption and passphrase sections, enable
540 // data type checkboxes, and restore their checked state to the last time
541 // the "Choose what to sync" was selected while the dialog was still up.
420 datatypeSelect.onchange = function() { 542 datatypeSelect.onchange = function() {
421 var syncAll = this.selectedIndex == 0; 543 if (this.selectedIndex == DataTypeSelection.SYNC_NOTHING) {
422 self.setCheckboxesToKeepEverythingSynced_(syncAll); 544 self.showSyncNothingPage_();
545 } else {
546 self.showCustomizePage_(self.syncConfigureArgs_, this.selectedIndex);
547 if (this.selectedIndex == DataTypeSelection.SYNC_EVERYTHING)
548 self.checkAllDataTypeCheckboxes_(true);
549 else
550 self.restoreDataTypeCheckboxes_();
551 }
423 }; 552 };
424 553
425 this.resetPage_('sync-setup-configure'); 554 this.resetPage_('sync-setup-configure');
426 $('sync-setup-configure').hidden = false; 555 $('sync-setup-configure').hidden = false;
427 556
428 // onsubmit is changed when submitting a passphrase. Reset it to its 557 // onsubmit is changed when submitting a passphrase. Reset it to its
429 // default. 558 // default.
430 $('choose-data-types-form').onsubmit = function() { 559 $('choose-data-types-form').onsubmit = function() {
431 self.sendConfiguration_(); 560 self.sendConfiguration_();
432 return false; 561 return false;
433 }; 562 };
434 563
435 if (args) { 564 if (args) {
436 this.setCheckboxesAndErrors_(args); 565 this.setCheckboxesAndErrors_(args);
437 566
438 this.useEncryptEverything_ = args.encryptAllData; 567 this.useEncryptEverything_ = args.encryptAllData;
439 568
440 // Whether to display the 'Sync everything' confirmation page or the 569 // Determine whether to display the 'OK, sync everything' confirmation
441 // customize data types page. 570 // dialog or the advanced sync settings dialog.
442 var syncAllDataTypes = args.syncAllDataTypes;
443 this.usePassphrase_ = args.usePassphrase; 571 this.usePassphrase_ = args.usePassphrase;
444 this.keystoreEncryptionEnabled_ = args.keystoreEncryptionEnabled; 572 this.keystoreEncryptionEnabled_ = args.keystoreEncryptionEnabled;
445 if (args.showSyncEverythingPage == false || this.usePassphrase_ || 573 if (args.showSyncEverythingPage == false || this.usePassphrase_ ||
446 syncAllDataTypes == false || args.showPassphrase) { 574 args.syncAllDataTypes == false || args.showPassphrase) {
447 this.showCustomizePage_(args, syncAllDataTypes); 575 var index = args.syncAllDataTypes ?
576 DataTypeSelection.SYNC_EVERYTHING :
577 DataTypeSelection.CHOOSE_WHAT_TO_SYNC;
578 this.showCustomizePage_(args, index);
448 } else { 579 } else {
449 this.showSyncEverythingPage_(); 580 this.showSyncEverythingPage_();
450 } 581 }
451 } 582 }
452 }, 583 },
453 584
454 showSpinner_: function() { 585 showSpinner_: function() {
455 this.resetPage_('sync-setup-spinner'); 586 this.resetPage_('sync-setup-spinner');
456 $('sync-setup-spinner').hidden = false; 587 $('sync-setup-spinner').hidden = false;
457 }, 588 },
458 589
459 showTimeoutPage_: function() { 590 showTimeoutPage_: function() {
460 this.resetPage_('sync-setup-timeout'); 591 this.resetPage_('sync-setup-timeout');
461 $('sync-setup-timeout').hidden = false; 592 $('sync-setup-timeout').hidden = false;
462 }, 593 },
463 594
464 showSyncEverythingPage_: function() { 595 showSyncEverythingPage_: function() {
465 $('confirm-sync-preferences').hidden = false; 596 $('confirm-sync-preferences').hidden = false;
466 $('customize-sync-preferences').hidden = true; 597 $('customize-sync-preferences').hidden = true;
467 598
468 // Reset the selection to 'Sync everything'. 599 // Reset the selection to 'Sync everything'.
469 $('sync-select-datatypes').selectedIndex = 0; 600 $('sync-select-datatypes').selectedIndex = 0;
470 601
471 // The default state is to sync everything. 602 // The default state is to sync everything.
472 this.setCheckboxesToKeepEverythingSynced_(true); 603 this.setDataTypeCheckboxes_(DataTypeSelection.SYNC_EVERYTHING);
473 604
474 // Encrypt passwords is the default, but don't set it if the previously 605 // Encrypt passwords is the default, but don't set it if the previously
475 // synced account is already set to encrypt everything. 606 // synced account is already set to encrypt everything.
476 if (!this.useEncryptEverything_) 607 if (!this.useEncryptEverything_)
477 $('encrypt-sensitive-option').checked = true; 608 $('encrypt-sensitive-option').checked = true;
478 609
479 // If the account is not synced with a custom passphrase, reset the 610 // If the account is not synced with a custom passphrase, reset the
480 // passphrase radio when switching to the 'Sync everything' page. 611 // passphrase radio when switching to the 'Sync everything' page.
481 if (!this.usePassphrase_) { 612 if (!this.usePassphrase_) {
482 $('google-option').checked = true; 613 $('google-option').checked = true;
483 $('sync-custom-passphrase').hidden = true; 614 $('sync-custom-passphrase').hidden = true;
484 } 615 }
485 616
486 if (!this.useEncryptEverything_ && !this.usePassphrase_) 617 if (!this.useEncryptEverything_ && !this.usePassphrase_)
487 $('basic-encryption-option').checked = true; 618 $('basic-encryption-option').checked = true;
488 619
489 $('confirm-everything-ok').focus(); 620 $('confirm-everything-ok').focus();
490 }, 621 },
491 622
492 /** 623 /**
624 * Reveals the UI for when the user chooses not to sync any data types.
625 * This happens when the user signs in and selects "Sync nothing" in the
626 * advanced sync settings dialog.
627 * @private
628 */
629 showSyncNothingPage_: function() {
630 // Reset the selection to 'Sync nothing'.
631 $('sync-select-datatypes').selectedIndex = DataTypeSelection.SYNC_NOTHING;
632
633 // Uncheck and disable the individual data type checkboxes.
634 this.checkAllDataTypeCheckboxes_(false);
635 this.setDataTypeCheckboxesEnabled_(false);
636
637 // Hide the encryption section.
638 $('customize-sync-encryption').hidden = true;
639 $('customize-sync-encryption-new').hidden = true;
640 $('sync-custom-passphrase-container').hidden = true;
641 $('sync-existing-passphrase-container').hidden = true;
642
643 // Hide the "use default settings" link.
644 $('use-default-link').hidden = true;
645 },
646
647 /**
493 * Reveals the UI for entering a custom passphrase during initial setup. 648 * 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 649 * This happens if the user has previously enabled a custom passphrase on a
495 * different machine. 650 * different machine.
496 * @param {Array} args The args that contain the passphrase UI 651 * @param {Array} args The args that contain the passphrase UI
497 * configuration. 652 * configuration.
498 * @private 653 * @private
499 */ 654 */
500 showPassphraseContainer_: function(args) { 655 showPassphraseContainer_: function(args) {
501 // Once we require a passphrase, we prevent the user from returning to 656 // Once we require a passphrase, we prevent the user from returning to
502 // the Sync Everything pane. 657 // the Sync Everything pane.
(...skipping 18 matching lines...) Expand all
521 // Warn the user about their incorrect passphrase if we need a passphrase 676 // 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 677 // and the passphrase field is non-empty (meaning they tried to set it
523 // previously but failed). 678 // previously but failed).
524 $('incorrect-passphrase').hidden = 679 $('incorrect-passphrase').hidden =
525 !(args.usePassphrase && args.passphraseFailed); 680 !(args.usePassphrase && args.passphraseFailed);
526 681
527 $('sync-passphrase-warning').hidden = false; 682 $('sync-passphrase-warning').hidden = false;
528 $('passphrase').focus(); 683 $('passphrase').focus();
529 }, 684 },
530 685
531 /** @private */ 686 /**
532 showCustomizePage_: function(args, syncEverything) { 687 * Displays the advanced sync setting dialog, and pre-selects either the
688 * "Sync everything" or the "Choose what to sync" drop-down menu item.
689 * @param {cr.DataTypeSelection} index Index of item to pre-select.
690 * @private
691 */
692 showCustomizePage_: function(args, index) {
533 $('confirm-sync-preferences').hidden = true; 693 $('confirm-sync-preferences').hidden = true;
534 $('customize-sync-preferences').hidden = false; 694 $('customize-sync-preferences').hidden = false;
535 695
536 $('sync-custom-passphrase-container').hidden = false; 696 $('sync-custom-passphrase-container').hidden = false;
537 697
538 if (this.keystoreEncryptionEnabled_) { 698 if (this.keystoreEncryptionEnabled_) {
539 $('customize-sync-encryption').hidden = true; 699 $('customize-sync-encryption').hidden = true;
540 $('sync-custom-passphrase-options').hidden = true; 700 $('sync-custom-passphrase-options').hidden = true;
541 $('sync-new-encryption-section-container').hidden = false; 701 $('sync-new-encryption-section-container').hidden = false;
542 $('customize-sync-encryption-new').hidden = false; 702 $('customize-sync-encryption-new').hidden = false;
543 } else { 703 } else {
544 $('customize-sync-encryption').hidden = false; 704 $('customize-sync-encryption').hidden = false;
545 $('sync-custom-passphrase-options').hidden = false; 705 $('sync-custom-passphrase-options').hidden = false;
546 $('customize-sync-encryption-new').hidden = true; 706 $('customize-sync-encryption-new').hidden = true;
547 } 707 }
548 708
549 $('sync-existing-passphrase-container').hidden = true; 709 $('sync-existing-passphrase-container').hidden = true;
550 710
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; 711 $('sync-select-datatypes').selectedIndex = index;
556 this.setDataTypeCheckboxesEnabled_(!syncEverything); 712 this.setDataTypeCheckboxesEnabled_(
713 index == DataTypeSelection.CHOOSE_WHAT_TO_SYNC);
557 714
558 // The passphrase input may need to take over focus from the OK button, so 715 // The passphrase input may need to take over focus from the OK button, so
559 // set focus before that logic. 716 // set focus before that logic.
560 $('choose-datatypes-ok').focus(); 717 $('choose-datatypes-ok').focus();
561 718
562 if (args && args.showPassphrase) { 719 if (args && args.showPassphrase) {
563 this.showPassphraseContainer_(args); 720 this.showPassphraseContainer_(args);
564 } else { 721 } else {
565 // We only show the 'Use Default' link if we're not prompting for an 722 // We only show the 'Use Default' link if we're not prompting for an
566 // existing passphrase. 723 // existing passphrase.
(...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after
1012 1169
1013 SyncSetupOverlay.getLoginPasswd = function() { 1170 SyncSetupOverlay.getLoginPasswd = function() {
1014 return SyncSetupOverlay.getInstance().getLoginPasswd_(); 1171 return SyncSetupOverlay.getInstance().getLoginPasswd_();
1015 }; 1172 };
1016 1173
1017 SyncSetupOverlay.getSignInButton = function() { 1174 SyncSetupOverlay.getSignInButton = function() {
1018 return SyncSetupOverlay.getInstance().getSignInButton_(); 1175 return SyncSetupOverlay.getInstance().getSignInButton_();
1019 }; 1176 };
1020 1177
1021 // These methods are for general consumption. 1178 // These methods are for general consumption.
1179 SyncSetupOverlay.closeOverlay = function() {
1180 SyncSetupOverlay.getInstance().closeOverlay_();
1181 };
1182
1022 SyncSetupOverlay.showErrorUI = function() { 1183 SyncSetupOverlay.showErrorUI = function() {
1023 SyncSetupOverlay.getInstance().showErrorUI_(); 1184 SyncSetupOverlay.getInstance().showErrorUI_();
1024 }; 1185 };
1025 1186
1026 SyncSetupOverlay.showSetupUI = function() { 1187 SyncSetupOverlay.showSetupUI = function() {
1027 SyncSetupOverlay.getInstance().showSetupUI_(); 1188 SyncSetupOverlay.getInstance().showSetupUI_();
1028 }; 1189 };
1029 1190
1030 SyncSetupOverlay.startSignIn = function() { 1191 SyncSetupOverlay.startSignIn = function() {
1031 SyncSetupOverlay.getInstance().startSignIn_(); 1192 SyncSetupOverlay.getInstance().startSignIn_();
(...skipping 17 matching lines...) Expand all
1049 1210
1050 SyncSetupOverlay.showStopSyncingUI = function() { 1211 SyncSetupOverlay.showStopSyncingUI = function() {
1051 SyncSetupOverlay.getInstance().showStopSyncingUI_(); 1212 SyncSetupOverlay.getInstance().showStopSyncingUI_();
1052 }; 1213 };
1053 1214
1054 // Export 1215 // Export
1055 return { 1216 return {
1056 SyncSetupOverlay: SyncSetupOverlay 1217 SyncSetupOverlay: SyncSetupOverlay
1057 }; 1218 };
1058 }); 1219 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/sync_setup_overlay.html ('k') | chrome/browser/sync/profile_sync_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698