Chromium Code Reviews| 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 */ |
| 38 this.$.dialog.showModal(); | 78 open: function(isTriggered) { |
| 39 this.browserProxy_.onShowResetProfileDialog(); | 79 this.isTriggered_ = isTriggered; |
| 80 if (isTriggered) { | |
| 81 this.browserProxy_.getTriggeredResetToolName().then(function(name) { | |
| 82 this.triggeredResetToolName_ = name; | |
| 83 this.$.dialog.showModal(); | |
| 84 this.browserProxy_.onShowResetProfileDialog(); | |
| 85 }.bind(this)); | |
| 86 } else { | |
| 87 this.$.dialog.showModal(); | |
| 88 this.browserProxy_.onShowResetProfileDialog(); | |
|
Dan Beam
2016/09/28 06:12:19
maybe combine these 2 lines into a method?
showDi
alito
2016/10/11 19:02:49
Done.
| |
| 89 } | |
| 40 }, | 90 }, |
| 41 | 91 |
| 42 /** @private */ | 92 /** @private */ |
| 43 onCancelTap_: function() { | 93 onCancelTap_: function() { |
| 44 this.$.dialog.cancel(); | 94 this.$.dialog.cancel(); |
| 45 }, | 95 }, |
| 46 | 96 |
| 47 /** @private */ | 97 /** @private */ |
| 48 onResetTap_: function() { | 98 onResetTap_: function() { |
| 49 this.clearingInProgress_ = true; | 99 this.clearingInProgress_ = true; |
| 50 this.browserProxy_.performResetProfileSettings( | 100 this.browserProxy_.performResetProfileSettings( |
| 51 this.$.sendSettings.checked).then(function() { | 101 this.$.sendSettings.checked).then(function() { |
| 52 this.clearingInProgress_ = false; | 102 this.clearingInProgress_ = false; |
| 53 if (this.$.dialog.open) | 103 if (this.$.dialog.open) |
| 54 this.$.dialog.close(); | 104 this.$.dialog.close(); |
| 55 this.fire('reset-done'); | 105 this.fire('reset-done'); |
| 56 }.bind(this)); | 106 }.bind(this)); |
| 57 }, | 107 }, |
| 58 | 108 |
| 59 /** | 109 /** |
| 60 * Displays the settings that will be reported in a new tab. | 110 * Displays the settings that will be reported in a new tab. |
| 61 * @private | 111 * @private |
| 62 */ | 112 */ |
| 63 onShowReportedSettingsTap_: function() { | 113 onShowReportedSettingsTap_: function() { |
| 64 this.browserProxy_.showReportedSettings(); | 114 this.browserProxy_.showReportedSettings(); |
| 65 }, | 115 }, |
| 66 }); | 116 }); |
| OLD | NEW |