OLD | NEW |
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 Page constructor. | 14 * @param {string} name See Page constructor. |
15 * @param {string} title See Page constructor. | 15 * @param {string} title See Page constructor. |
16 * @param {string} pageDivName See Page constructor. | 16 * @param {string} pageDivName See Page constructor. |
17 * @param {HTMLButtonElement} okButton The confirmation button element. | 17 * @param {HTMLButtonElement} okButton The confirmation button element. |
18 * @param {HTMLButtonElement} cancelButton The cancellation button element. | 18 * @param {HTMLButtonElement} 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=} opt_confirmedPref A pref used to remember whether the | 21 * @param {string=} opt_confirmedPref A pref used to remember whether the |
22 * user has confirmed the dialog before. This ensures that the user is | 22 * user has confirmed the dialog before. This ensures that the user is |
23 * presented with the dialog only once. If left |undefined|, the dialog | 23 * presented with the dialog only once. If left |undefined|, 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 * @param {boolean=} opt_confirmValue The value to which changing should | 25 * @param {boolean=} opt_confirmValue The value to which changing should |
26 * trigger the confirmation dialog. Defaults to |true| if left | 26 * trigger the confirmation dialog. Defaults to |true| if left |
27 * |undefined|. | 27 * |undefined|. |
28 * @extends {options.SettingsDialog} | 28 * @extends {options.SettingsDialog} |
29 */ | 29 */ |
30 function ConfirmDialog(name, title, pageDivName, okButton, cancelButton, pref, | 30 function ConfirmDialog( |
31 metric, opt_confirmedPref, opt_confirmValue) { | 31 name, title, pageDivName, okButton, cancelButton, pref, metric, |
| 32 opt_confirmedPref, opt_confirmValue) { |
32 SettingsDialog.call(this, name, title, pageDivName, okButton, cancelButton); | 33 SettingsDialog.call(this, name, title, pageDivName, okButton, cancelButton); |
33 | 34 |
34 /** @protected */ | 35 /** @protected */ |
35 this.pref = pref; | 36 this.pref = pref; |
36 | 37 |
37 /** @protected */ | 38 /** @protected */ |
38 this.metric = metric; | 39 this.metric = metric; |
39 | 40 |
40 /** @private */ | 41 /** @private */ |
41 this.confirmedPref_ = opt_confirmedPref; | 42 this.confirmedPref_ = opt_confirmedPref; |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 * When a user navigates away from a confirm dialog, treat as a cancel. | 122 * When a user navigates away from a confirm dialog, treat as a cancel. |
122 * @protected | 123 * @protected |
123 * @override | 124 * @override |
124 */ | 125 */ |
125 willHidePage: function() { | 126 willHidePage: function() { |
126 if (this.visible) | 127 if (this.visible) |
127 Preferences.getInstance().rollbackPref(this.pref); | 128 Preferences.getInstance().rollbackPref(this.pref); |
128 }, | 129 }, |
129 }; | 130 }; |
130 | 131 |
131 return { | 132 return {ConfirmDialog: ConfirmDialog}; |
132 ConfirmDialog: ConfirmDialog | |
133 }; | |
134 }); | 133 }); |
OLD | NEW |