OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 cr.define('options', function() { | |
6 var OptionsPage = options.OptionsPage; | |
7 | |
8 /** | |
9 * ResetProfileSettingsOverlay class | |
10 * Encapsulated handling of the 'Reset Profile Settings' overlay page. | |
11 * @class | |
12 */ | |
13 function ResetProfileSettingsOverlay() { | |
14 OptionsPage.call( | |
15 this, 'resetProfileSettings', | |
16 loadTimeData.getString('resetProfileSettingsOverlayTabTitle'), | |
17 'reset-profile-settings-overlay'); | |
18 } | |
19 | |
20 cr.addSingletonGetter(ResetProfileSettingsOverlay); | |
21 | |
22 ResetProfileSettingsOverlay.prototype = { | |
23 // Inherit ResetProfileSettingsOverlay from OptionsPage. | |
24 __proto__: OptionsPage.prototype, | |
25 | |
26 /** | |
27 * Initialize the page. | |
28 */ | |
29 initializePage: function() { | |
30 // Call base class implementation to starts preference initialization. | |
James Hawkins
2013/05/13 17:31:33
Optional nit: I think this comment is superfluous.
battre
2013/05/21 09:25:08
Done.
| |
31 OptionsPage.prototype.initializePage.call(this); | |
32 | |
33 var f = this.updateCommitButtonState_.bind(this); | |
34 var types = ['browser.reset_profile_settings.default_search_engine', | |
35 'browser.reset_profile_settings.homepage', | |
36 'browser.reset_profile_settings.content_settings', | |
37 'browser.reset_profile_settings.cookies_and_site_data', | |
38 'browser.reset_profile_settings.extensions']; | |
39 types.forEach(function(type) { | |
40 Preferences.getInstance().addEventListener(type, f); | |
41 }); | |
42 | |
43 var checkboxes = document.querySelectorAll( | |
44 '#reset-profile-settings-content-area input[type=checkbox]'); | |
45 for (var i = 0; i < checkboxes.length; i++) { | |
James Hawkins
2013/05/13 17:31:33
nit: No braces for single-line blocks.
battre
2013/05/21 09:25:08
Done.
| |
46 checkboxes[i].onclick = f; | |
47 } | |
48 this.updateCommitButtonState_(); | |
49 | |
50 $('reset-profile-settings-dismiss').onclick = function(event) { | |
51 ResetProfileSettingsOverlay.dismiss(); | |
52 }; | |
53 $('reset-profile-settings-commit').onclick = function(event) { | |
54 ResetProfileSettingsOverlay.setResettingState(true); | |
55 chrome.send('performResetProfileSettings'); | |
56 }; | |
57 }, | |
58 | |
59 // Set the enabled state of the commit button. | |
James Hawkins
2013/05/13 17:31:33
nit: Sets
battre
2013/05/21 09:25:08
Done.
| |
60 updateCommitButtonState_: function() { | |
61 var checkboxes = document.querySelectorAll( | |
62 '#reset-profile-settings-content-area input[type=checkbox]'); | |
63 var isChecked = false; | |
64 for (var i = 0; i < checkboxes.length; i++) { | |
65 if (checkboxes[i].checked) { | |
66 isChecked = true; | |
67 break; | |
68 } | |
69 } | |
70 $('reset-profile-settings-commit').disabled = !isChecked; | |
71 }, | |
72 }; | |
73 | |
74 // | |
75 // Chrome callbacks | |
James Hawkins
2013/05/13 17:31:33
nit: Unless you want to make these forward to docu
battre
2013/05/21 09:25:08
Done.
| |
76 // | |
77 ResetProfileSettingsOverlay.setResettingState = function(state) { | |
78 $('reset-default-search-engine-checkbox').disabled = state; | |
79 $('reset-homepage-checkbox').disabled = state; | |
80 $('reset-content-settings-checkbox').disabled = state; | |
81 $('reset-cookies-and-site-data-checkbox').disabled = state; | |
82 $('reset-extensions-checkbox').disabled = state; | |
83 $('reset-extensions-handling').disabled = state; | |
84 $('reset-profile-settings-throbber').style.visibility = | |
85 state ? 'visible' : 'hidden'; | |
86 $('reset-profile-settings-dismiss').disabled = state; | |
87 | |
88 if (state) | |
89 $('reset-profile-settings-commit').disabled = true; | |
90 else | |
91 ResetProfileSettingsOverlay.getInstance().updateCommitButtonState_(); | |
92 }; | |
93 | |
94 ResetProfileSettingsOverlay.doneResetting = function() { | |
95 // The delay gives the user some feedback that the resetting | |
96 // actually worked. Otherwise the dialog just vanishes instantly in most | |
97 // cases. | |
98 window.setTimeout(function() { | |
99 ResetProfileSettingsOverlay.dismiss(); | |
100 }, 200); | |
101 }; | |
102 | |
103 ResetProfileSettingsOverlay.dismiss = function() { | |
104 OptionsPage.closeOverlay(); | |
105 this.setResettingState(false); | |
106 }; | |
107 | |
108 // Export | |
109 return { | |
110 ResetProfileSettingsOverlay: ResetProfileSettingsOverlay | |
111 }; | |
112 }); | |
OLD | NEW |