| 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 cr.exportPath('settings'); | 5 cr.exportPath('settings'); |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * The state of sync. This is the data structure sent back and forth between | 8 * The state of sync. This is the data structure sent back and forth between |
| 9 * C++ and JS. Its naming and structure is not optimal, but changing it would | 9 * C++ and JS. Its naming and structure is not optimal, but changing it would |
| 10 * require changes to the C++ handler, which is already functional. | 10 * require changes to the C++ handler, which is already functional. |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 * wifiCredentialsSynced: (boolean|undefined) | 52 * wifiCredentialsSynced: (boolean|undefined) |
| 53 * }} | 53 * }} |
| 54 */ | 54 */ |
| 55 settings.SyncPrefs; | 55 settings.SyncPrefs; |
| 56 | 56 |
| 57 /** | 57 /** |
| 58 * @typedef {{actionLinkText: (string|undefined), | 58 * @typedef {{actionLinkText: (string|undefined), |
| 59 * childUser: (boolean|undefined), | 59 * childUser: (boolean|undefined), |
| 60 * hasError: (boolean|undefined), | 60 * hasError: (boolean|undefined), |
| 61 * hasUnrecoverableError: (boolean|undefined), | 61 * hasUnrecoverableError: (boolean|undefined), |
| 62 * iconURL: (string|undefined), |
| 62 * managed: (boolean|undefined), | 63 * managed: (boolean|undefined), |
| 64 * name: (string|undefined), |
| 63 * setupCompleted: (boolean|undefined), | 65 * setupCompleted: (boolean|undefined), |
| 64 * setupInProgress: (boolean|undefined), | 66 * setupInProgress: (boolean|undefined), |
| 65 * signedIn: (boolean|undefined), | 67 * signedIn: (boolean|undefined), |
| 66 * signinAllowed: (boolean|undefined), | 68 * signinAllowed: (boolean|undefined), |
| 67 * signoutAllowed: (boolean|undefined), | 69 * signoutAllowed: (boolean|undefined), |
| 68 * statusText: (string|undefined), | 70 * statusText: (string|undefined), |
| 69 * supervisedUser: (boolean|undefined), | 71 * supervisedUser: (boolean|undefined), |
| 70 * syncSystemEnabled: (boolean|undefined)}} | 72 * syncSystemEnabled: (boolean|undefined)}} |
| 71 * @see chrome/browser/ui/webui/settings/sync_handler.cc | 73 * @see chrome/browser/ui/webui/settings/sync_handler.cc |
| 72 */ | 74 */ |
| (...skipping 10 matching lines...) Expand all Loading... |
| 83 PASSPHRASE_ERROR: 'passphraseError', // Error in the passphrase. | 85 PASSPHRASE_ERROR: 'passphraseError', // Error in the passphrase. |
| 84 }; | 86 }; |
| 85 | 87 |
| 86 cr.define('settings', function() { | 88 cr.define('settings', function() { |
| 87 /** | 89 /** |
| 88 * API which encapsulates messaging between JS and C++ for the sync page. | 90 * API which encapsulates messaging between JS and C++ for the sync page. |
| 89 * @constructor | 91 * @constructor |
| 90 */ | 92 */ |
| 91 function SyncPrivateApi() {} | 93 function SyncPrivateApi() {} |
| 92 | 94 |
| 93 /** @private {?function(!string, !string)} */ | |
| 94 SyncPrivateApi.getProfileInfoCallback_ = null; | |
| 95 | |
| 96 /** @private {?function(!Array<string>)} */ | |
| 97 SyncPrivateApi.getAvailableIconsCallback_ = null; | |
| 98 | |
| 99 /** @private {?function(settings.SyncPrefs)} */ | 95 /** @private {?function(settings.SyncPrefs)} */ |
| 100 SyncPrivateApi.syncPrefsCallback_ = null; | 96 SyncPrivateApi.syncPrefsCallback_ = null; |
| 101 | 97 |
| 102 /** @private {?function(settings.PageStatus)} */ | 98 /** @private {?function(settings.PageStatus)} */ |
| 103 SyncPrivateApi.setPageStatusCallback_ = null; | 99 SyncPrivateApi.setPageStatusCallback_ = null; |
| 104 | 100 |
| 105 /** | 101 /** |
| 106 * Called from JavaScript. Gets the current profile name and icon. | |
| 107 * @param {?function(!string, !string)} callback | |
| 108 */ | |
| 109 SyncPrivateApi.getProfileInfo = function(callback) { | |
| 110 SyncPrivateApi.getProfileInfoCallback_ = callback; | |
| 111 chrome.send('getProfileInfo'); | |
| 112 }; | |
| 113 | |
| 114 /** | |
| 115 * Called from C++ as a response to getIconsAndNames. | |
| 116 * @param {!string} name The current profile name. | |
| 117 * @param {!string} iconUrl The current profile icon's URL. Can be a data URL. | |
| 118 */ | |
| 119 SyncPrivateApi.receiveProfileInfo = function(name, iconUrl) { | |
| 120 if (SyncPrivateApi.getProfileInfoCallback_) | |
| 121 SyncPrivateApi.getProfileInfoCallback_(name, iconUrl); | |
| 122 }; | |
| 123 | |
| 124 /** | |
| 125 * Called from JavaScript. Gets the available profile icons to choose from. | |
| 126 * @param {!function(!Array<string>)} callback | |
| 127 */ | |
| 128 SyncPrivateApi.getAvailableIcons = function(callback) { | |
| 129 SyncPrivateApi.getAvailableIconsCallback_ = callback; | |
| 130 chrome.send('requestDefaultProfileIcons'); | |
| 131 }; | |
| 132 | |
| 133 /** | |
| 134 * Called from C++ as a response to getAvailableIcons. | |
| 135 * @param {!Array<string>} iconUrls An array of icon URLs. | |
| 136 */ | |
| 137 SyncPrivateApi.receiveAvailableIcons = function(iconUrls) { | |
| 138 if (SyncPrivateApi.getAvailableIconsCallback_) | |
| 139 SyncPrivateApi.getAvailableIconsCallback_(iconUrls); | |
| 140 }; | |
| 141 | |
| 142 /** | |
| 143 * Called from JavaScript. Sets the profile icon and name. | |
| 144 * @param {!string} iconUrl The new profile URL. | |
| 145 * @param {!string} name The new profile name. | |
| 146 */ | |
| 147 SyncPrivateApi.setProfileIconAndName = function(iconUrl, name) { | |
| 148 chrome.send('setProfileIconAndName', [iconUrl, name]); | |
| 149 }; | |
| 150 | |
| 151 /** | |
| 152 * Starts the signin process for the user. Does nothing if the user is | 102 * Starts the signin process for the user. Does nothing if the user is |
| 153 * already signed in. | 103 * already signed in. |
| 154 * @private | 104 * @private |
| 155 */ | 105 */ |
| 156 SyncPrivateApi.startSignIn = function() { | 106 SyncPrivateApi.startSignIn = function() { |
| 157 chrome.send('SyncSetupStartSignIn'); | 107 chrome.send('SyncSetupStartSignIn'); |
| 158 }; | 108 }; |
| 159 | 109 |
| 160 /** | 110 /** |
| 161 * Disconnects the signed in user. | 111 * Disconnects the signed in user. |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 break; | 233 break; |
| 284 default: | 234 default: |
| 285 // Other statuses (i.e. "spinner") are ignored. | 235 // Other statuses (i.e. "spinner") are ignored. |
| 286 } | 236 } |
| 287 }; | 237 }; |
| 288 | 238 |
| 289 return { | 239 return { |
| 290 SyncPrivateApi: SyncPrivateApi, | 240 SyncPrivateApi: SyncPrivateApi, |
| 291 }; | 241 }; |
| 292 }); | 242 }); |
| OLD | NEW |