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

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 2013 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++)
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 sel =
60 '#reset-profile-settings-content-area input[type=checkbox]:checked';
61 $('reset-profile-settings-commit').disabled =
62 !document.querySelector(sel);
63 },
64 };
65
66 /**
67 * Enables/disables UI elements after/while Chrome is performing a reset.
68 * @param {boolean} state If true, UI elements are disabled.
69 */
70 ResetProfileSettingsOverlay.setResettingState = function(state) {
71 $('reset-default-search-engine-checkbox').disabled = state;
72 $('reset-homepage-checkbox').disabled = state;
73 $('reset-content-settings-checkbox').disabled = state;
74 $('reset-cookies-and-site-data-checkbox').disabled = state;
75 $('reset-extensions-checkbox').disabled = state;
76 $('reset-extensions-handling').disabled = state;
77 $('reset-profile-settings-throbber').style.visibility =
78 state ? 'visible' : 'hidden';
79 $('reset-profile-settings-dismiss').disabled = state;
80
81 if (state)
82 $('reset-profile-settings-commit').disabled = true;
83 else
84 ResetProfileSettingsOverlay.getInstance().updateCommitButtonState_();
85 };
86
87 /**
88 * Chrome callback to notify ResetProfileSettingsOverlay that the reset
89 * operation has terminated.
90 */
91 ResetProfileSettingsOverlay.doneResetting = function() {
92 // The delay gives the user some feedback that the resetting
93 // actually worked. Otherwise the dialog just vanishes instantly in most
94 // cases.
95 window.setTimeout(function() {
96 ResetProfileSettingsOverlay.dismiss();
97 }, 200);
98 };
99
100 /**
101 * Dismisses the overlay.
102 */
103 ResetProfileSettingsOverlay.dismiss = function() {
104 OptionsPage.closeOverlay();
105 ResetProfileSettingsOverlay.setResettingState(false);
106 };
107
108 // Export
109 return {
110 ResetProfileSettingsOverlay: ResetProfileSettingsOverlay
111 };
112 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/options/reset_profile_settings_overlay.html ('k') | chrome/browser/ui/browser_ui_prefs.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698