| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 cr.define('options', function() { | 5 cr.define('options', function() { |
| 6 var OptionsPage = options.OptionsPage; | 6 var OptionsPage = options.OptionsPage; |
| 7 | 7 |
| 8 /** | 8 /** |
| 9 * ResetProfileSettingsOverlay class | 9 * ResetProfileSettingsOverlay class |
| 10 * Encapsulated handling of the 'Reset Profile Settings' overlay page. | 10 * Encapsulated handling of the 'Reset Profile Settings' overlay page. |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 ResetProfileSettingsOverlay.prototype = { | 22 ResetProfileSettingsOverlay.prototype = { |
| 23 // Inherit ResetProfileSettingsOverlay from OptionsPage. | 23 // Inherit ResetProfileSettingsOverlay from OptionsPage. |
| 24 __proto__: OptionsPage.prototype, | 24 __proto__: OptionsPage.prototype, |
| 25 | 25 |
| 26 /** | 26 /** |
| 27 * Initialize the page. | 27 * Initialize the page. |
| 28 */ | 28 */ |
| 29 initializePage: function() { | 29 initializePage: function() { |
| 30 OptionsPage.prototype.initializePage.call(this); | 30 OptionsPage.prototype.initializePage.call(this); |
| 31 | 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) { | 32 $('reset-profile-settings-dismiss').onclick = function(event) { |
| 49 ResetProfileSettingsOverlay.dismiss(); | 33 ResetProfileSettingsOverlay.dismiss(); |
| 50 }; | 34 }; |
| 51 $('reset-profile-settings-commit').onclick = function(event) { | 35 $('reset-profile-settings-commit').onclick = function(event) { |
| 52 ResetProfileSettingsOverlay.setResettingState(true); | 36 ResetProfileSettingsOverlay.setResettingState(true); |
| 53 chrome.send('performResetProfileSettings'); | 37 chrome.send('performResetProfileSettings'); |
| 54 }; | 38 }; |
| 55 }, | 39 }, |
| 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 }; | 40 }; |
| 65 | 41 |
| 66 /** | 42 /** |
| 67 * Enables/disables UI elements after/while Chrome is performing a reset. | 43 * Enables/disables UI elements after/while Chrome is performing a reset. |
| 68 * @param {boolean} state If true, UI elements are disabled. | 44 * @param {boolean} state If true, UI elements are disabled. |
| 69 */ | 45 */ |
| 70 ResetProfileSettingsOverlay.setResettingState = function(state) { | 46 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 = | 47 $('reset-profile-settings-throbber').style.visibility = |
| 78 state ? 'visible' : 'hidden'; | 48 state ? 'visible' : 'hidden'; |
| 79 $('reset-profile-settings-dismiss').disabled = state; | 49 $('reset-profile-settings-dismiss').disabled = state; |
| 80 | 50 $('reset-profile-settings-commit').disabled = state; |
| 81 if (state) | |
| 82 $('reset-profile-settings-commit').disabled = true; | |
| 83 else | |
| 84 ResetProfileSettingsOverlay.getInstance().updateCommitButtonState_(); | |
| 85 }; | 51 }; |
| 86 | 52 |
| 87 /** | 53 /** |
| 88 * Chrome callback to notify ResetProfileSettingsOverlay that the reset | 54 * Chrome callback to notify ResetProfileSettingsOverlay that the reset |
| 89 * operation has terminated. | 55 * operation has terminated. |
| 90 */ | 56 */ |
| 91 ResetProfileSettingsOverlay.doneResetting = function() { | 57 ResetProfileSettingsOverlay.doneResetting = function() { |
| 92 // The delay gives the user some feedback that the resetting | 58 // The delay gives the user some feedback that the resetting |
| 93 // actually worked. Otherwise the dialog just vanishes instantly in most | 59 // actually worked. Otherwise the dialog just vanishes instantly in most |
| 94 // cases. | 60 // cases. |
| 95 window.setTimeout(function() { | 61 window.setTimeout(function() { |
| 96 ResetProfileSettingsOverlay.dismiss(); | 62 ResetProfileSettingsOverlay.dismiss(); |
| 97 }, 200); | 63 }, 200); |
| 98 }; | 64 }; |
| 99 | 65 |
| 100 /** | 66 /** |
| 101 * Dismisses the overlay. | 67 * Dismisses the overlay. |
| 102 */ | 68 */ |
| 103 ResetProfileSettingsOverlay.dismiss = function() { | 69 ResetProfileSettingsOverlay.dismiss = function() { |
| 104 OptionsPage.closeOverlay(); | 70 OptionsPage.closeOverlay(); |
| 105 ResetProfileSettingsOverlay.setResettingState(false); | 71 ResetProfileSettingsOverlay.setResettingState(false); |
| 106 }; | 72 }; |
| 107 | 73 |
| 108 // Export | 74 // Export |
| 109 return { | 75 return { |
| 110 ResetProfileSettingsOverlay: ResetProfileSettingsOverlay | 76 ResetProfileSettingsOverlay: ResetProfileSettingsOverlay |
| 111 }; | 77 }; |
| 112 }); | 78 }); |
| OLD | NEW |