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

Side by Side Diff: chrome/browser/resources/options2/browser_options.js

Issue 10834109: Consistently decorate pref values sent to the settings UI code (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Silly me, made a CrOS-only change and tested it on a desktop build... Created 8 years, 4 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 var OptionsPage = options.OptionsPage; 6 var OptionsPage = options.OptionsPage;
7 var ArrayDataModel = cr.ui.ArrayDataModel; 7 var ArrayDataModel = cr.ui.ArrayDataModel;
8 var RepeatingButton = cr.ui.RepeatingButton; 8 var RepeatingButton = cr.ui.RepeatingButton;
9 9
10 // 10 //
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after
477 477
478 /** 478 /**
479 * Event listener for the 'session.restore_on_startup' pref. 479 * Event listener for the 'session.restore_on_startup' pref.
480 * @param {Event} event The preference change event. 480 * @param {Event} event The preference change event.
481 * @private 481 * @private
482 */ 482 */
483 onRestoreOnStartupChanged_: function(event) { 483 onRestoreOnStartupChanged_: function(event) {
484 /** @const */ var showPagesValue = Number($('startup-show-pages').value); 484 /** @const */ var showPagesValue = Number($('startup-show-pages').value);
485 /** @const */ var showHomePageValue = 0; 485 /** @const */ var showHomePageValue = 0;
486 486
487 $('startup-set-pages').disabled = event.value['disabled'] && 487 $('startup-set-pages').disabled = event.value.disabled &&
488 event.value['value'] != showPagesValue; 488 event.value.value != showPagesValue;
489 489
490 if (event.value['value'] == showHomePageValue) { 490 if (event.value.value == showHomePageValue) {
491 // If the user previously selected "Show the homepage", the 491 // If the user previously selected "Show the homepage", the
492 // preference will already be migrated to "Open a specific page". So 492 // preference will already be migrated to "Open a specific page". So
493 // the only way to reach this code is if the 'restore on startup' 493 // the only way to reach this code is if the 'restore on startup'
494 // preference is managed. 494 // preference is managed.
495 assert(event.value['controlledBy']); 495 assert(event.value.controlledBy);
496 496
497 // Select "open the following pages" and lock down the list of URLs 497 // Select "open the following pages" and lock down the list of URLs
498 // to reflect the intention of the policy. 498 // to reflect the intention of the policy.
499 $('startup-show-pages').checked = true; 499 $('startup-show-pages').checked = true;
500 StartupOverlay.getInstance().setControlsDisabled(true); 500 StartupOverlay.getInstance().setControlsDisabled(true);
501 } else { 501 } else {
502 // Re-enable the controls in the startup overlay if necessary. 502 // Re-enable the controls in the startup overlay if necessary.
503 StartupOverlay.getInstance().updateControlStates(); 503 StartupOverlay.getInstance().updateControlStates();
504 } 504 }
505 }, 505 },
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
678 /** 678 /**
679 * Event listener for the 'show home button' preference. Shows/hides the 679 * Event listener for the 'show home button' preference. Shows/hides the
680 * UI for changing the home page with animation, unless this is the first 680 * UI for changing the home page with animation, unless this is the first
681 * time this function is called, in which case there is no animation. 681 * time this function is called, in which case there is no animation.
682 * @param {Event} event The preference change event. 682 * @param {Event} event The preference change event.
683 */ 683 */
684 onShowHomeButtonChanged_: function(event) { 684 onShowHomeButtonChanged_: function(event) {
685 var section = $('change-home-page-section'); 685 var section = $('change-home-page-section');
686 if (this.onShowHomeButtonChangedCalled_) { 686 if (this.onShowHomeButtonChangedCalled_) {
687 var container = $('change-home-page-section-container'); 687 var container = $('change-home-page-section-container');
688 if (event.value['value']) 688 if (event.value.value)
689 this.showSectionWithAnimation_(section, container); 689 this.showSectionWithAnimation_(section, container);
690 else 690 else
691 this.hideSectionWithAnimation_(section, container); 691 this.hideSectionWithAnimation_(section, container);
692 } else { 692 } else {
693 section.hidden = !event.value['value']; 693 section.hidden = !event.value.value;
694 this.onShowHomeButtonChangedCalled_ = true; 694 this.onShowHomeButtonChangedCalled_ = true;
695 } 695 }
696 }, 696 },
697 697
698 /** 698 /**
699 * Event listener for the 'homepage is NTP' preference. Updates the label 699 * Event listener for the 'homepage is NTP' preference. Updates the label
700 * next to the 'Change' button. 700 * next to the 'Change' button.
701 * @param {Event} event The preference change event. 701 * @param {Event} event The preference change event.
702 */ 702 */
703 onHomePageIsNtpChanged_: function(event) { 703 onHomePageIsNtpChanged_: function(event) {
704 $('home-page-url').hidden = event.value['value']; 704 $('home-page-url').hidden = event.value.value;
705 $('home-page-ntp').hidden = !event.value['value']; 705 $('home-page-ntp').hidden = !event.value.value;
706 }, 706 },
707 707
708 /** 708 /**
709 * Event listener for changes to the homepage preference. Updates the label 709 * Event listener for changes to the homepage preference. Updates the label
710 * next to the 'Change' button. 710 * next to the 'Change' button.
711 * @param {Event} event The preference change event. 711 * @param {Event} event The preference change event.
712 */ 712 */
713 onHomePageChanged_: function(event) { 713 onHomePageChanged_: function(event) {
714 $('home-page-url').textContent = this.stripHttp_(event.value['value']); 714 $('home-page-url').textContent = this.stripHttp_(event.value.value);
715 }, 715 },
716 716
717 /** 717 /**
718 * Removes the 'http://' from a URL, like the omnibox does. If the string 718 * Removes the 'http://' from a URL, like the omnibox does. If the string
719 * doesn't start with 'http://' it is returned unchanged. 719 * doesn't start with 'http://' it is returned unchanged.
720 * @param {string} url The url to be processed 720 * @param {string} url The url to be processed
721 * @return {string} The url with the 'http://' removed. 721 * @return {string} The url with the 'http://' removed.
722 */ 722 */
723 stripHttp_: function(url) { 723 stripHttp_: function(url) {
724 return url.replace(/^http:\/\//, ''); 724 return url.replace(/^http:\/\//, '');
725 }, 725 },
726 726
727 /** 727 /**
728 * Shows the autoLaunch preference and initializes its checkbox value. 728 * Shows the autoLaunch preference and initializes its checkbox value.
729 * @param {bool} enabled Whether autolaunch is enabled or or not. 729 * @param {bool} enabled Whether autolaunch is enabled or or not.
730 * @private 730 * @private
731 */ 731 */
732 updateAutoLaunchState_: function(enabled) { 732 updateAutoLaunchState_: function(enabled) {
733 $('auto-launch-option').hidden = false; 733 $('auto-launch-option').hidden = false;
734 $('auto-launch').checked = enabled; 734 $('auto-launch').checked = enabled;
735 }, 735 },
736 736
737 /** 737 /**
738 * Called when the value of the instant.confirm_dialog_shown preference 738 * Called when the value of the instant.confirm_dialog_shown preference
739 * changes. Cache this value. 739 * changes. Cache this value.
740 * @param {Event} event Change event. 740 * @param {Event} event Change event.
741 * @private 741 * @private
742 */ 742 */
743 onInstantConfirmDialogShownChanged_: function(event) { 743 onInstantConfirmDialogShownChanged_: function(event) {
744 this.instantConfirmDialogShown_ = event.value['value']; 744 this.instantConfirmDialogShown_ = event.value.value;
745 }, 745 },
746 746
747 /** 747 /**
748 * Called when the value of the spellcheck.confirm_dialog_shown preference 748 * Called when the value of the spellcheck.confirm_dialog_shown preference
749 * changes. Cache this value. 749 * changes. Cache this value.
750 * @param {Event} event Change event. 750 * @param {Event} event Change event.
751 * @private 751 * @private
752 */ 752 */
753 onSpellcheckConfirmDialogShownChanged_: function(event) { 753 onSpellcheckConfirmDialogShownChanged_: function(event) {
754 this.spellcheckConfirmDialogShown_ = event.value['value']; 754 this.spellcheckConfirmDialogShown_ = event.value.value;
755 }, 755 },
756 756
757 /** 757 /**
758 * Called when the value of the download.default_directory preference 758 * Called when the value of the download.default_directory preference
759 * changes. 759 * changes.
760 * @param {Event} event Change event. 760 * @param {Event} event Change event.
761 * @private 761 * @private
762 */ 762 */
763 onDefaultDownloadDirectoryChanged_: function(event) { 763 onDefaultDownloadDirectoryChanged_: function(event) {
764 $('downloadLocationPath').value = event.value['value']; 764 $('downloadLocationPath').value = event.value.value;
765 if (cr.isChromeOS) { 765 if (cr.isChromeOS) {
766 // On ChromeOS, strip out /special for drive paths, and 766 // On ChromeOS, strip out /special for drive paths, and
767 // /home/chronos/user for local files. 767 // /home/chronos/user for local files.
768 $('downloadLocationPath').value = $('downloadLocationPath').value. 768 $('downloadLocationPath').value = $('downloadLocationPath').value.
769 replace(/^\/(special|home\/chronos\/user)/, ''); 769 replace(/^\/(special|home\/chronos\/user)/, '');
770 } 770 }
771 }, 771 },
772 772
773 /** 773 /**
774 * Update the Default Browsers section based on the current state. 774 * Update the Default Browsers section based on the current state.
(...skipping 570 matching lines...) Expand 10 before | Expand all | Expand 10 after
1345 BrowserOptions.getLoggedInUsername = function() { 1345 BrowserOptions.getLoggedInUsername = function() {
1346 return BrowserOptions.getInstance().username_; 1346 return BrowserOptions.getInstance().username_;
1347 }; 1347 };
1348 } 1348 }
1349 1349
1350 // Export 1350 // Export
1351 return { 1351 return {
1352 BrowserOptions: BrowserOptions 1352 BrowserOptions: BrowserOptions
1353 }; 1353 };
1354 }); 1354 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698