summaryrefslogtreecommitdiffstats
path: root/chrome/browser/resources/options2/browser_options.js
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/resources/options2/browser_options.js')
-rw-r--r--chrome/browser/resources/options2/browser_options.js132
1 files changed, 36 insertions, 96 deletions
diff --git a/chrome/browser/resources/options2/browser_options.js b/chrome/browser/resources/options2/browser_options.js
index 679508a..1de8786 100644
--- a/chrome/browser/resources/options2/browser_options.js
+++ b/chrome/browser/resources/options2/browser_options.js
@@ -24,11 +24,8 @@ cr.define('options', function() {
// State variables.
syncSetupCompleted: false,
- showHomeButton_: false,
- homePageIsNtp_: false,
-
/**
- * An autocomplete list that can be attached to the home page URL text field
+ * An autocomplete list that can be attached to the homepage URL text field
* during editing.
* @type {HTMLElement}
* @private
@@ -47,7 +44,6 @@ cr.define('options', function() {
*/
initializePage: function() {
OptionsPage.prototype.initializePage.call(this);
- var self = this;
window.addEventListener('message', this.handleWindowMessage_.bind(this));
@@ -82,17 +78,9 @@ cr.define('options', function() {
};
// Appearance section.
- $('home-page-select').addEventListener(
- 'change', this.onHomePageSelectChange_.bind(this));
-
- ['browser.show_home_button',
- 'homepage',
- 'homepage_is_newtabpage'].forEach(function(pref) {
- Preferences.getInstance().addEventListener(
- pref,
- self.onHomePagePrefChanged_.bind(self));
- });
-
+ $('change-home-page').onclick = function(event) {
+ OptionsPage.navigateToPage('homePageOverlay');
+ };
$('themes-gallery').onclick = function(event) {
window.open(localStrings.getString('themesGalleryURL'));
};
@@ -150,6 +138,7 @@ cr.define('options', function() {
// Text fields may change widths when the window changes size, so make
// sure the suggestion list stays in sync.
+ var self = this;
window.addEventListener('resize', function() {
self.autocompleteList_.syncWidthToInput();
});
@@ -386,88 +375,12 @@ cr.define('options', function() {
},
/**
- * Returns the <option> element with the given |value|.
- * @param {string} value One of 'none', 'ntp', 'url', 'choose'.
- * @return {HTMLOptionElement} the specified <option> element.
- */
- getHomePageOption_: function(value) {
- var select = $('home-page-select');
- return select.querySelector('option[value=' + value + ']');
- },
-
- /**
- * Selects the <option> element with the given |value|.
- * @private
- */
- selectHomePageOption_: function(value) {
- var select = $('home-page-select');
- var option = this.getHomePageOption_(value);
- if (!option.selected)
- option.selected = true;
- },
-
- /**
- * Event listener for the |change| event on the homepage <select> element.
+ * Sets the label for the 'Show Home page' input.
+ * @param {string} label The HTML of the input label.
* @private
*/
- onHomePageSelectChange_: function() {
- var option = $('home-page-select').value;
- if (option == 'choose') {
- OptionsPage.navigateToPage('homePageOverlay');
- return;
- }
-
- var showHomeButton = (option != 'none');
- Preferences.setBooleanPref('browser.show_home_button', showHomeButton);
-
- if (option == 'ntp')
- Preferences.setBooleanPref('homepage_is_newtabpage', true);
- else if (option == 'url')
- Preferences.setBooleanPref('homepage_is_newtabpage', false);
- },
-
- /**
- * Event listener called when any homepage-related preferences change.
- * @private
- */
- onHomePagePrefChanged_: function(event) {
- switch (event.type) {
- case 'homepage':
- this.getHomePageOption_('url').textContent = event.value['value'];
- break;
- case 'browser.show_home_button':
- this.showHomeButton_ = event.value['value'];
- break;
- case 'homepage_is_newtabpage':
- this.homePageIsNtp_ = event.value['value'];
- break;
- default:
- console.error('Unexpected pref change event:', event.type);
- }
- this.updateHomePageSelector();
- },
-
- /**
- * Updates the homepage <select> element to have the appropriate option
- * selected.
- */
- updateHomePageSelector: function() {
- if (this.showHomeButton_) {
- if (this.homePageIsNtp_)
- this.selectHomePageOption_('ntp');
- else
- this.selectHomePageOption_('url');
- } else {
- this.selectHomePageOption_('none');
- }
- },
-
- /**
- * Sets the home page selector to the 'url' option.Called when user clicks
- * OK in the "Choose another..." dialog.
- */
- homePageSelectUrl: function() {
- this.selectHomePageOption_('url');
+ updateHomePageLabel_: function(label) {
+ $('home-page-label').innerHTML = label;
},
/**
@@ -584,6 +497,32 @@ cr.define('options', function() {
},
/**
+ * Returns true if the custom startup page control block should be enabled.
+ * @return {boolean} Whether the startup page controls should be enabled.
+ */
+ shouldEnableCustomStartupPageControls: function(pages) {
+ return $('startup-show-pages').checked &&
+ !this.startup_pages_pref_.disabled;
+ },
+
+ /**
+ * Sets the enabled state of the custom startup page list controls
+ * based on the current startup radio button selection.
+ * @private
+ */
+ updateCustomStartupPageControlStates_: function() {
+ var disable = !this.shouldEnableCustomStartupPageControls();
+ var startupPagesList = $('startupPagesList');
+ startupPagesList.disabled = disable;
+ startupPagesList.setAttribute('tabindex', disable ? -1 : 0);
+ // Explicitly set disabled state for input text elements.
+ var inputs = startupPagesList.querySelectorAll("input[type='text']");
+ for (var i = 0; i < inputs.length; i++)
+ inputs[i].disabled = disable;
+ $('startupUseCurrentButton').disabled = disable;
+ },
+
+ /**
* Set the default search engine based on the popup selection.
* @private
*/
@@ -736,6 +675,7 @@ cr.define('options', function() {
'updateAccountPicture',
'updateAutocompleteSuggestions',
'updateAutoLaunchState',
+ 'updateHomePageLabel',
'updateManagedBannerVisibility',
'updateSearchEngines',
'updateSyncState',