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'); | 5 cr.exportPath('options'); |
6 | 6 |
7 /** @typedef {{appsEnforced: boolean, | |
8 * appsRegistered: boolean, | |
9 * appsSynced: boolean, | |
10 * autofillEnforced: boolean, | |
11 * autofillRegistered: boolean, | |
12 * autofillSynced: boolean, | |
13 * bookmarksEnforced: boolean, | |
14 * bookmarksRegistered: boolean, | |
15 * bookmarksSynced: boolean, | |
16 * encryptAllData: boolean, | |
17 * enterGooglePassphraseBody: (string|undefined), | |
18 * enterPassphraseBody: (string|undefined), | |
19 * extensionsEnforced: boolean, | |
20 * extensionsRegistered: boolean, | |
21 * extensionsSynced: boolean, | |
22 * fullEncryptionBody: string, | |
23 * isSupervised: boolean, | |
24 * passphraseFailed: boolean, | |
25 * passwordsEnforced: boolean, | |
26 * passwordsRegistered: boolean, | |
27 * passwordsSynced: boolean, | |
28 * preferencesEnforced: boolean, | |
29 * preferencesRegistered: boolean, | |
30 * preferencesSynced: boolean, | |
31 * showPassphrase: boolean, | |
32 * showSyncEverythingPage: boolean, | |
33 * syncAllDataTypes: boolean, | |
34 * syncNothing: boolean, | |
35 * tabsEnforced: boolean, | |
36 * tabsRegistered: boolean, | |
37 * tabsSynced: boolean, | |
38 * themesEnforced: boolean, | |
39 * themesRegistered: boolean, | |
40 * themesSynced: boolean, | |
41 * typedUrlsEnforced: boolean, | |
42 * typedUrlsRegistered: boolean, | |
43 * typedUrlsSynced: boolean, | |
44 * usePassphrase: boolean}} | |
45 */ | |
46 var SyncArgs; | |
Dan Beam
2014/09/11 02:53:09
nit: SyncConfig
Vitaly Pavlenko
2014/09/11 04:16:25
Done.
| |
47 | |
7 /** | 48 /** |
8 * The user's selection in the synced data type drop-down menu, as an index. | 49 * The user's selection in the synced data type drop-down menu, as an index. |
9 * @enum {number} | 50 * @enum {number} |
10 * @const | 51 * @const |
11 */ | 52 */ |
12 options.DataTypeSelection = { | 53 options.DataTypeSelection = { |
13 SYNC_EVERYTHING: 0, | 54 SYNC_EVERYTHING: 0, |
14 CHOOSE_WHAT_TO_SYNC: 1, | 55 CHOOSE_WHAT_TO_SYNC: 1, |
15 SYNC_NOTHING: 2 | 56 SYNC_NOTHING: 2 |
16 }; | 57 }; |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
161 } | 202 } |
162 }, | 203 }, |
163 | 204 |
164 /** | 205 /** |
165 * Enables / grays out the sync data type checkboxes in the advanced | 206 * Enables / grays out the sync data type checkboxes in the advanced |
166 * settings dialog. | 207 * settings dialog. |
167 * @param {boolean} enabled True for enabled, false for grayed out. | 208 * @param {boolean} enabled True for enabled, false for grayed out. |
168 * @private | 209 * @private |
169 */ | 210 */ |
170 setDataTypeCheckboxesEnabled_: function(enabled) { | 211 setDataTypeCheckboxesEnabled_: function(enabled) { |
171 for (dataType in dataTypeBoxesDisabled_) { | 212 for (var dataType in dataTypeBoxesDisabled_) { |
172 $(dataType).disabled = !enabled || dataTypeBoxesDisabled_[dataType]; | 213 $(dataType).disabled = !enabled || dataTypeBoxesDisabled_[dataType]; |
173 } | 214 } |
174 }, | 215 }, |
175 | 216 |
176 /** | 217 /** |
177 * Sets the state of the sync data type checkboxes based on whether "Sync | 218 * Sets the state of the sync data type checkboxes based on whether "Sync |
178 * everything", "Choose what to sync", or "Sync nothing" are selected in the | 219 * everything", "Choose what to sync", or "Sync nothing" are selected in the |
179 * drop-down menu of the advanced settings dialog. | 220 * drop-down menu of the advanced settings dialog. |
180 * @param {options.DataTypeSelection} selectedIndex Index of user's | 221 * @param {options.DataTypeSelection} selectedIndex Index of user's |
181 * selection. | 222 * selection. |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
305 options.DataTypeSelection.SYNC_EVERYTHING); | 346 options.DataTypeSelection.SYNC_EVERYTHING); |
306 return false; | 347 return false; |
307 }; | 348 }; |
308 }, | 349 }, |
309 | 350 |
310 /** | 351 /** |
311 * Shows or hides the sync data type checkboxes in the advanced sync | 352 * Shows or hides the sync data type checkboxes in the advanced sync |
312 * settings dialog. Also initializes |dataTypeBoxesChecked_| and | 353 * settings dialog. Also initializes |dataTypeBoxesChecked_| and |
313 * |dataTypeBoxedDisabled_| with their values, and makes their onclick | 354 * |dataTypeBoxedDisabled_| with their values, and makes their onclick |
314 * handlers update |dataTypeBoxesChecked_|. | 355 * handlers update |dataTypeBoxesChecked_|. |
315 * @param {Object} args The configuration data used to show/hide UI. | 356 * @param {SyncArgs} args The configuration data used to show/hide UI. |
316 * @private | 357 * @private |
317 */ | 358 */ |
318 setChooseDataTypesCheckboxes_: function(args) { | 359 setChooseDataTypesCheckboxes_: function(args) { |
319 var datatypeSelect = $('sync-select-datatypes'); | 360 var datatypeSelect = $('sync-select-datatypes'); |
320 datatypeSelect.selectedIndex = args.syncAllDataTypes ? | 361 datatypeSelect.selectedIndex = args.syncAllDataTypes ? |
321 options.DataTypeSelection.SYNC_EVERYTHING : | 362 options.DataTypeSelection.SYNC_EVERYTHING : |
322 options.DataTypeSelection.CHOOSE_WHAT_TO_SYNC; | 363 options.DataTypeSelection.CHOOSE_WHAT_TO_SYNC; |
323 | 364 |
324 $('bookmarks-checkbox').checked = args.bookmarksSynced; | 365 $('bookmarks-checkbox').checked = args.bookmarksSynced; |
325 dataTypeBoxesChecked_['bookmarks-checkbox'] = args.bookmarksSynced; | 366 dataTypeBoxesChecked_['bookmarks-checkbox'] = args.bookmarksSynced; |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
399 * |dataTypeBoxesChecked_|. Used as an onclick handler for each data type | 440 * |dataTypeBoxesChecked_|. Used as an onclick handler for each data type |
400 * checkbox. | 441 * checkbox. |
401 * @private | 442 * @private |
402 */ | 443 */ |
403 handleDataTypeClick_: function() { | 444 handleDataTypeClick_: function() { |
404 dataTypeBoxesChecked_[this.id] = this.checked; | 445 dataTypeBoxesChecked_[this.id] = this.checked; |
405 chrome.send('coreOptionsUserMetricsAction', | 446 chrome.send('coreOptionsUserMetricsAction', |
406 ['Options_SyncToggleDataType']); | 447 ['Options_SyncToggleDataType']); |
407 }, | 448 }, |
408 | 449 |
450 /** | |
451 * @param {SyncArgs} args | |
452 */ | |
409 setEncryptionRadios_: function(args) { | 453 setEncryptionRadios_: function(args) { |
410 if (!args.encryptAllData && !args.usePassphrase) { | 454 if (!args.encryptAllData && !args.usePassphrase) { |
411 $('basic-encryption-option').checked = true; | 455 $('basic-encryption-option').checked = true; |
412 } else { | 456 } else { |
413 $('full-encryption-option').checked = true; | 457 $('full-encryption-option').checked = true; |
414 $('full-encryption-option').disabled = true; | 458 $('full-encryption-option').disabled = true; |
415 $('basic-encryption-option').disabled = true; | 459 $('basic-encryption-option').disabled = true; |
416 } | 460 } |
417 }, | 461 }, |
418 | 462 |
463 /** | |
464 * @param {SyncArgs} args | |
465 */ | |
419 setCheckboxesAndErrors_: function(args) { | 466 setCheckboxesAndErrors_: function(args) { |
420 this.setChooseDataTypesCheckboxes_(args); | 467 this.setChooseDataTypesCheckboxes_(args); |
421 this.setEncryptionRadios_(args); | 468 this.setEncryptionRadios_(args); |
422 }, | 469 }, |
423 | 470 |
471 /** | |
472 * @param {SyncArgs} args | |
473 */ | |
424 showConfigure_: function(args) { | 474 showConfigure_: function(args) { |
425 var datatypeSelect = $('sync-select-datatypes'); | 475 var datatypeSelect = $('sync-select-datatypes'); |
426 var self = this; | 476 var self = this; |
427 | 477 |
428 // Cache the sync config args so they can be reused when we transition | 478 // Cache the sync config args so they can be reused when we transition |
429 // between the drop-down menu items in the advanced settings dialog. | 479 // between the drop-down menu items in the advanced settings dialog. |
430 if (args) | 480 if (args) |
431 this.syncConfigureArgs_ = args; | 481 this.syncConfigureArgs_ = args; |
432 | 482 |
433 // Required in order to determine whether to give focus to the OK button | 483 // Required in order to determine whether to give focus to the OK button |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
549 // Hide the "use default settings" link. | 599 // Hide the "use default settings" link. |
550 $('use-default-link').hidden = true; | 600 $('use-default-link').hidden = true; |
551 $('use-default-link').disabled = true; | 601 $('use-default-link').disabled = true; |
552 $('use-default-link').onclick = null; | 602 $('use-default-link').onclick = null; |
553 }, | 603 }, |
554 | 604 |
555 /** | 605 /** |
556 * Reveals the UI for entering a custom passphrase during initial setup. | 606 * Reveals the UI for entering a custom passphrase during initial setup. |
557 * This happens if the user has previously enabled a custom passphrase on a | 607 * This happens if the user has previously enabled a custom passphrase on a |
558 * different machine. | 608 * different machine. |
559 * @param {Array} args The args that contain the passphrase UI | 609 * @param {SyncArgs} args The args that contain the passphrase UI |
560 * configuration. | 610 * configuration. |
561 * @private | 611 * @private |
562 */ | 612 */ |
563 showPassphraseContainer_: function(args) { | 613 showPassphraseContainer_: function(args) { |
564 // Once we require a passphrase, we prevent the user from returning to | 614 // Once we require a passphrase, we prevent the user from returning to |
565 // the Sync Everything pane. | 615 // the Sync Everything pane. |
566 $('use-default-link').hidden = true; | 616 $('use-default-link').hidden = true; |
567 $('use-default-link').disabled = true; | 617 $('use-default-link').disabled = true; |
568 $('use-default-link').onclick = null; | 618 $('use-default-link').onclick = null; |
569 $('sync-custom-passphrase-container').hidden = true; | 619 $('sync-custom-passphrase-container').hidden = true; |
(...skipping 18 matching lines...) Expand all Loading... | |
588 // previously but failed). | 638 // previously but failed). |
589 $('incorrect-passphrase').hidden = | 639 $('incorrect-passphrase').hidden = |
590 !(args.usePassphrase && args.passphraseFailed); | 640 !(args.usePassphrase && args.passphraseFailed); |
591 | 641 |
592 $('sync-passphrase-warning').hidden = false; | 642 $('sync-passphrase-warning').hidden = false; |
593 }, | 643 }, |
594 | 644 |
595 /** | 645 /** |
596 * Displays the advanced sync setting dialog, and pre-selects either the | 646 * Displays the advanced sync setting dialog, and pre-selects either the |
597 * "Sync everything" or the "Choose what to sync" drop-down menu item. | 647 * "Sync everything" or the "Choose what to sync" drop-down menu item. |
648 * @param {SyncArgs} args | |
598 * @param {options.DataTypeSelection} index Index of item to pre-select. | 649 * @param {options.DataTypeSelection} index Index of item to pre-select. |
599 * @private | 650 * @private |
600 */ | 651 */ |
601 showCustomizePage_: function(args, index) { | 652 showCustomizePage_: function(args, index) { |
602 // Determine whether to bring the OK button field into focus. | 653 // Determine whether to bring the OK button field into focus. |
603 var wasCustomizePageHidden = !this.customizePageVisible_; | 654 var wasCustomizePageHidden = !this.customizePageVisible_; |
604 this.customizePageVisible_ = true; | 655 this.customizePageVisible_ = true; |
605 this.confirmPageVisible_ = false; | 656 this.confirmPageVisible_ = false; |
606 | 657 |
607 $('confirm-sync-preferences').hidden = true; | 658 $('confirm-sync-preferences').hidden = true; |
(...skipping 27 matching lines...) Expand all Loading... | |
635 $('use-default-link').onclick = function() { | 686 $('use-default-link').onclick = function() { |
636 SyncSetupOverlay.showSyncEverythingPage(); | 687 SyncSetupOverlay.showSyncEverythingPage(); |
637 return false; | 688 return false; |
638 }; | 689 }; |
639 } | 690 } |
640 }, | 691 }, |
641 | 692 |
642 /** | 693 /** |
643 * Shows the appropriate sync setup page. | 694 * Shows the appropriate sync setup page. |
644 * @param {string} page A page of the sync setup to show. | 695 * @param {string} page A page of the sync setup to show. |
645 * @param {Object} args Data from the C++ to forward on to the right | 696 * @param {SyncArgs} args Data from the C++ to forward on to the right |
646 * section. | 697 * section. |
647 */ | 698 */ |
648 showSyncSetupPage_: function(page, args) { | 699 showSyncSetupPage_: function(page, args) { |
649 // If the user clicks the OK button, dismiss the dialog immediately, and | 700 // If the user clicks the OK button, dismiss the dialog immediately, and |
650 // do not go through the process of hiding elements of the overlay. | 701 // do not go through the process of hiding elements of the overlay. |
651 // See crbug.com/308873. | 702 // See crbug.com/308873. |
652 if (page == 'done') { | 703 if (page == 'done') { |
653 this.closeOverlay_(); | 704 this.closeOverlay_(); |
654 return; | 705 return; |
655 } | 706 } |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
808 | 859 |
809 SyncSetupOverlay.showStopSyncingUI = function() { | 860 SyncSetupOverlay.showStopSyncingUI = function() { |
810 SyncSetupOverlay.getInstance().showStopSyncingUI_(); | 861 SyncSetupOverlay.getInstance().showStopSyncingUI_(); |
811 }; | 862 }; |
812 | 863 |
813 // Export | 864 // Export |
814 return { | 865 return { |
815 SyncSetupOverlay: SyncSetupOverlay | 866 SyncSetupOverlay: SyncSetupOverlay |
816 }; | 867 }; |
817 }); | 868 }); |
OLD | NEW |