| 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 |
| 77 /** @private */ |
| 78 showDialog_: function() { |
| 79 this.$.dialog.showModal(); |
| 80 this.browserProxy_.onShowResetProfileDialog(); |
| 81 }, |
| 82 |
| 37 /** @override */ | 83 /** @override */ |
| 38 attached: function() { | 84 attached: function() { |
| 39 this.$.dialog.showModal(); | 85 this.isTriggered_ = |
| 40 this.browserProxy_.onShowResetProfileDialog(); | 86 settings.getCurrentRoute() == settings.Route.TRIGGERED_RESET_DIALOG; |
| 87 if (this.isTriggered_) { |
| 88 this.browserProxy_.getTriggeredResetToolName().then(function(name) { |
| 89 this.triggeredResetToolName_ = name; |
| 90 this.showDialog_(); |
| 91 }.bind(this)); |
| 92 } else { |
| 93 this.showDialog_(); |
| 94 } |
| 41 }, | 95 }, |
| 42 | 96 |
| 43 /** @private */ | 97 /** @private */ |
| 44 onCancelTap_: function() { | 98 onCancelTap_: function() { |
| 45 this.$.dialog.cancel(); | 99 this.$.dialog.cancel(); |
| 46 }, | 100 }, |
| 47 | 101 |
| 48 /** @private */ | 102 /** @private */ |
| 49 onResetTap_: function() { | 103 onResetTap_: function() { |
| 50 this.clearingInProgress_ = true; | 104 this.clearingInProgress_ = true; |
| 51 this.browserProxy_.performResetProfileSettings( | 105 this.browserProxy_.performResetProfileSettings( |
| 52 this.$.sendSettings.checked).then(function() { | 106 this.$.sendSettings.checked).then(function() { |
| 53 this.clearingInProgress_ = false; | 107 this.clearingInProgress_ = false; |
| 54 if (this.$.dialog.open) | 108 if (this.$.dialog.open) |
| 55 this.$.dialog.close(); | 109 this.$.dialog.close(); |
| 56 this.fire('reset-done'); | 110 this.fire('reset-done'); |
| 57 }.bind(this)); | 111 }.bind(this)); |
| 58 }, | 112 }, |
| 59 | 113 |
| 60 /** | 114 /** |
| 61 * Displays the settings that will be reported in a new tab. | 115 * Displays the settings that will be reported in a new tab. |
| 62 * @private | 116 * @private |
| 63 */ | 117 */ |
| 64 onShowReportedSettingsTap_: function() { | 118 onShowReportedSettingsTap_: function() { |
| 65 this.browserProxy_.showReportedSettings(); | 119 this.browserProxy_.showReportedSettings(); |
| 66 }, | 120 }, |
| 67 }); | 121 }); |
| OLD | NEW |