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

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

Issue 14924002: WebUI for Profile Settings Reset (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed comments Created 7 years, 7 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
(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 OptionsPage.prototype.initializePage.call(this);
31
32 var f = this.updateCommitButtonState_.bind(this);
33 var types = ['browser.reset_profile_settings.default_search_engine',
34 'browser.reset_profile_settings.homepage',
35 'browser.reset_profile_settings.content_settings',
36 'browser.reset_profile_settings.cookies_and_site_data',
37 'browser.reset_profile_settings.extensions'];
38 types.forEach(function(type) {
39 Preferences.getInstance().addEventListener(type, f);
40 });
41
42 var checkboxes = document.querySelectorAll(
43 '#reset-profile-settings-content-area input[type=checkbox]');
44 for (var i = 0; i < checkboxes.length; i++)
Dan Beam 2013/05/23 19:46:43 nit: curlies
James Hawkins 2013/05/23 20:06:42 Not required for single line blocks.
Dan Beam 2013/05/23 21:37:34 I think that only applies to conditionals -- http:
45 checkboxes[i].onclick = f;
46 this.updateCommitButtonState_();
47
48 $('reset-profile-settings-dismiss').onclick = function(event) {
49 ResetProfileSettingsOverlay.dismiss();
50 };
51 $('reset-profile-settings-commit').onclick = function(event) {
52 ResetProfileSettingsOverlay.setResettingState(true);
53 chrome.send('performResetProfileSettings');
54 };
55 },
56
57 // Sets the enabled state of the commit button.
58 updateCommitButtonState_: function() {
59 var checkboxes = document.querySelectorAll(
60 '#reset-profile-settings-content-area input[type=checkbox]');
Dan Beam 2013/05/23 19:46:43 var sel = '#reset-profile-settings-content-area in
battre 2013/05/24 09:15:46 Done.
61 var isChecked = false;
62 for (var i = 0; i < checkboxes.length; i++) {
63 if (checkboxes[i].checked) {
64 isChecked = true;
65 break;
66 }
67 }
68 $('reset-profile-settings-commit').disabled = !isChecked;
69 },
70 };
71
72 /**
73 * Enables/disables UI elements after/while Chrome is performing a reset.
74 * @param {boolean} state If true, UI elements are disabled.
75 */
76 ResetProfileSettingsOverlay.setResettingState = function(state) {
77 $('reset-default-search-engine-checkbox').disabled = state;
78 $('reset-homepage-checkbox').disabled = state;
79 $('reset-content-settings-checkbox').disabled = state;
80 $('reset-cookies-and-site-data-checkbox').disabled = state;
81 $('reset-extensions-checkbox').disabled = state;
82 $('reset-extensions-handling').disabled = state;
83 $('reset-profile-settings-throbber').style.visibility =
84 state ? 'visible' : 'hidden';
85 $('reset-profile-settings-dismiss').disabled = state;
86
87 if (state)
88 $('reset-profile-settings-commit').disabled = true;
89 else
90 ResetProfileSettingsOverlay.getInstance().updateCommitButtonState_();
91 };
92
93 /**
94 * Chrome callback to notify ResetProfileSettingsOverlay that the reset
95 * operation has terminated.
96 */
97 ResetProfileSettingsOverlay.doneResetting = function() {
98 // The delay gives the user some feedback that the resetting
99 // actually worked. Otherwise the dialog just vanishes instantly in most
100 // cases.
101 window.setTimeout(function() {
102 ResetProfileSettingsOverlay.dismiss();
103 }, 200);
104 };
105
106 /**
107 * Dismisses the overlay.
108 */
109 ResetProfileSettingsOverlay.dismiss = function() {
110 OptionsPage.closeOverlay();
111 ResetProfileSettingsOverlay.setResettingState(false);
112 };
113
114 // Export
115 return {
116 ResetProfileSettingsOverlay: ResetProfileSettingsOverlay
117 };
118 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698