| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 /** | 5 /** |
| 6 * @fileoverview | 6 * @fileoverview |
| 7 * |
| 7 * 'settings-reset-profile-dialog' is the dialog shown for clearing profile | 8 * 'settings-reset-profile-dialog' is the dialog shown for clearing profile |
| 8 * settings. | 9 * settings. A triggered variant of this dialog can be shown under certain |
| 10 * circumstances. See triggered_profile_resetter.h for when the triggered |
| 11 * variant will be used. |
| 9 */ | 12 */ |
| 10 Polymer({ | 13 Polymer({ |
| 11 is: 'settings-reset-profile-dialog', | 14 is: 'settings-reset-profile-dialog', |
| 12 | 15 |
| 13 behaviors: [WebUIListenerBehavior], | 16 behaviors: [WebUIListenerBehavior], |
| 14 | 17 |
| 15 properties: { | 18 properties: { |
| 16 // TODO(dpapad): Evaluate whether this needs to be synced across different | 19 // TODO(dpapad): Evaluate whether this needs to be synced across different |
| 17 // settings tabs. | 20 // settings tabs. |
| 21 |
| 22 /** @private */ |
| 23 isTriggered_: { |
| 24 type: Boolean, |
| 25 value: false, |
| 26 }, |
| 27 |
| 28 /** @private */ |
| 29 triggeredResetToolName_: { |
| 30 type: String, |
| 31 value: '', |
| 32 }, |
| 33 |
| 18 /** @private */ | 34 /** @private */ |
| 19 clearingInProgress_: { | 35 clearingInProgress_: { |
| 20 type: Boolean, | 36 type: Boolean, |
| 21 value: false, | 37 value: false, |
| 22 }, | 38 }, |
| 23 }, | 39 }, |
| 24 | 40 |
| 25 /** @private {!settings.ResetBrowserProxy} */ | 41 /** @private {!settings.ResetBrowserProxy} */ |
| 26 browserProxy_: null, | 42 browserProxy_: null, |
| 27 | 43 |
| 44 /** |
| 45 * @private |
| 46 * @return {string} |
| 47 */ |
| 48 getExplanationText_: function() { |
| 49 if (this.isTriggered_) { |
| 50 return loadTimeData.getStringF('triggeredResetPageExplanation', |
| 51 this.triggeredResetToolName_); |
| 52 } |
| 53 return loadTimeData.getStringF('resetPageExplanation'); |
| 54 }, |
| 55 |
| 56 /** |
| 57 * @private |
| 58 * @return {string} |
| 59 */ |
| 60 getPageTitle_: function() { |
| 61 if (this.isTriggered_) { |
| 62 return loadTimeData.getStringF('triggeredResetPageTitle', |
| 63 this.triggeredResetToolName_); |
| 64 } |
| 65 return loadTimeData.getStringF('resetPageTitle'); |
| 66 }, |
| 67 |
| 28 /** @override */ | 68 /** @override */ |
| 29 ready: function() { | 69 ready: function() { |
| 30 this.browserProxy_ = settings.ResetBrowserProxyImpl.getInstance(); | 70 this.browserProxy_ = settings.ResetBrowserProxyImpl.getInstance(); |
| 31 | 71 |
| 32 this.addEventListener('cancel', function() { | 72 this.addEventListener('cancel', function() { |
| 33 this.browserProxy_.onHideResetProfileDialog(); | 73 this.browserProxy_.onHideResetProfileDialog(); |
| 34 }.bind(this)); | 74 }.bind(this)); |
| 35 }, | 75 }, |
| 36 | 76 |
| 37 open: function() { | 77 /** @param {boolean} isTriggered */ |
| 78 open: function(isTriggered) { |
| 79 this.isTriggered_ = isTriggered; |
| 80 if (isTriggered) { |
| 81 this.browserProxy_.getTriggeredResetToolName().then(function(name) { |
| 82 this.triggeredResetToolName_ = name; |
| 83 }.bind(this)); |
| 84 } |
| 38 this.$.dialog.showModal(); | 85 this.$.dialog.showModal(); |
| 39 this.browserProxy_.onShowResetProfileDialog(); | 86 this.browserProxy_.onShowResetProfileDialog(); |
| 40 }, | 87 }, |
| 41 | 88 |
| 42 /** @private */ | 89 /** @private */ |
| 43 onCancelTap_: function() { | 90 onCancelTap_: function() { |
| 44 this.$.dialog.cancel(); | 91 this.$.dialog.cancel(); |
| 45 }, | 92 }, |
| 46 | 93 |
| 47 /** @private */ | 94 /** @private */ |
| 48 onResetTap_: function() { | 95 onResetTap_: function() { |
| 49 this.clearingInProgress_ = true; | 96 this.clearingInProgress_ = true; |
| 50 this.browserProxy_.performResetProfileSettings( | 97 this.browserProxy_.performResetProfileSettings( |
| 51 this.$.sendSettings.checked).then(function() { | 98 this.$.sendSettings.checked).then(function() { |
| 52 this.clearingInProgress_ = false; | 99 this.clearingInProgress_ = false; |
| 53 if (this.$.dialog.open) | 100 if (this.$.dialog.open) |
| 54 this.$.dialog.close(); | 101 this.$.dialog.close(); |
| 55 this.fire('reset-done'); | 102 this.fire('reset-done'); |
| 56 }.bind(this)); | 103 }.bind(this)); |
| 57 }, | 104 }, |
| 58 | 105 |
| 59 /** | 106 /** |
| 60 * Displays the settings that will be reported in a new tab. | 107 * Displays the settings that will be reported in a new tab. |
| 61 * @private | 108 * @private |
| 62 */ | 109 */ |
| 63 onShowReportedSettingsTap_: function() { | 110 onShowReportedSettingsTap_: function() { |
| 64 this.browserProxy_.showReportedSettings(); | 111 this.browserProxy_.showReportedSettings(); |
| 65 }, | 112 }, |
| 66 }); | 113 }); |
| OLD | NEW |