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 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), | |
| 63 * managed: (boolean|undefined), | 62 * managed: (boolean|undefined), |
| 64 * name: (string|undefined), | |
| 65 * setupCompleted: (boolean|undefined), | 63 * setupCompleted: (boolean|undefined), |
| 66 * setupInProgress: (boolean|undefined), | 64 * setupInProgress: (boolean|undefined), |
| 67 * signedIn: (boolean|undefined), | 65 * signedIn: (boolean|undefined), |
| 68 * signinAllowed: (boolean|undefined), | 66 * signinAllowed: (boolean|undefined), |
| 69 * signoutAllowed: (boolean|undefined), | 67 * signoutAllowed: (boolean|undefined), |
| 70 * statusText: (string|undefined), | 68 * statusText: (string|undefined), |
| 71 * supervisedUser: (boolean|undefined), | 69 * supervisedUser: (boolean|undefined), |
| 72 * syncSystemEnabled: (boolean|undefined)}} | 70 * syncSystemEnabled: (boolean|undefined)}} |
| 73 * @see chrome/browser/ui/webui/settings/sync_handler.cc | 71 * @see chrome/browser/ui/webui/settings/sync_handler.cc |
| 74 */ | 72 */ |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 85 PASSPHRASE_ERROR: 'passphraseError', // Error in the passphrase. | 83 PASSPHRASE_ERROR: 'passphraseError', // Error in the passphrase. |
| 86 }; | 84 }; |
| 87 | 85 |
| 88 cr.define('settings', function() { | 86 cr.define('settings', function() { |
| 89 /** | 87 /** |
| 90 * API which encapsulates messaging between JS and C++ for the sync page. | 88 * API which encapsulates messaging between JS and C++ for the sync page. |
| 91 * @constructor | 89 * @constructor |
| 92 */ | 90 */ |
| 93 function SyncPrivateApi() {} | 91 function SyncPrivateApi() {} |
| 94 | 92 |
| 93 /** @private {?function(!string, !string)} */ | |
| 94 SyncPrivateApi.getProfileInfoCallback_ = null; | |
| 95 | |
| 96 /** @private {?function(!Array<string>)} */ | |
| 97 SyncPrivateApi.getAvailableIconsCallback_ = null; | |
| 98 | |
| 95 /** @private {?function(settings.SyncPrefs)} */ | 99 /** @private {?function(settings.SyncPrefs)} */ |
| 96 SyncPrivateApi.syncPrefsCallback_ = null; | 100 SyncPrivateApi.syncPrefsCallback_ = null; |
| 97 | 101 |
| 98 /** @private {?function(settings.PageStatus)} */ | 102 /** @private {?function(settings.PageStatus)} */ |
| 99 SyncPrivateApi.setPageStatusCallback_ = null; | 103 SyncPrivateApi.setPageStatusCallback_ = null; |
| 100 | 104 |
| 101 /** | 105 /** |
| 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) { | |
|
Dan Beam
2015/12/28 23:28:57
nit: prefer iconUrl, as far as I know
tommycli
2016/01/04 21:40:13
Done.
| |
| 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 /** | |
| 102 * Starts the signin process for the user. Does nothing if the user is | 152 * Starts the signin process for the user. Does nothing if the user is |
| 103 * already signed in. | 153 * already signed in. |
| 104 * @private | 154 * @private |
| 105 */ | 155 */ |
| 106 SyncPrivateApi.startSignIn = function() { | 156 SyncPrivateApi.startSignIn = function() { |
| 107 chrome.send('SyncSetupStartSignIn'); | 157 chrome.send('SyncSetupStartSignIn'); |
| 108 }; | 158 }; |
| 109 | 159 |
| 110 /** | 160 /** |
| 111 * Disconnects the signed in user. | 161 * Disconnects the signed in user. |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 233 break; | 283 break; |
| 234 default: | 284 default: |
| 235 // Other statuses (i.e. "spinner") are ignored. | 285 // Other statuses (i.e. "spinner") are ignored. |
| 236 } | 286 } |
| 237 }; | 287 }; |
| 238 | 288 |
| 239 return { | 289 return { |
| 240 SyncPrivateApi: SyncPrivateApi, | 290 SyncPrivateApi: SyncPrivateApi, |
| 241 }; | 291 }; |
| 242 }); | 292 }); |
| OLD | NEW |