diff options
author | jhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-02 23:16:33 +0000 |
---|---|---|
committer | jhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-02 23:16:33 +0000 |
commit | 043aa5a5482d302b56b4a0a2ca80b61e9f3d7ad7 (patch) | |
tree | 67ee74c31c52bce7860f0e0b1fdc06173909325d /chrome/browser/resources | |
parent | cea467f6e990d9990209a97ce3e896cb5ff72212 (diff) | |
download | chromium_src-043aa5a5482d302b56b4a0a2ca80b61e9f3d7ad7.zip chromium_src-043aa5a5482d302b56b4a0a2ca80b61e9f3d7ad7.tar.gz chromium_src-043aa5a5482d302b56b4a0a2ca80b61e9f3d7ad7.tar.bz2 |
Options: Simplify access to the instant.confirm_dialog_shown preference.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/6591062
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@76649 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/resources')
-rw-r--r-- | chrome/browser/resources/options/browser_options.html | 4 | ||||
-rw-r--r-- | chrome/browser/resources/options/browser_options.js | 24 | ||||
-rw-r--r-- | chrome/browser/resources/options/instant_confirm_overlay.js | 4 |
3 files changed, 21 insertions, 11 deletions
diff --git a/chrome/browser/resources/options/browser_options.html b/chrome/browser/resources/options/browser_options.html index e79d702..d8244c1 100644 --- a/chrome/browser/resources/options/browser_options.html +++ b/chrome/browser/resources/options/browser_options.html @@ -89,10 +89,6 @@ <input type="checkbox" id="instantEnableCheckbox" pref="instant.enabled"> <span i18n-content="instantName"></span> - <!-- This hidden checkbox allows us to get/set the state of the - confirm_dialog_shown pref --> - <input type="checkbox" class="hidden" id="instantDialogShown" - pref="instant.confirm_dialog_shown"> </label> </div> <div class="suboption informational-text"> diff --git a/chrome/browser/resources/options/browser_options.js b/chrome/browser/resources/options/browser_options.js index 6f5a2a7..2819807 100644 --- a/chrome/browser/resources/options/browser_options.js +++ b/chrome/browser/resources/options/browser_options.js @@ -34,6 +34,9 @@ cr.define('options', function() { 'managed': false }, + // The cached value of the instant.confirm_dialog_shown preference. + instantConfirmDialogShown_: false, + /** * Initialize BrowserOptions page. */ @@ -53,17 +56,20 @@ cr.define('options', function() { chrome.send('coreOptionsUserMetricsAction', ['Options_ManageSearchEngines']); }; - $('instantEnableCheckbox').onclick = function(event) { - var alreadyConfirmed = $('instantDialogShown').checked; + $('defaultSearchEngine').onchange = this.setDefaultSearchEngine; - if (this.checked && !alreadyConfirmed) { + var self = this; + $('instantEnableCheckbox').onclick = function(event) { + if (this.checked && !self.instantConfirmDialogShown_) { // Leave disabled for now. The PrefCheckbox handler already set it to // true so undo that. Preferences.setBooleanPref(this.pref, false, this.metric); OptionsPage.navigateToPage('instantConfirm'); } }; - $('defaultSearchEngine').onchange = this.setDefaultSearchEngine; + + Preferences.getInstance().addEventListener('instant.confirm_dialog_shown', + this.onInstantConfirmDialogShownChanged_.bind(this)); var homepageField = $('homepageURL'); $('homepageUseNTPButton').onchange = @@ -112,6 +118,16 @@ cr.define('options', function() { }, /** + * Called when the value of the instant.confirm_dialog_shown preference + * changes. Cache this value. + * @param {Event} event Change event. + * @private + */ + onInstantConfirmDialogShownChanged_: function(event) { + this.instantConfirmDialogShown_ = event.value['value']; + }, + + /** * Update the Default Browsers section based on the current state. * @private * @param {string} statusString Description of the current default state. diff --git a/chrome/browser/resources/options/instant_confirm_overlay.js b/chrome/browser/resources/options/instant_confirm_overlay.js index 3ba9793..9f983c7 100644 --- a/chrome/browser/resources/options/instant_confirm_overlay.js +++ b/chrome/browser/resources/options/instant_confirm_overlay.js @@ -25,9 +25,7 @@ cr.define('options', function() { }; $('instantConfirmOk').onclick = function() { OptionsPage.closeOverlay(); - var instantDialogShown = $('instantDialogShown'); - Preferences.setBooleanPref(instantDialogShown.pref, true, - instantDialogShown.metric); + Preferences.setBooleanPref('instant.confirm_dialog_shown', true); var instantEnabledCheckbox = $('instantEnableCheckbox'); Preferences.setBooleanPref(instantEnableCheckbox.pref, true, instantEnableCheckbox.metric); |