| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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('settings', function() { | 5 cr.define('settings', function() { |
| 6 /** @interface */ | 6 /** @interface */ |
| 7 function ResetBrowserProxy() {} | 7 class ResetBrowserProxy { |
| 8 | |
| 9 ResetBrowserProxy.prototype = { | |
| 10 /** | 8 /** |
| 11 * @param {boolean} sendSettings Whether the user gave consent to upload | 9 * @param {boolean} sendSettings Whether the user gave consent to upload |
| 12 * broken settings to Google for analysis. | 10 * broken settings to Google for analysis. |
| 13 * @param {string} requestOrigin The origin of the reset request. | 11 * @param {string} requestOrigin The origin of the reset request. |
| 14 * @return {!Promise} A promise firing once resetting has completed. | 12 * @return {!Promise} A promise firing once resetting has completed. |
| 15 */ | 13 */ |
| 16 performResetProfileSettings: function(sendSettings, requestOrigin) {}, | 14 performResetProfileSettings(sendSettings, requestOrigin) {} |
| 17 | 15 |
| 18 /** | 16 /** |
| 19 * A method to be called when the reset profile dialog is hidden. | 17 * A method to be called when the reset profile dialog is hidden. |
| 20 */ | 18 */ |
| 21 onHideResetProfileDialog: function() {}, | 19 onHideResetProfileDialog() {} |
| 22 | 20 |
| 23 /** | 21 /** |
| 24 * A method to be called when the reset profile banner is hidden. | 22 * A method to be called when the reset profile banner is hidden. |
| 25 */ | 23 */ |
| 26 onHideResetProfileBanner: function() {}, | 24 onHideResetProfileBanner() {} |
| 27 | 25 |
| 28 /** | 26 /** |
| 29 * A method to be called when the reset profile dialog is shown. | 27 * A method to be called when the reset profile dialog is shown. |
| 30 */ | 28 */ |
| 31 onShowResetProfileDialog: function() {}, | 29 onShowResetProfileDialog() {} |
| 32 | 30 |
| 33 /** | 31 /** |
| 34 * Shows the settings that are about to be reset and which will be reported | 32 * Shows the settings that are about to be reset and which will be reported |
| 35 * to Google for analysis, in a new tab. | 33 * to Google for analysis, in a new tab. |
| 36 */ | 34 */ |
| 37 showReportedSettings: function() {}, | 35 showReportedSettings() {} |
| 38 | 36 |
| 39 /** | 37 /** |
| 40 * Retrieves the triggered reset tool name. | 38 * Retrieves the triggered reset tool name. |
| 41 * @return {!Promise<string>} A promise firing with the tool name, once it | 39 * @return {!Promise<string>} A promise firing with the tool name, once it |
| 42 * has been retrieved. | 40 * has been retrieved. |
| 43 */ | 41 */ |
| 44 getTriggeredResetToolName: function() {}, | 42 getTriggeredResetToolName() {} |
| 45 | 43 |
| 46 // <if expr="chromeos"> | 44 // <if expr="chromeos"> |
| 47 /** | 45 /** |
| 48 * A method to be called when the reset powerwash dialog is shown. | 46 * A method to be called when the reset powerwash dialog is shown. |
| 49 */ | 47 */ |
| 50 onPowerwashDialogShow: function() {}, | 48 onPowerwashDialogShow() {} |
| 51 | 49 |
| 52 /** | 50 /** |
| 53 * Initiates a factory reset and restarts ChromeOS. | 51 * Initiates a factory reset and restarts ChromeOS. |
| 54 */ | 52 */ |
| 55 requestFactoryResetRestart: function() {}, | 53 requestFactoryResetRestart() {} |
| 56 // </if> | 54 // </if> |
| 57 }; | 55 } |
| 58 | 56 |
| 59 /** | 57 /** |
| 60 * @constructor | |
| 61 * @implements {settings.ResetBrowserProxy} | 58 * @implements {settings.ResetBrowserProxy} |
| 62 */ | 59 */ |
| 63 function ResetBrowserProxyImpl() {} | 60 class ResetBrowserProxyImpl { |
| 64 cr.addSingletonGetter(ResetBrowserProxyImpl); | |
| 65 | |
| 66 ResetBrowserProxyImpl.prototype = { | |
| 67 /** @override */ | 61 /** @override */ |
| 68 performResetProfileSettings: function(sendSettings, requestOrigin) { | 62 performResetProfileSettings(sendSettings, requestOrigin) { |
| 69 return cr.sendWithPromise( | 63 return cr.sendWithPromise( |
| 70 'performResetProfileSettings', sendSettings, requestOrigin); | 64 'performResetProfileSettings', sendSettings, requestOrigin); |
| 71 }, | 65 } |
| 72 | 66 |
| 73 /** @override */ | 67 /** @override */ |
| 74 onHideResetProfileDialog: function() { | 68 onHideResetProfileDialog() { |
| 75 chrome.send('onHideResetProfileDialog'); | 69 chrome.send('onHideResetProfileDialog'); |
| 76 }, | 70 } |
| 77 | 71 |
| 78 /** @override */ | 72 /** @override */ |
| 79 onHideResetProfileBanner: function() { | 73 onHideResetProfileBanner() { |
| 80 chrome.send('onHideResetProfileBanner'); | 74 chrome.send('onHideResetProfileBanner'); |
| 81 }, | 75 } |
| 82 | 76 |
| 83 /** @override */ | 77 /** @override */ |
| 84 onShowResetProfileDialog: function() { | 78 onShowResetProfileDialog() { |
| 85 chrome.send('onShowResetProfileDialog'); | 79 chrome.send('onShowResetProfileDialog'); |
| 86 }, | 80 } |
| 87 | 81 |
| 88 /** @override */ | 82 /** @override */ |
| 89 showReportedSettings: function() { | 83 showReportedSettings() { |
| 90 cr.sendWithPromise('getReportedSettings').then(function(settings) { | 84 cr.sendWithPromise('getReportedSettings').then(function(settings) { |
| 91 var output = settings.map(function(entry) { | 85 var output = settings.map(function(entry) { |
| 92 return entry.key + ': ' + entry.value.replace(/\n/g, ', '); | 86 return entry.key + ': ' + entry.value.replace(/\n/g, ', '); |
| 93 }); | 87 }); |
| 94 var win = window.open('about:blank'); | 88 var win = window.open('about:blank'); |
| 95 var div = win.document.createElement('div'); | 89 var div = win.document.createElement('div'); |
| 96 div.textContent = output.join('\n'); | 90 div.textContent = output.join('\n'); |
| 97 div.style.whiteSpace = 'pre'; | 91 div.style.whiteSpace = 'pre'; |
| 98 win.document.body.appendChild(div); | 92 win.document.body.appendChild(div); |
| 99 }); | 93 }); |
| 100 }, | 94 } |
| 101 | 95 |
| 102 /** @override */ | 96 /** @override */ |
| 103 getTriggeredResetToolName: function() { | 97 getTriggeredResetToolName() { |
| 104 return cr.sendWithPromise('getTriggeredResetToolName'); | 98 return cr.sendWithPromise('getTriggeredResetToolName'); |
| 105 }, | 99 } |
| 106 | 100 |
| 107 // <if expr="chromeos"> | 101 // <if expr="chromeos"> |
| 108 /** @override */ | 102 /** @override */ |
| 109 onPowerwashDialogShow: function() { | 103 onPowerwashDialogShow() { |
| 110 chrome.send('onPowerwashDialogShow'); | 104 chrome.send('onPowerwashDialogShow'); |
| 111 }, | 105 } |
| 112 | 106 |
| 113 /** @override */ | 107 /** @override */ |
| 114 requestFactoryResetRestart: function() { | 108 requestFactoryResetRestart() { |
| 115 chrome.send('requestFactoryResetRestart'); | 109 chrome.send('requestFactoryResetRestart'); |
| 116 }, | 110 } |
| 117 // </if> | 111 // </if> |
| 118 }; | 112 } |
| 113 |
| 114 cr.addSingletonGetter(ResetBrowserProxyImpl); |
| 119 | 115 |
| 120 return { | 116 return { |
| 121 ResetBrowserProxyImpl: ResetBrowserProxyImpl, | 117 ResetBrowserProxyImpl: ResetBrowserProxyImpl, |
| 122 }; | 118 }; |
| 123 }); | 119 }); |
| OLD | NEW |