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

Unified Diff: chrome/browser/resources/options/home_page_overlay.js

Issue 11096020: Add first batch of controlled setting indicators (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Nit addressed. Created 8 years, 2 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/options/home_page_overlay.js
diff --git a/chrome/browser/resources/options/home_page_overlay.js b/chrome/browser/resources/options/home_page_overlay.js
index 01a76c54b54a5c1a98ef92d73df51ceca31b053c..3955b536bb4ee1091b81f353077b1b1a7d05bcc4 100644
--- a/chrome/browser/resources/options/home_page_overlay.js
+++ b/chrome/browser/resources/options/home_page_overlay.js
@@ -38,8 +38,9 @@ cr.define('options', function() {
SettingsDialog.prototype.initializePage.call(this);
var self = this;
- $('homepage-use-ntp').onchange = this.updateHomePageInput_.bind(this);
- $('homepage-use-url').onchange = this.updateHomePageInput_.bind(this);
+ options.Preferences.getInstance().addEventListener(
+ 'homepage_is_newtabpage',
+ this.handleHomepageIsNTPPrefChange.bind(this));
var urlField = $('homepage-url-field');
urlField.addEventListener('keydown', function(event) {
@@ -73,19 +74,22 @@ cr.define('options', function() {
/** @inheritDoc */
didShowPage: function() {
- this.updateHomePageInput_();
this.updateFavicon_();
},
/**
- * Updates the state of the homepage text input. The input is enabled only
- * if the |homepage-use-url| radio button is checked.
- * @private
+ * Updates the state of the homepage text input and its controlled setting
+ * indicator when the |homepage_is_newtabpage| pref changes. The input is
+ * enabled only if the homepage is not the NTP. The indicator is always
+ * enabled but treats the input's value as read-only if the homepage is the
+ * NTP.
+ * @param {Event} Pref change event.
*/
- updateHomePageInput_: function() {
+ handleHomepageIsNTPPrefChange: function(event) {
var urlField = $('homepage-url-field');
- var homePageUseURL = $('homepage-use-url');
- urlField.setDisabled('radio-choice', !homePageUseURL.checked);
+ var urlFieldIndicator = $('homepage-url-field-indicator');
+ urlField.setDisabled('homepage-is-ntp', event.value.value);
+ urlFieldIndicator.readOnly = event.value.value;
},
/**
« no previous file with comments | « chrome/browser/resources/options/home_page_overlay.html ('k') | chrome/test/data/policy/policy_test_cases.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698