summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbartfab@chromium.org <bartfab@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-24 18:38:16 +0000
committerbartfab@chromium.org <bartfab@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-24 18:38:16 +0000
commit373a6c9b7cd5ad059a70f3a76583193b8596d39f (patch)
tree63a83fa577580062e02ea43c675b3f0650a13592
parent518ee58ff2ed4f72e313fce4f3c29d2688b3ade1 (diff)
downloadchromium_src-373a6c9b7cd5ad059a70f3a76583193b8596d39f.zip
chromium_src-373a6c9b7cd5ad059a70f3a76583193b8596d39f.tar.gz
chromium_src-373a6c9b7cd5ad059a70f3a76583193b8596d39f.tar.bz2
Clean up copy&paste in confirmation dialogs for prefs
This CL consolidates the three implementations of virtually identical confirmation dialogs for prefs into a single class. The new code has the further advantage that the confirmation dialogs no longer know about and manipulate any input elements directly but instead, use the dialog pref system to commit or roll back changes when they are confirmed or cancelled. BUG=157319 Review URL: https://chromiumcodereview.appspot.com/11232059 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@163874 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/resources/options/browser_options.html6
-rw-r--r--chrome/browser/resources/options/browser_options.js64
-rw-r--r--chrome/browser/resources/options/confirm_dialog.js110
-rw-r--r--chrome/browser/resources/options/do_not_track_confirm_overlay.js45
-rw-r--r--chrome/browser/resources/options/instant_confirm_overlay.js50
-rw-r--r--chrome/browser/resources/options/options.js40
-rw-r--r--chrome/browser/resources/options/options_bundle.js4
-rw-r--r--chrome/browser/resources/options/spelling_confirm_overlay.js53
-rw-r--r--chrome/browser/ui/webui/options/options_browsertest.js22
9 files changed, 155 insertions, 239 deletions
diff --git a/chrome/browser/resources/options/browser_options.html b/chrome/browser/resources/options/browser_options.html
index ae136b0..cbbac0b 100644
--- a/chrome/browser/resources/options/browser_options.html
+++ b/chrome/browser/resources/options/browser_options.html
@@ -136,7 +136,7 @@
<label id="instant-label">
<!-- TODO(estade): metric? -->
<input id="instant-enabled-control" type="checkbox"
- pref="instant.enabled">
+ pref="instant.enabled" dialog-pref>
<!-- TODO(estade) There's a link in here which should not be inside
a <label>. -->
<span i18n-values=".innerHTML:instantPrefAndWarning"></span>
@@ -283,7 +283,7 @@
<div class="checkbox">
<label id="spelling-label">
<input id="spelling-enabled-control" type="checkbox"
- pref="spellcheck.use_spelling_service">
+ pref="spellcheck.use_spelling_service" dialog-pref>
<span i18n-content="spellingPref"></span>
</label>
</div>
@@ -310,7 +310,7 @@
<div class="checkbox">
<label>
<input id="do-not-track-enabled" pref="enable_do_not_track"
- metric="Options_DoNotTrackCheckbox" type="checkbox">
+ metric="Options_DoNotTrackCheckbox" type="checkbox" dialog-pref>
<span i18n-content="doNotTrack"></span>
</label>
</div>
diff --git a/chrome/browser/resources/options/browser_options.js b/chrome/browser/resources/options/browser_options.js
index 8314ee3..94b268c 100644
--- a/chrome/browser/resources/options/browser_options.js
+++ b/chrome/browser/resources/options/browser_options.js
@@ -25,20 +25,6 @@ cr.define('options', function() {
syncSetupCompleted: false,
/**
- * The cached value of the instant.confirm_dialog_shown preference.
- * @type {bool}
- * @private
- */
- instantConfirmDialogShown_: false,
-
- /**
- * The cached value of the spellcheck.confirm_dialog_shown preference.
- * @type {bool}
- * @private
- */
- spellcheckConfirmDialogShown_: false,
-
- /**
* Keeps track of whether |onShowHomeButtonChanged_| has been called. See
* |onShowHomeButtonChanged_|.
* @type {bool}
@@ -165,15 +151,6 @@ cr.define('options', function() {
};
$('default-search-engine').addEventListener('change',
this.setDefaultSearchEngine_);
- $('instant-enabled-control').customChangeHandler = function(event) {
- if (this.checked && !self.instantConfirmDialogShown_) {
- OptionsPage.showPageByName('instantConfirm', false);
- return true; // Stop default preference processing.
- }
- return false; // Allow default preference processing.
- };
- Preferences.getInstance().addEventListener('instant.confirm_dialog_shown',
- this.onInstantConfirmDialogShownChanged_.bind(this));
// Users section.
if (loadTimeData.valueExists('profilesInfo')) {
@@ -251,20 +228,6 @@ cr.define('options', function() {
OptionsPage.navigateToPage('clearBrowserData');
chrome.send('coreOptionsUserMetricsAction', ['Options_ClearData']);
};
- // 'spelling-enabled-control' element is only present on Chrome branded
- // builds.
- if ($('spelling-enabled-control')) {
- $('spelling-enabled-control').customChangeHandler = function(event) {
- if (this.checked && !self.spellcheckConfirmDialogShown_) {
- OptionsPage.showPageByName('spellingConfirm', false);
- return true;
- }
- return false;
- };
- Preferences.getInstance().addEventListener(
- 'spellcheck.confirm_dialog_shown',
- this.onSpellcheckConfirmDialogShownChanged_.bind(this));
- }
// 'metricsReportingEnabled' element is only present on Chrome branded
// builds.
if ($('metricsReportingEnabled')) {
@@ -273,13 +236,6 @@ cr.define('options', function() {
[String(event.target.checked)]);
};
}
- $('do-not-track-enabled').customChangeHandler = function(event) {
- if (this.checked) {
- OptionsPage.showPageByName('doNotTrackConfirm', false);
- return true;
- }
- return false;
- };
// Bluetooth (CrOS only).
if (cr.isChromeOS) {
@@ -737,26 +693,6 @@ 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;
- },
-
- /**
- * Called when the value of the spellcheck.confirm_dialog_shown preference
- * changes. Cache this value.
- * @param {Event} event Change event.
- * @private
- */
- onSpellcheckConfirmDialogShownChanged_: function(event) {
- this.spellcheckConfirmDialogShown_ = event.value.value;
- },
-
- /**
* Called when the value of the download.default_directory preference
* changes.
* @param {Event} event Change event.
diff --git a/chrome/browser/resources/options/confirm_dialog.js b/chrome/browser/resources/options/confirm_dialog.js
new file mode 100644
index 0000000..10b267a
--- /dev/null
+++ b/chrome/browser/resources/options/confirm_dialog.js
@@ -0,0 +1,110 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+cr.define('options', function() {
+ /** @const */ var OptionsPage = options.OptionsPage;
+
+ /**
+ * A dialog that will pop up when the user attempts to set the value of the
+ * Boolean |pref| to |true|, asking for confirmation. If the user clicks OK,
+ * the new value is committed to Chrome. If the user clicks Cancel or leaves
+ * the settings page, the new value is discarded.
+ * @constructor
+ * @param {string} name See OptionsPage constructor.
+ * @param {string} title See OptionsPage constructor.
+ * @param {string} pageDivName See OptionsPage constructor.
+ * @param {HTMLInputElement} okButton The confirmation button element.
+ * @param {HTMLInputElement} cancelButton The cancellation button element.
+ * @param {string} pref The pref that requires confirmation.
+ * @param {string} metric User metrics identifier.
+ * @param {string} confirmed_pref A pref used to remember whether the user has
+ * confirmed the dialog before. This ensures that the user is presented
+ * with the dialog only once. If left |undefined| or |null|, the dialog
+ * will pop up every time the user attempts to set |pref| to |true|.
+ * @extends {OptionsPage}
+ */
+ function ConfirmDialog(name, title, pageDivName, okButton, cancelButton, pref,
+ metric, confirmed_pref) {
+ OptionsPage.call(this, name, title, pageDivName);
+ this.okButton = okButton;
+ this.cancelButton = cancelButton;
+ this.pref = pref;
+ this.metric = metric;
+ this.confirmed_pref = confirmed_pref;
+ this.confirmed_ = false;
+ }
+
+ ConfirmDialog.prototype = {
+ // Set up the prototype chain
+ __proto__: OptionsPage.prototype,
+
+ /**
+ * Handle changes to |pref|. Only uncommitted changes are relevant as these
+ * originate from user and need to be explicitly committed to take effect.
+ * Pop up the dialog or commit the change, depending on whether confirmation
+ * is needed.
+ * @param {Event} event Change event.
+ * @private
+ */
+ onPrefChanged_: function(event) {
+ if (!event.value.uncommitted)
+ return;
+
+ if (event.value.value && !this.confirmed_)
+ OptionsPage.showPageByName(this.name, false);
+ else
+ Preferences.getInstance().commitPref(this.pref, this.metric);
+ },
+
+ /**
+ * Handle changes to |confirmed_pref| by caching them.
+ * @param {Event} event Change event.
+ * @private
+ */
+ onConfirmedChanged_: function(event) {
+ this.confirmed_ = event.value.value;
+ },
+
+ /**
+ * @inheritDoc
+ */
+ initializePage: function() {
+ this.okButton.onclick = this.handleConfirm.bind(this);
+ this.cancelButton.onclick = this.handleCancel.bind(this);
+ Preferences.getInstance().addEventListener(
+ this.pref, this.onPrefChanged_.bind(this));
+ if (this.confirmed_pref) {
+ Preferences.getInstance().addEventListener(
+ this.confirmed_pref, this.onConfirmedChanged_.bind(this));
+ }
+ },
+
+ /**
+ * Handle the confirm button by committing the |pref| change. If
+ * |confirmed_pref| has been specified, also remember that the dialog has
+ * been confirmed to avoid bringing it up in the future.
+ */
+ handleConfirm: function() {
+ OptionsPage.closeOverlay();
+
+ Preferences.getInstance().commitPref(this.pref, this.metric);
+ if (this.confirmed_pref)
+ Preferences.setBooleanPref(this.confirmed_pref, true, true);
+ },
+
+ /**
+ * Handle the cancel button by rolling back the |pref| change without it
+ * ever taking effect.
+ */
+ handleCancel: function() {
+ OptionsPage.closeOverlay();
+
+ Preferences.getInstance().rollbackPref(this.pref);
+ },
+ };
+
+ return {
+ ConfirmDialog: ConfirmDialog
+ };
+});
diff --git a/chrome/browser/resources/options/do_not_track_confirm_overlay.js b/chrome/browser/resources/options/do_not_track_confirm_overlay.js
deleted file mode 100644
index 868a514..0000000
--- a/chrome/browser/resources/options/do_not_track_confirm_overlay.js
+++ /dev/null
@@ -1,45 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-cr.define('options', function() {
- var SettingsDialog = options.SettingsDialog;
-
- /**
- * DoNotTrackConfirmOverlay class
- * Dialog to confirm that the user really wants to enable Do Not Track.
- * @extends {SettingsDialog}
- */
- function DoNotTrackConfirmOverlay() {
- SettingsDialog.call(
- this,
- 'doNotTrackConfirm',
- loadTimeData.getString('doNotTrackConfirmOverlayTabTitle'),
- 'do-not-track-confirm-overlay',
- $('do-not-track-confirm-ok'),
- $('do-not-track-confirm-cancel'));
- };
-
- cr.addSingletonGetter(DoNotTrackConfirmOverlay);
-
- DoNotTrackConfirmOverlay.prototype = {
- __proto__: SettingsDialog.prototype,
-
- /** @inheritDoc */
- handleConfirm: function() {
- SettingsDialog.prototype.handleConfirm.call(this);
- Preferences.setBooleanPref('enable_do_not_track', true, true);
- },
-
- /** @inheritDoc */
- handleCancel: function() {
- SettingsDialog.prototype.handleCancel.call(this);
- $('do-not-track-enabled').checked = false;
- },
- };
-
- // Export
- return {
- DoNotTrackConfirmOverlay: DoNotTrackConfirmOverlay
- };
-});
diff --git a/chrome/browser/resources/options/instant_confirm_overlay.js b/chrome/browser/resources/options/instant_confirm_overlay.js
deleted file mode 100644
index db0a37e..0000000
--- a/chrome/browser/resources/options/instant_confirm_overlay.js
+++ /dev/null
@@ -1,50 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-cr.define('options', function() {
- var SettingsDialog = options.SettingsDialog;
-
- /*
- * InstantConfirmOverlay class
- * Dialog to confirm that the user really wants to enable Chrome Instant.
- * @extends {SettingsDialog}
- */
- function InstantConfirmOverlay() {
- SettingsDialog.call(this,
- 'instantConfirm',
- loadTimeData.getString('instantConfirmOverlayTabTitle'),
- 'instantConfirmOverlay',
- $('instantConfirmOk'),
- $('instantConfirmCancel'));
- };
-
- cr.addSingletonGetter(InstantConfirmOverlay);
-
- InstantConfirmOverlay.prototype = {
- __proto__: SettingsDialog.prototype,
-
- /** @inheritDoc */
- initializePage: function() {
- SettingsDialog.prototype.initializePage.call(this);
- },
-
- /** @inheritDoc */
- handleConfirm: function() {
- SettingsDialog.prototype.handleConfirm.call(this);
- Preferences.setBooleanPref('instant.confirm_dialog_shown', true, true);
- Preferences.setBooleanPref('instant.enabled', true, true);
- },
-
- /** @inheritDoc */
- handleCancel: function() {
- SettingsDialog.prototype.handleCancel.call(this);
- $('instant-enabled-control').checked = false;
- },
- };
-
- // Export
- return {
- InstantConfirmOverlay: InstantConfirmOverlay
- };
-});
diff --git a/chrome/browser/resources/options/options.js b/chrome/browser/resources/options/options.js
index 8a300e3..6c012fb 100644
--- a/chrome/browser/resources/options/options.js
+++ b/chrome/browser/resources/options/options.js
@@ -9,18 +9,17 @@ var AutofillEditCreditCardOverlay = options.AutofillEditCreditCardOverlay;
var AutofillOptions = options.AutofillOptions;
var BrowserOptions = options.BrowserOptions;
var ClearBrowserDataOverlay = options.ClearBrowserDataOverlay;
+var ConfirmDialog = options.ConfirmDialog;
var ContentSettings = options.ContentSettings;
var ContentSettingsExceptionsArea =
options.contentSettings.ContentSettingsExceptionsArea;
var CookiesView = options.CookiesView;
var CookiesViewApp = options.CookiesViewApp;
-var DoNotTrackConfirmOverlay = options.DoNotTrackConfirmOverlay;
var FactoryResetOverlay = options.FactoryResetOverlay;
var FontSettings = options.FontSettings;
var HandlerOptions = options.HandlerOptions;
var HomePageOverlay = options.HomePageOverlay;
var ImportDataOverlay = options.ImportDataOverlay;
-var InstantConfirmOverlay = options.InstantConfirmOverlay;
var LanguageOptions = options.LanguageOptions;
var MediaGalleriesManager = options.MediaGalleriesManager;
var OptionsFocusManager = options.OptionsFocusManager;
@@ -31,7 +30,6 @@ var PreferredNetworks = options.PreferredNetworks;
var ManageProfileOverlay = options.ManageProfileOverlay;
var SearchEngineManager = options.SearchEngineManager;
var SearchPage = options.SearchPage;
-var SpellingConfirmOverlay = options.SpellingConfirmOverlay;
var StartupOverlay = options.StartupOverlay;
var SyncSetupOverlay = options.SyncSetupOverlay;
@@ -73,6 +71,36 @@ function load() {
OptionsPage.registerOverlay(ClearBrowserDataOverlay.getInstance(),
BrowserOptions.getInstance(),
[$('privacyClearDataButton')]);
+ OptionsPage.registerOverlay(new ConfirmDialog(
+ 'doNotTrackConfirm',
+ loadTimeData.getString('doNotTrackConfirmOverlayTabTitle'),
+ 'do-not-track-confirm-overlay',
+ $('do-not-track-confirm-ok'),
+ $('do-not-track-confirm-cancel'),
+ $('do-not-track-enabled').pref,
+ $('do-not-track-enabled').metric));
+ OptionsPage.registerOverlay(new ConfirmDialog(
+ 'instantConfirm',
+ loadTimeData.getString('instantConfirmOverlayTabTitle'),
+ 'instantConfirmOverlay',
+ $('instantConfirmOk'),
+ $('instantConfirmCancel'),
+ $('instant-enabled-control').pref,
+ $('instant-enabled-control').metric,
+ 'instant.confirm_dialog_shown'));
+ // 'spelling-enabled-control' element is only present on Chrome branded
+ // builds.
+ if ($('spelling-enabled-control')) {
+ OptionsPage.registerOverlay(new ConfirmDialog(
+ 'spellingConfirm',
+ loadTimeData.getString('spellingConfirmOverlayTabTitle'),
+ 'spelling-confirm-overlay',
+ $('spelling-confirm-ok'),
+ $('spelling-confirm-cancel'),
+ $('spelling-enabled-control').pref,
+ $('spelling-enabled-control').metric,
+ 'spellcheck.confirm_dialog_shown'));
+ }
OptionsPage.registerOverlay(ContentSettings.getInstance(),
BrowserOptions.getInstance(),
[$('privacyContentSettingsButton')]);
@@ -85,8 +113,6 @@ function load() {
OptionsPage.registerOverlay(CookiesViewApp.getInstance(),
ContentSettings.getInstance(),
[$('privacyContentSettingsButton')]);
- OptionsPage.registerOverlay(DoNotTrackConfirmOverlay.getInstance(),
- BrowserOptions.getInstance());
OptionsPage.registerOverlay(FontSettings.getInstance(),
BrowserOptions.getInstance(),
[$('fontSettingsCustomizeFontsButton')]);
@@ -100,8 +126,6 @@ function load() {
[$('change-home-page')]);
OptionsPage.registerOverlay(ImportDataOverlay.getInstance(),
BrowserOptions.getInstance());
- OptionsPage.registerOverlay(InstantConfirmOverlay.getInstance(),
- BrowserOptions.getInstance());
OptionsPage.registerOverlay(LanguageOptions.getInstance(),
BrowserOptions.getInstance(),
[$('language-button')]);
@@ -116,8 +140,6 @@ function load() {
OptionsPage.registerOverlay(SearchEngineManager.getInstance(),
BrowserOptions.getInstance(),
[$('manage-default-search-engines')]);
- OptionsPage.registerOverlay(SpellingConfirmOverlay.getInstance(),
- BrowserOptions.getInstance());
OptionsPage.registerOverlay(StartupOverlay.getInstance(),
BrowserOptions.getInstance());
OptionsPage.registerOverlay(SyncSetupOverlay.getInstance(),
diff --git a/chrome/browser/resources/options/options_bundle.js b/chrome/browser/resources/options/options_bundle.js
index b61b9dd..0f2e662 100644
--- a/chrome/browser/resources/options/options_bundle.js
+++ b/chrome/browser/resources/options/options_bundle.js
@@ -68,6 +68,7 @@
<include src="browser_options_profile_list.js"></include>
<include src="browser_options_startup_page_list.js"></include>
<include src="clear_browser_data_overlay.js"></include>
+<include src="confirm_dialog.js"></include>
<include src="content_settings.js"></include>
<include src="content_settings2.js"></include>
<include src="content_settings_exceptions_area.js"></include>
@@ -75,14 +76,12 @@
<include src="cookies_list.js"></include>
<include src="cookies_view.js"></include>
<include src="cookies_view_app.js"></include>
-<include src="do_not_track_confirm_overlay.js"></include>
<include src="factory_reset_overlay.js"></include>
<include src="font_settings.js"></include>
<include src="handler_options.js"></include>
<include src="handler_options_list.js"></include>
<include src="home_page_overlay.js"></include>
<include src="import_data_overlay.js"></include>
-<include src="instant_confirm_overlay.js"></include>
<include src="language_add_language_overlay.js"></include>
<include src="language_list.js"></include>
<include src="language_options.js"></include>
@@ -96,7 +95,6 @@
<include src="search_engine_manager.js"></include>
<include src="search_engine_manager_engine_list.js"></include>
<include src="search_page.js"></include>
-<include src="spelling_confirm_overlay.js"></include>
<include src="startup_overlay.js"></include>
<include src="../sync_setup_overlay.js"></include>
<include src="../uber/uber_utils.js"></include>
diff --git a/chrome/browser/resources/options/spelling_confirm_overlay.js b/chrome/browser/resources/options/spelling_confirm_overlay.js
deleted file mode 100644
index 2458d0c..0000000
--- a/chrome/browser/resources/options/spelling_confirm_overlay.js
+++ /dev/null
@@ -1,53 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-cr.define('options', function() {
- var SettingsDialog = options.SettingsDialog;
-
- /*
- * SpellingConfirmOverlay class
- * Dialog to confirm that the user really wants to use the Spelling service
- * @extends {SettingsDialog}
- */
- function SpellingConfirmOverlay() {
- SettingsDialog.call(
- this,
- 'spellingConfirm',
- loadTimeData.getString('spellingConfirmOverlayTabTitle'),
- 'spelling-confirm-overlay',
- $('spelling-confirm-ok'),
- $('spelling-confirm-cancel'));
- };
-
- cr.addSingletonGetter(SpellingConfirmOverlay);
-
- SpellingConfirmOverlay.prototype = {
- __proto__: SettingsDialog.prototype,
-
- /** @inheritDoc */
- initializePage: function() {
- SettingsDialog.prototype.initializePage.call(this);
- },
-
- /** @inheritDoc */
- handleConfirm: function() {
- SettingsDialog.prototype.handleConfirm.call(this);
- Preferences.setBooleanPref('spellcheck.use_spelling_service',
- true, true);
- Preferences.setBooleanPref('spellcheck.confirm_dialog_shown',
- true, true);
- },
-
- /** @inheritDoc */
- handleCancel: function() {
- SettingsDialog.prototype.handleCancel.call(this);
- $('spelling-enabled-control').checked = false;
- },
- };
-
- // Export
- return {
- SpellingConfirmOverlay: SpellingConfirmOverlay
- };
-});
diff --git a/chrome/browser/ui/webui/options/options_browsertest.js b/chrome/browser/ui/webui/options/options_browsertest.js
index 08b4ff4..8a5f1cd 100644
--- a/chrome/browser/ui/webui/options/options_browsertest.js
+++ b/chrome/browser/ui/webui/options/options_browsertest.js
@@ -114,10 +114,11 @@ TEST_F('OptionsWebUITest', 'testDefaultZoomFactor', function() {
// interstitial is pressed, otherwise the abort button is pressed.
OptionsWebUITest.prototype.testDoNotTrackInterstitial =
function(confirmInterstitial) {
+ Preferences.prefsFetchedCallback({'enable_do_not_track': {'value': false } });
var buttonToClick = confirmInterstitial ? $('do-not-track-confirm-ok')
: $('do-not-track-confirm-cancel');
var dntCheckbox = $('do-not-track-enabled');
- var dntOverlay = DoNotTrackConfirmOverlay.getInstance();
+ var dntOverlay = OptionsPage.registeredOverlayPages['donottrackconfirm'];
assertFalse(dntCheckbox.checked);
var visibleChangeCounter = 0;
@@ -134,8 +135,7 @@ OptionsWebUITest.prototype.testDoNotTrackInterstitial =
window.setTimeout(function() {
assertFalse(dntOverlay.visible);
assertEquals(confirmInterstitial, dntCheckbox.checked);
- DoNotTrackConfirmOverlay.getInstance().removeEventListener(
- visibleChangeHandler);
+ dntOverlay.removeEventListener(visibleChangeHandler);
testDone();
}, 0);
break;
@@ -143,12 +143,11 @@ OptionsWebUITest.prototype.testDoNotTrackInterstitial =
assertTrue(false);
}
}
- DoNotTrackConfirmOverlay.getInstance().addEventListener('visibleChange',
- visibleChangeHandler);
+ dntOverlay.addEventListener('visibleChange', visibleChangeHandler);
if (confirmInterstitial) {
this.mockHandler.expects(once()).setBooleanPref(
- ["enable_do_not_track", true]);
+ ['enable_do_not_track', true, 'Options_DoNotTrackCheckbox']);
} else {
// The mock handler complains if setBooleanPref is called even though
// it should not be.
@@ -170,8 +169,9 @@ TEST_F('OptionsWebUITest', 'EnableDoNotTrackAndCancelInterstitial',
// Check that the "Do not Track" preference can be correctly disabled.
// In order to do that, we need to enable it first.
TEST_F('OptionsWebUITest', 'EnableAndDisableDoNotTrack', function() {
+ Preferences.prefsFetchedCallback({'enable_do_not_track': {'value': false } });
var dntCheckbox = $('do-not-track-enabled');
- var dntOverlay = DoNotTrackConfirmOverlay.getInstance();
+ var dntOverlay = OptionsPage.registeredOverlayPages['donottrackconfirm'];
assertFalse(dntCheckbox.checked);
var visibleChangeCounter = 0;
@@ -188,8 +188,7 @@ TEST_F('OptionsWebUITest', 'EnableAndDisableDoNotTrack', function() {
window.setTimeout(function() {
assertFalse(dntOverlay.visible);
assertTrue(dntCheckbox.checked);
- DoNotTrackConfirmOverlay.getInstance().removeEventListener(
- visibleChangeHandler);
+ dntOverlay.removeEventListener(visibleChangeHandler);
dntCheckbox.click();
}, 0);
break;
@@ -197,11 +196,10 @@ TEST_F('OptionsWebUITest', 'EnableAndDisableDoNotTrack', function() {
assertNotReached();
}
}
- DoNotTrackConfirmOverlay.getInstance().addEventListener('visibleChange',
- visibleChangeHandler);
+ dntOverlay.addEventListener('visibleChange', visibleChangeHandler);
this.mockHandler.expects(once()).setBooleanPref(
- eq(["enable_do_not_track", true]));
+ eq(["enable_do_not_track", true, 'Options_DoNotTrackCheckbox']));
var verifyCorrectEndState = function() {
window.setTimeout(function() {