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

Side by Side Diff: chrome/browser/resources/options/confirm_dialog.js

Issue 410293004: Split OptionsPage into Page and PageManager (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed feedback Created 6 years, 4 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 cr.define('options', function() { 5 cr.define('options', function() {
6 /** @const */ var SettingsDialog = options.SettingsDialog; 6 /** @const */ var SettingsDialog = options.SettingsDialog;
7 7
8 /** 8 /**
9 * A dialog that will pop up when the user attempts to set the value of the 9 * A dialog that will pop up when the user attempts to set the value of the
10 * Boolean |pref| to |true|, asking for confirmation. If the user clicks OK, 10 * Boolean |pref| to |true|, asking for confirmation. If the user clicks OK,
11 * the new value is committed to Chrome. If the user clicks Cancel or leaves 11 * the new value is committed to Chrome. If the user clicks Cancel or leaves
12 * the settings page, the new value is discarded. 12 * the settings page, the new value is discarded.
13 * @constructor 13 * @constructor
14 * @param {string} name See OptionsPage constructor. 14 * @param {string} name See Page constructor.
15 * @param {string} title See OptionsPage constructor. 15 * @param {string} title See Page constructor.
16 * @param {string} pageDivName See OptionsPage constructor. 16 * @param {string} pageDivName See Page constructor.
17 * @param {HTMLInputElement} okButton The confirmation button element. 17 * @param {HTMLInputElement} okButton The confirmation button element.
18 * @param {HTMLInputElement} cancelButton The cancellation button element. 18 * @param {HTMLInputElement} cancelButton The cancellation button element.
19 * @param {string} pref The pref that requires confirmation. 19 * @param {string} pref The pref that requires confirmation.
20 * @param {string} metric User metrics identifier. 20 * @param {string} metric User metrics identifier.
21 * @param {string} confirmed_pref A pref used to remember whether the user has 21 * @param {string} confirmed_pref A pref used to remember whether the user has
22 * confirmed the dialog before. This ensures that the user is presented 22 * confirmed the dialog before. This ensures that the user is presented
23 * with the dialog only once. If left |undefined| or |null|, the dialog 23 * with the dialog only once. If left |undefined| or |null|, the dialog
24 * will pop up every time the user attempts to set |pref| to |true|. 24 * will pop up every time the user attempts to set |pref| to |true|.
25 * @extends {SettingsDialog} 25 * @extends {SettingsDialog}
26 */ 26 */
(...skipping 16 matching lines...) Expand all
43 * Pop up the dialog or commit the change, depending on whether confirmation 43 * Pop up the dialog or commit the change, depending on whether confirmation
44 * is needed. 44 * is needed.
45 * @param {Event} event Change event. 45 * @param {Event} event Change event.
46 * @private 46 * @private
47 */ 47 */
48 onPrefChanged_: function(event) { 48 onPrefChanged_: function(event) {
49 if (!event.value.uncommitted) 49 if (!event.value.uncommitted)
50 return; 50 return;
51 51
52 if (event.value.value && !this.confirmed_) 52 if (event.value.value && !this.confirmed_)
53 OptionsPage.showPageByName(this.name, false); 53 PageManager.showPageByName(this.name, false);
54 else 54 else
55 Preferences.getInstance().commitPref(this.pref, this.metric); 55 Preferences.getInstance().commitPref(this.pref, this.metric);
56 }, 56 },
57 57
58 /** 58 /**
59 * Handle changes to |confirmed_pref| by caching them. 59 * Handle changes to |confirmed_pref| by caching them.
60 * @param {Event} event Change event. 60 * @param {Event} event Change event.
61 * @private 61 * @private
62 */ 62 */
63 onConfirmedChanged_: function(event) { 63 onConfirmedChanged_: function(event) {
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 willHidePage: function() { 110 willHidePage: function() {
111 if (this.visible) 111 if (this.visible)
112 Preferences.getInstance().rollbackPref(this.pref); 112 Preferences.getInstance().rollbackPref(this.pref);
113 }, 113 },
114 }; 114 };
115 115
116 return { 116 return {
117 ConfirmDialog: ConfirmDialog 117 ConfirmDialog: ConfirmDialog
118 }; 118 };
119 }); 119 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698