| 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 * 'settings-reset-profile-dialog' is the dialog shown for clearing profile | 7 * 'settings-reset-profile-dialog' is the dialog shown for clearing profile |
| 8 * settings. | 8 * settings. |
| 9 */ | 9 */ |
| 10 Polymer({ | 10 Polymer({ |
| 11 is: 'settings-reset-profile-dialog', | 11 is: 'settings-reset-profile-dialog', |
| 12 | 12 |
| 13 behaviors: [WebUIListenerBehavior], | 13 behaviors: [WebUIListenerBehavior], |
| 14 | 14 |
| 15 properties: { | |
| 16 feedbackInfo_: String, | |
| 17 }, | |
| 18 | |
| 19 /** @private {!settings.ResetBrowserProxy} */ | 15 /** @private {!settings.ResetBrowserProxy} */ |
| 20 browserProxy_: null, | 16 browserProxy_: null, |
| 21 | 17 |
| 22 /** @override */ | 18 /** @override */ |
| 23 ready: function() { | 19 ready: function() { |
| 24 this.browserProxy_ = settings.ResetBrowserProxyImpl.getInstance(); | 20 this.browserProxy_ = settings.ResetBrowserProxyImpl.getInstance(); |
| 25 | 21 |
| 26 this.addEventListener('iron-overlay-canceled', function() { | 22 this.addEventListener('iron-overlay-canceled', function() { |
| 27 this.browserProxy_.onHideResetProfileDialog(); | 23 this.browserProxy_.onHideResetProfileDialog(); |
| 28 }.bind(this)); | 24 }.bind(this)); |
| 29 | |
| 30 this.addWebUIListener('feedback-info-changed', function(feedbackInfo) { | |
| 31 this.feedbackInfo_ = feedbackInfo; | |
| 32 }.bind(this)); | |
| 33 }, | 25 }, |
| 34 | 26 |
| 35 open: function() { | 27 open: function() { |
| 36 this.$.dialog.open(); | 28 this.$.dialog.open(); |
| 37 this.browserProxy_.onShowResetProfileDialog(); | 29 this.browserProxy_.onShowResetProfileDialog(); |
| 38 }, | 30 }, |
| 39 | 31 |
| 40 /** @private */ | 32 /** @private */ |
| 41 onCancelTap_: function() { | 33 onCancelTap_: function() { |
| 42 this.$.dialog.cancel(); | 34 this.$.dialog.cancel(); |
| 43 }, | 35 }, |
| 44 | 36 |
| 45 /** @private */ | 37 /** @private */ |
| 46 onResetTap_: function() { | 38 onResetTap_: function() { |
| 47 this.$.resetSpinner.active = true; | 39 this.$.resetSpinner.active = true; |
| 48 this.browserProxy_.performResetProfileSettings( | 40 this.browserProxy_.performResetProfileSettings( |
| 49 this.$.sendSettings.checked).then(function() { | 41 this.$.sendSettings.checked).then(function() { |
| 50 this.$.resetSpinner.active = false; | 42 this.$.resetSpinner.active = false; |
| 51 this.$.dialog.close(); | 43 this.$.dialog.close(); |
| 52 this.dispatchEvent(new CustomEvent('reset-done')); | 44 this.dispatchEvent(new CustomEvent('reset-done')); |
| 53 }.bind(this)); | 45 }.bind(this)); |
| 54 }, | 46 }, |
| 55 | 47 |
| 56 /** @private */ | 48 /** |
| 57 onSendSettingsChange_: function() { | 49 * Displays the settings that will be reported in a new tab. |
| 58 // TODO(dpapad): Update how settings info is surfaced when final mocks | 50 * @private |
| 59 // exist. | 51 */ |
| 60 this.$.settings.hidden = !this.$.sendSettings.checked; | 52 onShowReportedSettingsTap_: function() { |
| 61 this.$.dialog.center(); | 53 this.browserProxy_.getReportedSettings().then(function(settings) { |
| 54 var feedbackObj = {}; |
| 55 settings.forEach(function(entry) { |
| 56 // Break strings with '\n' characters into arrays to make the settings a |
| 57 // bit more readable. |
| 58 var values = entry.value.split('\n'); |
| 59 feedbackObj[entry.key] = values.length == 1 ? values[0] : values; |
| 60 }); |
| 61 var win = window.open('about:blank'); |
| 62 var div = win.document.createElement('div'); |
| 63 div.textContent = JSON.stringify(feedbackObj, null, 2 /* spaces */); |
| 64 div.style.whiteSpace = 'pre'; |
| 65 win.document.body.appendChild(div); |
| 66 }); |
| 62 }, | 67 }, |
| 63 }); | 68 }); |
| OLD | NEW |