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..623425d36124dd0d8fb2e0890ca9d4665efea44b |
--- /dev/null |
+++ b/chrome/browser/resources/options/reset_profile_settings_overlay.js |
@@ -0,0 +1,118 @@ |
+// 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() { |
+ 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++) |
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:
|
+ 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'); |
+ }; |
+ }, |
+ |
+ // Sets the enabled state of the commit button. |
+ updateCommitButtonState_: function() { |
+ var checkboxes = document.querySelectorAll( |
+ '#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.
|
+ var isChecked = false; |
+ for (var i = 0; i < checkboxes.length; i++) { |
+ if (checkboxes[i].checked) { |
+ isChecked = true; |
+ break; |
+ } |
+ } |
+ $('reset-profile-settings-commit').disabled = !isChecked; |
+ }, |
+ }; |
+ |
+ /** |
+ * Enables/disables UI elements after/while Chrome is performing a reset. |
+ * @param {boolean} state If true, UI elements are disabled. |
+ */ |
+ 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_(); |
+ }; |
+ |
+ /** |
+ * Chrome callback to notify ResetProfileSettingsOverlay that the reset |
+ * operation has terminated. |
+ */ |
+ 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); |
+ }; |
+ |
+ /** |
+ * Dismisses the overlay. |
+ */ |
+ ResetProfileSettingsOverlay.dismiss = function() { |
+ OptionsPage.closeOverlay(); |
+ ResetProfileSettingsOverlay.setResettingState(false); |
+ }; |
+ |
+ // Export |
+ return { |
+ ResetProfileSettingsOverlay: ResetProfileSettingsOverlay |
+ }; |
+}); |