From 043aa5a5482d302b56b4a0a2ca80b61e9f3d7ad7 Mon Sep 17 00:00:00 2001 From: "jhawkins@chromium.org" Date: Wed, 2 Mar 2011 23:16:33 +0000 Subject: 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 --- .../browser/resources/options/browser_options.html | 4 ---- .../browser/resources/options/browser_options.js | 24 ++++++++++++++++++---- .../resources/options/instant_confirm_overlay.js | 4 +--- 3 files changed, 21 insertions(+), 11 deletions(-) (limited to 'chrome/browser/resources') 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 @@ - -
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); -- cgit v1.1