| 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 /** | 5 /** |
| 6 * @fileoverview A helper object used from the the People section to get the | 6 * @fileoverview A helper object used from the the People section to get the |
| 7 * status of the sync backend and user preferences on what data to sync. Used | 7 * status of the sync backend and user preferences on what data to sync. Used |
| 8 * for both Chrome browser and ChromeOS. | 8 * for both Chrome browser and ChromeOS. |
| 9 */ | 9 */ |
| 10 cr.exportPath('settings'); | 10 cr.exportPath('settings'); |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 settings.PageStatus = { | 98 settings.PageStatus = { |
| 99 SPINNER: 'spinner', // Before the page has loaded. | 99 SPINNER: 'spinner', // Before the page has loaded. |
| 100 CONFIGURE: 'configure', // Preferences ready to be configured. | 100 CONFIGURE: 'configure', // Preferences ready to be configured. |
| 101 TIMEOUT: 'timeout', // Preferences loading has timed out. | 101 TIMEOUT: 'timeout', // Preferences loading has timed out. |
| 102 DONE: 'done', // Sync subpage can be closed now. | 102 DONE: 'done', // Sync subpage can be closed now. |
| 103 PASSPHRASE_FAILED: 'passphraseFailed', // Error in the passphrase. | 103 PASSPHRASE_FAILED: 'passphraseFailed', // Error in the passphrase. |
| 104 }; | 104 }; |
| 105 | 105 |
| 106 cr.define('settings', function() { | 106 cr.define('settings', function() { |
| 107 /** @interface */ | 107 /** @interface */ |
| 108 function SyncBrowserProxy() {} | 108 class SyncBrowserProxy { |
| 109 | |
| 110 SyncBrowserProxy.prototype = { | |
| 111 // <if expr="not chromeos"> | 109 // <if expr="not chromeos"> |
| 112 /** | 110 /** |
| 113 * Starts the signin process for the user. Does nothing if the user is | 111 * Starts the signin process for the user. Does nothing if the user is |
| 114 * already signed in. | 112 * already signed in. |
| 115 */ | 113 */ |
| 116 startSignIn: function() {}, | 114 startSignIn() {} |
| 117 | 115 |
| 118 /** | 116 /** |
| 119 * Signs out the signed-in user. | 117 * Signs out the signed-in user. |
| 120 * @param {boolean} deleteProfile | 118 * @param {boolean} deleteProfile |
| 121 */ | 119 */ |
| 122 signOut: function(deleteProfile) {}, | 120 signOut(deleteProfile) {} |
| 123 | 121 |
| 124 /** | 122 /** |
| 125 * Opens the multi-profile user manager. | 123 * Opens the multi-profile user manager. |
| 126 */ | 124 */ |
| 127 manageOtherPeople: function() {}, | 125 manageOtherPeople() {} |
| 126 |
| 128 // </if> | 127 // </if> |
| 129 | 128 |
| 130 // <if expr="chromeos"> | 129 // <if expr="chromeos"> |
| 131 /** | 130 /** |
| 132 * Signs the user out. | 131 * Signs the user out. |
| 133 */ | 132 */ |
| 134 attemptUserExit: function() {}, | 133 attemptUserExit() {} |
| 134 |
| 135 // </if> | 135 // </if> |
| 136 | 136 |
| 137 /** | 137 /** |
| 138 * Gets the current sync status. | 138 * Gets the current sync status. |
| 139 * @return {!Promise<!settings.SyncStatus>} | 139 * @return {!Promise<!settings.SyncStatus>} |
| 140 */ | 140 */ |
| 141 getSyncStatus: function() {}, | 141 getSyncStatus() {} |
| 142 | 142 |
| 143 /** | 143 /** |
| 144 * Function to invoke when the sync page has been navigated to. This | 144 * Function to invoke when the sync page has been navigated to. This |
| 145 * registers the UI as the "active" sync UI so that if the user tries to | 145 * registers the UI as the "active" sync UI so that if the user tries to |
| 146 * open another sync UI, this one will be shown instead. | 146 * open another sync UI, this one will be shown instead. |
| 147 */ | 147 */ |
| 148 didNavigateToSyncPage: function() {}, | 148 didNavigateToSyncPage() {} |
| 149 | 149 |
| 150 /** | 150 /** |
| 151 * Function to invoke when leaving the sync page so that the C++ layer can | 151 * Function to invoke when leaving the sync page so that the C++ layer can |
| 152 * be notified that the sync UI is no longer open. | 152 * be notified that the sync UI is no longer open. |
| 153 */ | 153 */ |
| 154 didNavigateAwayFromSyncPage: function() {}, | 154 didNavigateAwayFromSyncPage() {} |
| 155 | 155 |
| 156 /** | 156 /** |
| 157 * Sets which types of data to sync. | 157 * Sets which types of data to sync. |
| 158 * @param {!settings.SyncPrefs} syncPrefs | 158 * @param {!settings.SyncPrefs} syncPrefs |
| 159 * @return {!Promise<!settings.PageStatus>} | 159 * @return {!Promise<!settings.PageStatus>} |
| 160 */ | 160 */ |
| 161 setSyncDatatypes: function(syncPrefs) {}, | 161 setSyncDatatypes(syncPrefs) {} |
| 162 | 162 |
| 163 /** | 163 /** |
| 164 * Sets the sync encryption options. | 164 * Sets the sync encryption options. |
| 165 * @param {!settings.SyncPrefs} syncPrefs | 165 * @param {!settings.SyncPrefs} syncPrefs |
| 166 * @return {!Promise<!settings.PageStatus>} | 166 * @return {!Promise<!settings.PageStatus>} |
| 167 */ | 167 */ |
| 168 setSyncEncryption: function(syncPrefs) {}, | 168 setSyncEncryption(syncPrefs) {} |
| 169 | 169 |
| 170 /** | 170 /** |
| 171 * Opens the Google Activity Controls url in a new tab. | 171 * Opens the Google Activity Controls url in a new tab. |
| 172 */ | 172 */ |
| 173 openActivityControlsUrl: function() {}, | 173 openActivityControlsUrl() {} |
| 174 }; | 174 } |
| 175 | 175 |
| 176 /** | 176 /** |
| 177 * @constructor | |
| 178 * @implements {settings.SyncBrowserProxy} | 177 * @implements {settings.SyncBrowserProxy} |
| 179 */ | 178 */ |
| 180 function SyncBrowserProxyImpl() {} | 179 class SyncBrowserProxyImpl { |
| 181 cr.addSingletonGetter(SyncBrowserProxyImpl); | |
| 182 | |
| 183 SyncBrowserProxyImpl.prototype = { | |
| 184 // <if expr="not chromeos"> | 180 // <if expr="not chromeos"> |
| 185 /** @override */ | 181 /** @override */ |
| 186 startSignIn: function() { | 182 startSignIn() { |
| 187 chrome.send('SyncSetupStartSignIn'); | 183 chrome.send('SyncSetupStartSignIn'); |
| 188 }, | 184 } |
| 189 | 185 |
| 190 /** @override */ | 186 /** @override */ |
| 191 signOut: function(deleteProfile) { | 187 signOut(deleteProfile) { |
| 192 chrome.send('SyncSetupStopSyncing', [deleteProfile]); | 188 chrome.send('SyncSetupStopSyncing', [deleteProfile]); |
| 193 }, | 189 } |
| 194 | 190 |
| 195 /** @override */ | 191 /** @override */ |
| 196 manageOtherPeople: function() { | 192 manageOtherPeople() { |
| 197 chrome.send('SyncSetupManageOtherPeople'); | 193 chrome.send('SyncSetupManageOtherPeople'); |
| 198 }, | 194 } |
| 195 |
| 199 // </if> | 196 // </if> |
| 200 // <if expr="chromeos"> | 197 // <if expr="chromeos"> |
| 201 /** @override */ | 198 /** @override */ |
| 202 attemptUserExit: function() { | 199 attemptUserExit() { |
| 203 return chrome.send('AttemptUserExit'); | 200 return chrome.send('AttemptUserExit'); |
| 204 }, | 201 } |
| 202 |
| 205 // </if> | 203 // </if> |
| 206 | 204 |
| 207 /** @override */ | 205 /** @override */ |
| 208 getSyncStatus: function() { | 206 getSyncStatus() { |
| 209 return cr.sendWithPromise('SyncSetupGetSyncStatus'); | 207 return cr.sendWithPromise('SyncSetupGetSyncStatus'); |
| 210 }, | 208 } |
| 211 | 209 |
| 212 /** @override */ | 210 /** @override */ |
| 213 didNavigateToSyncPage: function() { | 211 didNavigateToSyncPage() { |
| 214 chrome.send('SyncSetupShowSetupUI'); | 212 chrome.send('SyncSetupShowSetupUI'); |
| 215 }, | 213 } |
| 216 | 214 |
| 217 /** @override */ | 215 /** @override */ |
| 218 didNavigateAwayFromSyncPage: function() { | 216 didNavigateAwayFromSyncPage() { |
| 219 chrome.send('SyncSetupDidClosePage'); | 217 chrome.send('SyncSetupDidClosePage'); |
| 220 }, | 218 } |
| 221 | 219 |
| 222 /** @override */ | 220 /** @override */ |
| 223 setSyncDatatypes: function(syncPrefs) { | 221 setSyncDatatypes(syncPrefs) { |
| 224 return cr.sendWithPromise( | 222 return cr.sendWithPromise( |
| 225 'SyncSetupSetDatatypes', JSON.stringify(syncPrefs)); | 223 'SyncSetupSetDatatypes', JSON.stringify(syncPrefs)); |
| 226 }, | 224 } |
| 227 | 225 |
| 228 /** @override */ | 226 /** @override */ |
| 229 setSyncEncryption: function(syncPrefs) { | 227 setSyncEncryption(syncPrefs) { |
| 230 return cr.sendWithPromise( | 228 return cr.sendWithPromise( |
| 231 'SyncSetupSetEncryption', JSON.stringify(syncPrefs)); | 229 'SyncSetupSetEncryption', JSON.stringify(syncPrefs)); |
| 232 }, | 230 } |
| 233 | 231 |
| 234 /** @override */ | 232 /** @override */ |
| 235 openActivityControlsUrl: function() { | 233 openActivityControlsUrl() { |
| 236 chrome.metricsPrivate.recordUserAction( | 234 chrome.metricsPrivate.recordUserAction( |
| 237 'Signin_AccountSettings_GoogleActivityControlsClicked'); | 235 'Signin_AccountSettings_GoogleActivityControlsClicked'); |
| 238 } | 236 } |
| 239 }; | 237 } |
| 238 |
| 239 cr.addSingletonGetter(SyncBrowserProxyImpl); |
| 240 | 240 |
| 241 return { | 241 return { |
| 242 SyncBrowserProxy: SyncBrowserProxy, | 242 SyncBrowserProxy: SyncBrowserProxy, |
| 243 SyncBrowserProxyImpl: SyncBrowserProxyImpl, | 243 SyncBrowserProxyImpl: SyncBrowserProxyImpl, |
| 244 }; | 244 }; |
| 245 }); | 245 }); |
| OLD | NEW |