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 /** | 5 /** |
6 * @fileoverview Base class for dialogs that require saving preferences on | 6 * @fileoverview Base class for dialogs that require saving preferences on |
7 * confirm and resetting preference inputs on cancel. | 7 * confirm and resetting preference inputs on cancel. |
8 */ | 8 */ |
9 | 9 |
10 cr.define('options', function() { | 10 cr.define('options', function() { |
(...skipping 25 matching lines...) Expand all Loading... |
36 this.okButton.onclick = this.handleConfirm.bind(this); | 36 this.okButton.onclick = this.handleConfirm.bind(this); |
37 this.cancelButton.onclick = this.handleCancel.bind(this); | 37 this.cancelButton.onclick = this.handleCancel.bind(this); |
38 }, | 38 }, |
39 | 39 |
40 /** | 40 /** |
41 * Handles the confirm button by saving the dialog preferences. | 41 * Handles the confirm button by saving the dialog preferences. |
42 */ | 42 */ |
43 handleConfirm: function() { | 43 handleConfirm: function() { |
44 OptionsPage.closeOverlay(); | 44 OptionsPage.closeOverlay(); |
45 | 45 |
| 46 var prefs = Preferences.getInstance(); |
46 var els = this.pageDiv.querySelectorAll('[dialog-pref]'); | 47 var els = this.pageDiv.querySelectorAll('[dialog-pref]'); |
47 for (var i = 0; i < els.length; i++) { | 48 for (var i = 0; i < els.length; i++) { |
48 if (els[i].savePrefState) | 49 if (els[i].pref) |
49 els[i].savePrefState(); | 50 prefs.commitPref(els[i].pref, els[i].metric); |
50 } | 51 } |
51 }, | 52 }, |
52 | 53 |
53 /** | 54 /** |
54 * Handles the cancel button by closing the overlay. | 55 * Handles the cancel button by closing the overlay. |
55 */ | 56 */ |
56 handleCancel: function() { | 57 handleCancel: function() { |
57 OptionsPage.closeOverlay(); | 58 OptionsPage.closeOverlay(); |
58 | 59 |
| 60 var prefs = Preferences.getInstance(); |
59 var els = this.pageDiv.querySelectorAll('[dialog-pref]'); | 61 var els = this.pageDiv.querySelectorAll('[dialog-pref]'); |
60 for (var i = 0; i < els.length; i++) { | 62 for (var i = 0; i < els.length; i++) { |
61 if (els[i].resetPrefState) | 63 if (els[i].pref) |
62 els[i].resetPrefState(); | 64 prefs.rollbackPref(els[i].pref); |
63 } | 65 } |
64 }, | 66 }, |
65 }; | 67 }; |
66 | 68 |
67 return { | 69 return { |
68 SettingsDialog: SettingsDialog | 70 SettingsDialog: SettingsDialog |
69 }; | 71 }; |
70 }); | 72 }); |
OLD | NEW |