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

Unified Diff: chrome/browser/resources/options2/browser_options.js

Issue 9353019: Revert 120803 - [uber] Redoing the homepage selection UI (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/resources/options2/browser_options.js
===================================================================
--- chrome/browser/resources/options2/browser_options.js (revision 120816)
+++ chrome/browser/resources/options2/browser_options.js (working copy)
@@ -25,11 +25,8 @@
syncEnabled: false,
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
@@ -49,8 +46,6 @@
initializePage: function() {
OptionsPage.prototype.initializePage.call(this);
- var self = this;
-
// Sync (Sign in) section.
$('sync-action-link').onclick = function(event) {
SyncSetupOverlay.showErrorUI();
@@ -80,17 +75,9 @@
};
// 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'));
};
@@ -148,6 +135,7 @@
// 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();
});
@@ -334,91 +322,15 @@
},
/**
- * 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|.
+ * Sets the label for the 'Show Home page' input.
+ * @param {string} label The HTML of the input label.
* @private
*/
- selectHomePageOption_: function(value) {
- var select = $('home-page-select');
- var option = this.getHomePageOption_(value);
- if (!option.selected)
- option.selected = true;
+ updateHomePageLabel_: function(label) {
+ $('home-page-label').innerHTML = label;
},
/**
- * Event listener for the |change| event on the homepage <select> element.
- * @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');
- },
-
- /**
* Called when the value of the instant.confirm_dialog_shown preference
* changes. Cache this value.
* @param {Event} event Change event.
@@ -522,6 +434,34 @@
},
/**
+ * Returns true if the custom startup page control block should
+ * be enabled.
+ * @returns {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
*/
@@ -677,6 +617,7 @@
'setThemesResetButtonEnabled',
'updateAccountPicture',
'updateAutocompleteSuggestions',
+ 'updateHomePageLabel',
'updateSearchEngines',
'updateStartupPages',
].forEach(function(name) {
« no previous file with comments | « chrome/browser/resources/options2/browser_options.html ('k') | chrome/browser/resources/options2/home_page_overlay.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698