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

Unified 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: Fix browser test 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/resources/options/reset_profile_settings_overlay.js
diff --git a/chrome/browser/resources/options/reset_profile_settings_overlay.js b/chrome/browser/resources/options/reset_profile_settings_overlay.js
new file mode 100644
index 0000000000000000000000000000000000000000..5a70442f15f26156a0b4bc20a56d28057c07d0af
--- /dev/null
+++ b/chrome/browser/resources/options/reset_profile_settings_overlay.js
@@ -0,0 +1,112 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+cr.define('options', function() {
+ var OptionsPage = options.OptionsPage;
+
+ /**
+ * ResetProfileSettingsOverlay class
+ * Encapsulated handling of the 'Reset Profile Settings' overlay page.
+ * @class
+ */
+ function ResetProfileSettingsOverlay() {
+ OptionsPage.call(
+ this, 'resetProfileSettings',
+ loadTimeData.getString('resetProfileSettingsOverlayTabTitle'),
+ 'reset-profile-settings-overlay');
+ }
+
+ cr.addSingletonGetter(ResetProfileSettingsOverlay);
+
+ ResetProfileSettingsOverlay.prototype = {
+ // Inherit ResetProfileSettingsOverlay from OptionsPage.
+ __proto__: OptionsPage.prototype,
+
+ /**
+ * Initialize the page.
+ */
+ initializePage: function() {
+ // Call base class implementation to starts preference initialization.
+ OptionsPage.prototype.initializePage.call(this);
+
+ var f = this.updateCommitButtonState_.bind(this);
+ var types = ['browser.reset_profile_settings.default_search_engine',
+ 'browser.reset_profile_settings.homepage',
+ 'browser.reset_profile_settings.content_settings',
+ 'browser.reset_profile_settings.cookies_and_site_data',
+ 'browser.reset_profile_settings.extensions'];
+ types.forEach(function(type) {
+ Preferences.getInstance().addEventListener(type, f);
+ });
+
+ var checkboxes = document.querySelectorAll(
+ '#reset-profile-settings-content-area input[type=checkbox]');
+ for (var i = 0; i < checkboxes.length; i++) {
+ checkboxes[i].onclick = f;
+ }
+ this.updateCommitButtonState_();
+
+ $('reset-profile-settings-dismiss').onclick = function(event) {
+ ResetProfileSettingsOverlay.dismiss();
+ };
+ $('reset-profile-settings-commit').onclick = function(event) {
+ ResetProfileSettingsOverlay.setResettingState(true);
+ chrome.send('performResetProfileSettings');
+ };
+ },
+
+ // Set the enabled state of the commit button.
+ updateCommitButtonState_: function() {
+ var checkboxes = document.querySelectorAll(
+ '#reset-profile-settings-content-area input[type=checkbox]');
+ var isChecked = false;
+ for (var i = 0; i < checkboxes.length; i++) {
+ if (checkboxes[i].checked) {
+ isChecked = true;
+ break;
+ }
+ }
+ $('reset-profile-settings-commit').disabled = !isChecked;
+ },
+ };
+
+ //
+ // Chrome callbacks
+ //
+ ResetProfileSettingsOverlay.setResettingState = function(state) {
+ $('reset-default-search-engine-checkbox').disabled = state;
+ $('reset-homepage-checkbox').disabled = state;
+ $('reset-content-settings-checkbox').disabled = state;
+ $('reset-cookies-and-site-data-checkbox').disabled = state;
+ $('reset-extensions-checkbox').disabled = state;
+ $('reset-extensions-handling').disabled = state;
+ $('reset-profile-settings-throbber').style.visibility =
+ state ? 'visible' : 'hidden';
+ $('reset-profile-settings-dismiss').disabled = state;
+
+ if (state)
+ $('reset-profile-settings-commit').disabled = true;
+ else
+ ResetProfileSettingsOverlay.getInstance().updateCommitButtonState_();
+ };
+
+ ResetProfileSettingsOverlay.doneResetting = function() {
+ // The delay gives the user some feedback that the resetting
+ // actually worked. Otherwise the dialog just vanishes instantly in most
+ // cases.
+ window.setTimeout(function() {
+ ResetProfileSettingsOverlay.dismiss();
+ }, 200);
+ };
+
+ ResetProfileSettingsOverlay.dismiss = function() {
+ OptionsPage.closeOverlay();
+ this.setResettingState(false);
+ };
+
+ // Export
+ return {
+ ResetProfileSettingsOverlay: ResetProfileSettingsOverlay
+ };
+});

Powered by Google App Engine
This is Rietveld 408576698