| OLD | NEW |
| 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.exportPath('options'); |
| 6 |
| 7 /** |
| 8 * The user's selection in the synced data type drop-down menu, as an index. |
| 9 * @enum {number} |
| 10 * @const |
| 11 */ |
| 12 options.DataTypeSelection = { |
| 13 SYNC_EVERYTHING: 0, |
| 14 CHOOSE_WHAT_TO_SYNC: 1, |
| 15 SYNC_NOTHING: 2 |
| 16 }; |
| 17 |
| 5 cr.define('options', function() { | 18 cr.define('options', function() { |
| 6 /** @const */ var Page = cr.ui.pageManager.Page; | 19 /** @const */ var Page = cr.ui.pageManager.Page; |
| 7 /** @const */ var PageManager = cr.ui.pageManager.PageManager; | 20 /** @const */ var PageManager = cr.ui.pageManager.PageManager; |
| 8 | 21 |
| 9 // True if the synced account uses a custom passphrase. | 22 // True if the synced account uses a custom passphrase. |
| 10 var usePassphrase_ = false; | 23 var usePassphrase_ = false; |
| 11 | 24 |
| 12 // True if the synced account uses 'encrypt everything'. | 25 // True if the synced account uses 'encrypt everything'. |
| 13 var useEncryptEverything_ = false; | 26 var useEncryptEverything_ = false; |
| 14 | 27 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 32 // Initialized when the advanced settings dialog is first brought up, and | 45 // Initialized when the advanced settings dialog is first brought up, and |
| 33 // reset when the dialog is closed. | 46 // reset when the dialog is closed. |
| 34 var dataTypeBoxesDisabled_ = {}; | 47 var dataTypeBoxesDisabled_ = {}; |
| 35 | 48 |
| 36 // Used to determine whether to bring the OK button / passphrase field into | 49 // Used to determine whether to bring the OK button / passphrase field into |
| 37 // focus. | 50 // focus. |
| 38 var confirmPageVisible_ = false; | 51 var confirmPageVisible_ = false; |
| 39 var customizePageVisible_ = false; | 52 var customizePageVisible_ = false; |
| 40 | 53 |
| 41 /** | 54 /** |
| 42 * The user's selection in the synced data type drop-down menu, as an index. | |
| 43 * @enum {number} | |
| 44 * @const | |
| 45 */ | |
| 46 var DataTypeSelection = { | |
| 47 SYNC_EVERYTHING: 0, | |
| 48 CHOOSE_WHAT_TO_SYNC: 1, | |
| 49 SYNC_NOTHING: 2 | |
| 50 }; | |
| 51 | |
| 52 /** | |
| 53 * SyncSetupOverlay class | 55 * SyncSetupOverlay class |
| 54 * Encapsulated handling of the 'Sync Setup' overlay page. | 56 * Encapsulated handling of the 'Sync Setup' overlay page. |
| 55 * @class | 57 * @class |
| 56 */ | 58 */ |
| 57 function SyncSetupOverlay() { | 59 function SyncSetupOverlay() { |
| 58 Page.call(this, 'syncSetup', | 60 Page.call(this, 'syncSetup', |
| 59 loadTimeData.getString('syncSetupOverlayTabTitle'), | 61 loadTimeData.getString('syncSetupOverlayTabTitle'), |
| 60 'sync-setup-overlay'); | 62 'sync-setup-overlay'); |
| 61 } | 63 } |
| 62 | 64 |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 * advanced sync settings dialog. Called when "Choose what to sync" is | 157 * advanced sync settings dialog. Called when "Choose what to sync" is |
| 156 * selected. Required because all the checkboxes are checked when | 158 * selected. Required because all the checkboxes are checked when |
| 157 * "Sync everything" is selected, and unchecked when "Sync nothing" is | 159 * "Sync everything" is selected, and unchecked when "Sync nothing" is |
| 158 * selected. Note: We only restore checkboxes for data types that are | 160 * selected. Note: We only restore checkboxes for data types that are |
| 159 * actually visible and whose old values are found in the cache, since it's | 161 * actually visible and whose old values are found in the cache, since it's |
| 160 * possible for some data types to not be registered, and therefore, their | 162 * possible for some data types to not be registered, and therefore, their |
| 161 * checkboxes remain hidden, and never get cached. | 163 * checkboxes remain hidden, and never get cached. |
| 162 * @private | 164 * @private |
| 163 */ | 165 */ |
| 164 restoreDataTypeCheckboxes_: function() { | 166 restoreDataTypeCheckboxes_: function() { |
| 165 for (dataType in dataTypeBoxesChecked_) { | 167 for (var dataType in dataTypeBoxesChecked_) { |
| 166 $(dataType).checked = dataTypeBoxesChecked_[dataType]; | 168 $(dataType).checked = dataTypeBoxesChecked_[dataType]; |
| 167 } | 169 } |
| 168 }, | 170 }, |
| 169 | 171 |
| 170 /** | 172 /** |
| 171 * Enables / grays out the sync data type checkboxes in the advanced | 173 * Enables / grays out the sync data type checkboxes in the advanced |
| 172 * settings dialog. | 174 * settings dialog. |
| 173 * @param {boolean} enabled True for enabled, false for grayed out. | 175 * @param {boolean} enabled True for enabled, false for grayed out. |
| 174 * @private | 176 * @private |
| 175 */ | 177 */ |
| 176 setDataTypeCheckboxesEnabled_: function(enabled) { | 178 setDataTypeCheckboxesEnabled_: function(enabled) { |
| 177 for (dataType in dataTypeBoxesDisabled_) { | 179 for (dataType in dataTypeBoxesDisabled_) { |
| 178 $(dataType).disabled = !enabled || dataTypeBoxesDisabled_[dataType]; | 180 $(dataType).disabled = !enabled || dataTypeBoxesDisabled_[dataType]; |
| 179 } | 181 } |
| 180 }, | 182 }, |
| 181 | 183 |
| 182 /** | 184 /** |
| 183 * Sets the state of the sync data type checkboxes based on whether "Sync | 185 * Sets the state of the sync data type checkboxes based on whether "Sync |
| 184 * everything", "Choose what to sync", or "Sync nothing" are selected in the | 186 * everything", "Choose what to sync", or "Sync nothing" are selected in the |
| 185 * drop-down menu of the advanced settings dialog. | 187 * drop-down menu of the advanced settings dialog. |
| 186 * @param {cr.DataTypeSelection} selectedIndex Index of user's selection. | 188 * @param {options.DataTypeSelection} selectedIndex Index of user's |
| 189 * selection. |
| 187 * @private | 190 * @private |
| 188 */ | 191 */ |
| 189 setDataTypeCheckboxes_: function(selectedIndex) { | 192 setDataTypeCheckboxes_: function(selectedIndex) { |
| 190 if (selectedIndex == DataTypeSelection.CHOOSE_WHAT_TO_SYNC) { | 193 if (selectedIndex == options.DataTypeSelection.CHOOSE_WHAT_TO_SYNC) { |
| 191 this.setDataTypeCheckboxesEnabled_(true); | 194 this.setDataTypeCheckboxesEnabled_(true); |
| 192 this.restoreDataTypeCheckboxes_(); | 195 this.restoreDataTypeCheckboxes_(); |
| 193 } else { | 196 } else { |
| 194 this.setDataTypeCheckboxesEnabled_(false); | 197 this.setDataTypeCheckboxesEnabled_(false); |
| 195 this.checkAllDataTypeCheckboxes_(selectedIndex == | 198 this.checkAllDataTypeCheckboxes_( |
| 196 DataTypeSelection.SYNC_EVERYTHING); | 199 selectedIndex == options.DataTypeSelection.SYNC_EVERYTHING); |
| 197 } | 200 } |
| 198 }, | 201 }, |
| 199 | 202 |
| 200 checkPassphraseMatch_: function() { | 203 checkPassphraseMatch_: function() { |
| 201 var emptyError = $('empty-error'); | 204 var emptyError = $('empty-error'); |
| 202 var mismatchError = $('mismatch-error'); | 205 var mismatchError = $('mismatch-error'); |
| 203 emptyError.hidden = true; | 206 emptyError.hidden = true; |
| 204 mismatchError.hidden = true; | 207 mismatchError.hidden = true; |
| 205 | 208 |
| 206 var f = $('choose-data-types-form'); | 209 var f = $('choose-data-types-form'); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 // Don't allow the user to tweak the settings once we send the | 260 // Don't allow the user to tweak the settings once we send the |
| 258 // configuration to the backend. | 261 // configuration to the backend. |
| 259 this.setInputElementsDisabledState_(true); | 262 this.setInputElementsDisabledState_(true); |
| 260 $('use-default-link').hidden = true; | 263 $('use-default-link').hidden = true; |
| 261 $('use-default-link').disabled = true; | 264 $('use-default-link').disabled = true; |
| 262 $('use-default-link').onclick = null; | 265 $('use-default-link').onclick = null; |
| 263 | 266 |
| 264 // These values need to be kept in sync with where they are read in | 267 // These values need to be kept in sync with where they are read in |
| 265 // SyncSetupFlow::GetDataTypeChoiceData(). | 268 // SyncSetupFlow::GetDataTypeChoiceData(). |
| 266 var syncAll = $('sync-select-datatypes').selectedIndex == | 269 var syncAll = $('sync-select-datatypes').selectedIndex == |
| 267 DataTypeSelection.SYNC_EVERYTHING; | 270 options.DataTypeSelection.SYNC_EVERYTHING; |
| 268 var syncNothing = $('sync-select-datatypes').selectedIndex == | 271 var syncNothing = $('sync-select-datatypes').selectedIndex == |
| 269 DataTypeSelection.SYNC_NOTHING; | 272 options.DataTypeSelection.SYNC_NOTHING; |
| 270 var result = JSON.stringify({ | 273 var result = JSON.stringify({ |
| 271 'syncAllDataTypes': syncAll, | 274 'syncAllDataTypes': syncAll, |
| 272 'syncNothing': syncNothing, | 275 'syncNothing': syncNothing, |
| 273 'bookmarksSynced': syncAll || $('bookmarks-checkbox').checked, | 276 'bookmarksSynced': syncAll || $('bookmarks-checkbox').checked, |
| 274 'preferencesSynced': syncAll || $('preferences-checkbox').checked, | 277 'preferencesSynced': syncAll || $('preferences-checkbox').checked, |
| 275 'themesSynced': syncAll || $('themes-checkbox').checked, | 278 'themesSynced': syncAll || $('themes-checkbox').checked, |
| 276 'passwordsSynced': syncAll || $('passwords-checkbox').checked, | 279 'passwordsSynced': syncAll || $('passwords-checkbox').checked, |
| 277 'autofillSynced': syncAll || $('autofill-checkbox').checked, | 280 'autofillSynced': syncAll || $('autofill-checkbox').checked, |
| 278 'extensionsSynced': syncAll || $('extensions-checkbox').checked, | 281 'extensionsSynced': syncAll || $('extensions-checkbox').checked, |
| 279 'typedUrlsSynced': syncAll || $('typed-urls-checkbox').checked, | 282 'typedUrlsSynced': syncAll || $('typed-urls-checkbox').checked, |
| (...skipping 20 matching lines...) Expand all Loading... |
| 300 var configureElements = | 303 var configureElements = |
| 301 $('customize-sync-preferences').querySelectorAll('input'); | 304 $('customize-sync-preferences').querySelectorAll('input'); |
| 302 for (var i = 0; i < configureElements.length; i++) | 305 for (var i = 0; i < configureElements.length; i++) |
| 303 configureElements[i].disabled = disabled; | 306 configureElements[i].disabled = disabled; |
| 304 $('sync-select-datatypes').disabled = disabled; | 307 $('sync-select-datatypes').disabled = disabled; |
| 305 | 308 |
| 306 $('customize-link').hidden = disabled; | 309 $('customize-link').hidden = disabled; |
| 307 $('customize-link').disabled = disabled; | 310 $('customize-link').disabled = disabled; |
| 308 $('customize-link').onclick = disabled ? null : function() { | 311 $('customize-link').onclick = disabled ? null : function() { |
| 309 SyncSetupOverlay.showCustomizePage(self.syncConfigureArgs_, | 312 SyncSetupOverlay.showCustomizePage(self.syncConfigureArgs_, |
| 310 DataTypeSelection.SYNC_EVERYTHING); | 313 options.DataTypeSelection.SYNC_EVERYTHING); |
| 311 return false; | 314 return false; |
| 312 }; | 315 }; |
| 313 }, | 316 }, |
| 314 | 317 |
| 315 /** | 318 /** |
| 316 * Shows or hides the sync data type checkboxes in the advanced sync | 319 * Shows or hides the sync data type checkboxes in the advanced sync |
| 317 * settings dialog. Also initializes |dataTypeBoxesChecked_| and | 320 * settings dialog. Also initializes |dataTypeBoxesChecked_| and |
| 318 * |dataTypeBoxedDisabled_| with their values, and makes their onclick | 321 * |dataTypeBoxedDisabled_| with their values, and makes their onclick |
| 319 * handlers update |dataTypeBoxesChecked_|. | 322 * handlers update |dataTypeBoxesChecked_|. |
| 320 * @param {Object} args The configuration data used to show/hide UI. | 323 * @param {Object} args The configuration data used to show/hide UI. |
| 321 * @private | 324 * @private |
| 322 */ | 325 */ |
| 323 setChooseDataTypesCheckboxes_: function(args) { | 326 setChooseDataTypesCheckboxes_: function(args) { |
| 324 var datatypeSelect = $('sync-select-datatypes'); | 327 var datatypeSelect = $('sync-select-datatypes'); |
| 325 datatypeSelect.selectedIndex = args.syncAllDataTypes ? | 328 datatypeSelect.selectedIndex = args.syncAllDataTypes ? |
| 326 DataTypeSelection.SYNC_EVERYTHING : | 329 options.DataTypeSelection.SYNC_EVERYTHING : |
| 327 DataTypeSelection.CHOOSE_WHAT_TO_SYNC; | 330 options.DataTypeSelection.CHOOSE_WHAT_TO_SYNC; |
| 328 | 331 |
| 329 $('bookmarks-checkbox').checked = args.bookmarksSynced; | 332 $('bookmarks-checkbox').checked = args.bookmarksSynced; |
| 330 dataTypeBoxesChecked_['bookmarks-checkbox'] = args.bookmarksSynced; | 333 dataTypeBoxesChecked_['bookmarks-checkbox'] = args.bookmarksSynced; |
| 331 dataTypeBoxesDisabled_['bookmarks-checkbox'] = args.bookmarksEnforced; | 334 dataTypeBoxesDisabled_['bookmarks-checkbox'] = args.bookmarksEnforced; |
| 332 $('bookmarks-checkbox').onclick = this.handleDataTypeClick_; | 335 $('bookmarks-checkbox').onclick = this.handleDataTypeClick_; |
| 333 | 336 |
| 334 $('preferences-checkbox').checked = args.preferencesSynced; | 337 $('preferences-checkbox').checked = args.preferencesSynced; |
| 335 dataTypeBoxesChecked_['preferences-checkbox'] = args.preferencesSynced; | 338 dataTypeBoxesChecked_['preferences-checkbox'] = args.preferencesSynced; |
| 336 dataTypeBoxesDisabled_['preferences-checkbox'] = args.preferencesEnforced; | 339 dataTypeBoxesDisabled_['preferences-checkbox'] = args.preferencesEnforced; |
| 337 $('preferences-checkbox').onclick = this.handleDataTypeClick_; | 340 $('preferences-checkbox').onclick = this.handleDataTypeClick_; |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 443 // Once the advanced sync settings dialog is visible, we transition | 446 // Once the advanced sync settings dialog is visible, we transition |
| 444 // between its drop-down menu items as follows: | 447 // between its drop-down menu items as follows: |
| 445 // "Sync everything": Show encryption and passphrase sections, and disable | 448 // "Sync everything": Show encryption and passphrase sections, and disable |
| 446 // and check all data type checkboxes. | 449 // and check all data type checkboxes. |
| 447 // "Sync nothing": Hide encryption and passphrase sections, and disable | 450 // "Sync nothing": Hide encryption and passphrase sections, and disable |
| 448 // and uncheck all data type checkboxes. | 451 // and uncheck all data type checkboxes. |
| 449 // "Choose what to sync": Show encryption and passphrase sections, enable | 452 // "Choose what to sync": Show encryption and passphrase sections, enable |
| 450 // data type checkboxes, and restore their checked state to the last time | 453 // data type checkboxes, and restore their checked state to the last time |
| 451 // the "Choose what to sync" was selected while the dialog was still up. | 454 // the "Choose what to sync" was selected while the dialog was still up. |
| 452 datatypeSelect.onchange = function() { | 455 datatypeSelect.onchange = function() { |
| 453 if (this.selectedIndex == DataTypeSelection.SYNC_NOTHING) { | 456 if (this.selectedIndex == options.DataTypeSelection.SYNC_NOTHING) { |
| 454 self.showSyncNothingPage_(); | 457 self.showSyncNothingPage_(); |
| 455 } else { | 458 } else { |
| 456 self.showCustomizePage_(self.syncConfigureArgs_, this.selectedIndex); | 459 self.showCustomizePage_(self.syncConfigureArgs_, this.selectedIndex); |
| 457 if (this.selectedIndex == DataTypeSelection.SYNC_EVERYTHING) | 460 if (this.selectedIndex == options.DataTypeSelection.SYNC_EVERYTHING) |
| 458 self.checkAllDataTypeCheckboxes_(true); | 461 self.checkAllDataTypeCheckboxes_(true); |
| 459 else | 462 else |
| 460 self.restoreDataTypeCheckboxes_(); | 463 self.restoreDataTypeCheckboxes_(); |
| 461 } | 464 } |
| 462 }; | 465 }; |
| 463 | 466 |
| 464 this.resetPage_('sync-setup-configure'); | 467 this.resetPage_('sync-setup-configure'); |
| 465 $('sync-setup-configure').hidden = false; | 468 $('sync-setup-configure').hidden = false; |
| 466 | 469 |
| 467 // onsubmit is changed when submitting a passphrase. Reset it to its | 470 // onsubmit is changed when submitting a passphrase. Reset it to its |
| 468 // default. | 471 // default. |
| 469 $('choose-data-types-form').onsubmit = function() { | 472 $('choose-data-types-form').onsubmit = function() { |
| 470 self.sendConfiguration_(); | 473 self.sendConfiguration_(); |
| 471 return false; | 474 return false; |
| 472 }; | 475 }; |
| 473 | 476 |
| 474 if (args) { | 477 if (args) { |
| 475 this.setCheckboxesAndErrors_(args); | 478 this.setCheckboxesAndErrors_(args); |
| 476 | 479 |
| 477 this.useEncryptEverything_ = args.encryptAllData; | 480 this.useEncryptEverything_ = args.encryptAllData; |
| 478 | 481 |
| 479 // Determine whether to display the 'OK, sync everything' confirmation | 482 // Determine whether to display the 'OK, sync everything' confirmation |
| 480 // dialog or the advanced sync settings dialog, and assign focus to the | 483 // dialog or the advanced sync settings dialog, and assign focus to the |
| 481 // OK button, or to the passphrase field if a passphrase is required. | 484 // OK button, or to the passphrase field if a passphrase is required. |
| 482 this.usePassphrase_ = args.usePassphrase; | 485 this.usePassphrase_ = args.usePassphrase; |
| 483 if (args.showSyncEverythingPage == false || this.usePassphrase_ || | 486 if (args.showSyncEverythingPage == false || this.usePassphrase_ || |
| 484 args.syncAllDataTypes == false || args.showPassphrase) { | 487 args.syncAllDataTypes == false || args.showPassphrase) { |
| 485 var index = args.syncAllDataTypes ? | 488 var index = args.syncAllDataTypes ? |
| 486 DataTypeSelection.SYNC_EVERYTHING : | 489 options.DataTypeSelection.SYNC_EVERYTHING : |
| 487 DataTypeSelection.CHOOSE_WHAT_TO_SYNC; | 490 options.DataTypeSelection.CHOOSE_WHAT_TO_SYNC; |
| 488 this.showCustomizePage_(args, index); | 491 this.showCustomizePage_(args, index); |
| 489 } else { | 492 } else { |
| 490 this.showSyncEverythingPage_(); | 493 this.showSyncEverythingPage_(); |
| 491 } | 494 } |
| 492 } | 495 } |
| 493 }, | 496 }, |
| 494 | 497 |
| 495 showSpinner_: function() { | 498 showSpinner_: function() { |
| 496 this.resetPage_('sync-setup-spinner'); | 499 this.resetPage_('sync-setup-spinner'); |
| 497 $('sync-setup-spinner').hidden = false; | 500 $('sync-setup-spinner').hidden = false; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 511 this.confirmPageVisible_ = true; | 514 this.confirmPageVisible_ = true; |
| 512 this.customizePageVisible_ = false; | 515 this.customizePageVisible_ = false; |
| 513 | 516 |
| 514 $('confirm-sync-preferences').hidden = false; | 517 $('confirm-sync-preferences').hidden = false; |
| 515 $('customize-sync-preferences').hidden = true; | 518 $('customize-sync-preferences').hidden = true; |
| 516 | 519 |
| 517 // Reset the selection to 'Sync everything'. | 520 // Reset the selection to 'Sync everything'. |
| 518 $('sync-select-datatypes').selectedIndex = 0; | 521 $('sync-select-datatypes').selectedIndex = 0; |
| 519 | 522 |
| 520 // The default state is to sync everything. | 523 // The default state is to sync everything. |
| 521 this.setDataTypeCheckboxes_(DataTypeSelection.SYNC_EVERYTHING); | 524 this.setDataTypeCheckboxes_(options.DataTypeSelection.SYNC_EVERYTHING); |
| 522 | 525 |
| 523 if (!this.usePassphrase_) | 526 if (!this.usePassphrase_) |
| 524 $('sync-custom-passphrase').hidden = true; | 527 $('sync-custom-passphrase').hidden = true; |
| 525 | 528 |
| 526 if (!this.useEncryptEverything_ && !this.usePassphrase_) | 529 if (!this.useEncryptEverything_ && !this.usePassphrase_) |
| 527 $('basic-encryption-option').checked = true; | 530 $('basic-encryption-option').checked = true; |
| 528 | 531 |
| 529 // Give the OK button focus only when the dialog wasn't already visible. | 532 // Give the OK button focus only when the dialog wasn't already visible. |
| 530 if (wasConfirmPageHidden) | 533 if (wasConfirmPageHidden) |
| 531 $('confirm-everything-ok').focus(); | 534 $('confirm-everything-ok').focus(); |
| 532 }, | 535 }, |
| 533 | 536 |
| 534 /** | 537 /** |
| 535 * Reveals the UI for when the user chooses not to sync any data types. | 538 * Reveals the UI for when the user chooses not to sync any data types. |
| 536 * This happens when the user signs in and selects "Sync nothing" in the | 539 * This happens when the user signs in and selects "Sync nothing" in the |
| 537 * advanced sync settings dialog. | 540 * advanced sync settings dialog. |
| 538 * @private | 541 * @private |
| 539 */ | 542 */ |
| 540 showSyncNothingPage_: function() { | 543 showSyncNothingPage_: function() { |
| 541 // Reset the selection to 'Sync nothing'. | 544 // Reset the selection to 'Sync nothing'. |
| 542 $('sync-select-datatypes').selectedIndex = DataTypeSelection.SYNC_NOTHING; | 545 $('sync-select-datatypes').selectedIndex = |
| 546 options.DataTypeSelection.SYNC_NOTHING; |
| 543 | 547 |
| 544 // Uncheck and disable the individual data type checkboxes. | 548 // Uncheck and disable the individual data type checkboxes. |
| 545 this.checkAllDataTypeCheckboxes_(false); | 549 this.checkAllDataTypeCheckboxes_(false); |
| 546 this.setDataTypeCheckboxesEnabled_(false); | 550 this.setDataTypeCheckboxesEnabled_(false); |
| 547 | 551 |
| 548 // Hide the encryption section. | 552 // Hide the encryption section. |
| 549 $('customize-sync-encryption-new').hidden = true; | 553 $('customize-sync-encryption-new').hidden = true; |
| 550 $('sync-custom-passphrase-container').hidden = true; | 554 $('sync-custom-passphrase-container').hidden = true; |
| 551 $('sync-existing-passphrase-container').hidden = true; | 555 $('sync-existing-passphrase-container').hidden = true; |
| 552 | 556 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 592 // previously but failed). | 596 // previously but failed). |
| 593 $('incorrect-passphrase').hidden = | 597 $('incorrect-passphrase').hidden = |
| 594 !(args.usePassphrase && args.passphraseFailed); | 598 !(args.usePassphrase && args.passphraseFailed); |
| 595 | 599 |
| 596 $('sync-passphrase-warning').hidden = false; | 600 $('sync-passphrase-warning').hidden = false; |
| 597 }, | 601 }, |
| 598 | 602 |
| 599 /** | 603 /** |
| 600 * Displays the advanced sync setting dialog, and pre-selects either the | 604 * Displays the advanced sync setting dialog, and pre-selects either the |
| 601 * "Sync everything" or the "Choose what to sync" drop-down menu item. | 605 * "Sync everything" or the "Choose what to sync" drop-down menu item. |
| 602 * @param {cr.DataTypeSelection} index Index of item to pre-select. | 606 * @param {options.DataTypeSelection} index Index of item to pre-select. |
| 603 * @private | 607 * @private |
| 604 */ | 608 */ |
| 605 showCustomizePage_: function(args, index) { | 609 showCustomizePage_: function(args, index) { |
| 606 // Determine whether to bring the OK button field into focus. | 610 // Determine whether to bring the OK button field into focus. |
| 607 var wasCustomizePageHidden = !this.customizePageVisible_; | 611 var wasCustomizePageHidden = !this.customizePageVisible_; |
| 608 this.customizePageVisible_ = true; | 612 this.customizePageVisible_ = true; |
| 609 this.confirmPageVisible_ = false; | 613 this.confirmPageVisible_ = false; |
| 610 | 614 |
| 611 $('confirm-sync-preferences').hidden = true; | 615 $('confirm-sync-preferences').hidden = true; |
| 612 $('customize-sync-preferences').hidden = false; | 616 $('customize-sync-preferences').hidden = false; |
| 613 | 617 |
| 614 $('sync-custom-passphrase-container').hidden = false; | 618 $('sync-custom-passphrase-container').hidden = false; |
| 615 $('sync-new-encryption-section-container').hidden = false; | 619 $('sync-new-encryption-section-container').hidden = false; |
| 616 $('customize-sync-encryption-new').hidden = args.isSupervised; | 620 $('customize-sync-encryption-new').hidden = args.isSupervised; |
| 617 | 621 |
| 618 $('sync-existing-passphrase-container').hidden = true; | 622 $('sync-existing-passphrase-container').hidden = true; |
| 619 | 623 |
| 620 $('sync-select-datatypes').selectedIndex = index; | 624 $('sync-select-datatypes').selectedIndex = index; |
| 621 this.setDataTypeCheckboxesEnabled_( | 625 this.setDataTypeCheckboxesEnabled_( |
| 622 index == DataTypeSelection.CHOOSE_WHAT_TO_SYNC); | 626 index == options.DataTypeSelection.CHOOSE_WHAT_TO_SYNC); |
| 623 | 627 |
| 624 // Give the OK button focus only when the dialog wasn't already visible. | 628 // Give the OK button focus only when the dialog wasn't already visible. |
| 625 if (wasCustomizePageHidden) | 629 if (wasCustomizePageHidden) |
| 626 $('choose-datatypes-ok').focus(); | 630 $('choose-datatypes-ok').focus(); |
| 627 | 631 |
| 628 if (args.showPassphrase) { | 632 if (args.showPassphrase) { |
| 629 this.showPassphraseContainer_(args); | 633 this.showPassphraseContainer_(args); |
| 630 // Give the passphrase field focus only when the dialog wasn't already | 634 // Give the passphrase field focus only when the dialog wasn't already |
| 631 // visible. | 635 // visible. |
| 632 if (wasCustomizePageHidden) | 636 if (wasCustomizePageHidden) |
| 633 $('passphrase').focus(); | 637 $('passphrase').focus(); |
| 634 } else { | 638 } else { |
| 635 // We only show the 'Use Default' link if we're not prompting for an | 639 // We only show the 'Use Default' link if we're not prompting for an |
| 636 // existing passphrase. | 640 // existing passphrase. |
| 637 $('use-default-link').hidden = false; | 641 $('use-default-link').hidden = false; |
| 638 $('use-default-link').disabled = false; | 642 $('use-default-link').disabled = false; |
| 639 $('use-default-link').onclick = function() { | 643 $('use-default-link').onclick = function() { |
| 640 SyncSetupOverlay.showSyncEverythingPage(); | 644 SyncSetupOverlay.showSyncEverythingPage(); |
| 641 return false; | 645 return false; |
| 642 }; | 646 }; |
| 643 } | 647 } |
| 644 }, | 648 }, |
| 645 | 649 |
| 646 /** | 650 /** |
| 647 * Shows the appropriate sync setup page. | 651 * Shows the appropriate sync setup page. |
| 648 * @param {string} page A page of the sync setup to show. | 652 * @param {string} page A page of the sync setup to show. |
| 649 * @param {object} args Data from the C++ to forward on to the right | 653 * @param {Object} args Data from the C++ to forward on to the right |
| 650 * section. | 654 * section. |
| 651 */ | 655 */ |
| 652 showSyncSetupPage_: function(page, args) { | 656 showSyncSetupPage_: function(page, args) { |
| 653 // If the user clicks the OK button, dismiss the dialog immediately, and | 657 // If the user clicks the OK button, dismiss the dialog immediately, and |
| 654 // do not go through the process of hiding elements of the overlay. | 658 // do not go through the process of hiding elements of the overlay. |
| 655 // See crbug.com/308873. | 659 // See crbug.com/308873. |
| 656 if (page == 'done') { | 660 if (page == 'done') { |
| 657 this.closeOverlay_(); | 661 this.closeOverlay_(); |
| 658 return; | 662 return; |
| 659 } | 663 } |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 702 var throbbers = this.pageDiv.getElementsByClassName('throbber'); | 706 var throbbers = this.pageDiv.getElementsByClassName('throbber'); |
| 703 for (var i = 0; i < throbbers.length; i++) | 707 for (var i = 0; i < throbbers.length; i++) |
| 704 throbbers[i].style.visibility = visible ? 'visible' : 'hidden'; | 708 throbbers[i].style.visibility = visible ? 'visible' : 'hidden'; |
| 705 }, | 709 }, |
| 706 | 710 |
| 707 /** | 711 /** |
| 708 * Reset the state of all descendant elements of a root element to their | 712 * Reset the state of all descendant elements of a root element to their |
| 709 * initial state. | 713 * initial state. |
| 710 * The initial state is specified by adding a class to the descendant | 714 * The initial state is specified by adding a class to the descendant |
| 711 * element in sync_setup_overlay.html. | 715 * element in sync_setup_overlay.html. |
| 712 * @param {HTMLElement} pageElementId The root page element id. | 716 * @param {string} pageElementId The root page element id. |
| 713 * @private | 717 * @private |
| 714 */ | 718 */ |
| 715 resetPage_: function(pageElementId) { | 719 resetPage_: function(pageElementId) { |
| 716 var page = $(pageElementId); | 720 var page = $(pageElementId); |
| 717 var forEach = function(arr, fn) { | 721 var forEach = function(arr, fn) { |
| 718 var length = arr.length; | 722 var length = arr.length; |
| 719 for (var i = 0; i < length; i++) { | 723 for (var i = 0; i < length; i++) { |
| 720 fn(arr[i]); | 724 fn(arr[i]); |
| 721 } | 725 } |
| 722 }; | 726 }; |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 812 | 816 |
| 813 SyncSetupOverlay.showStopSyncingUI = function() { | 817 SyncSetupOverlay.showStopSyncingUI = function() { |
| 814 SyncSetupOverlay.getInstance().showStopSyncingUI_(); | 818 SyncSetupOverlay.getInstance().showStopSyncingUI_(); |
| 815 }; | 819 }; |
| 816 | 820 |
| 817 // Export | 821 // Export |
| 818 return { | 822 return { |
| 819 SyncSetupOverlay: SyncSetupOverlay | 823 SyncSetupOverlay: SyncSetupOverlay |
| 820 }; | 824 }; |
| 821 }); | 825 }); |
| OLD | NEW |