Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(29)

Unified Diff: chrome/browser/resources/settings/people_page/sync_private_api.js

Issue 1536593004: Settings People Revamp: Implement Chrome Profile name/icon selection. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/resources/settings/people_page/sync_private_api.js
diff --git a/chrome/browser/resources/settings/people_page/sync_private_api.js b/chrome/browser/resources/settings/people_page/sync_private_api.js
index 05547fb3399354e872ef7c2c8d68a5f4084c5093..89d51dee2db21cef2d540ae9caf2e340133b9b0f 100644
--- a/chrome/browser/resources/settings/people_page/sync_private_api.js
+++ b/chrome/browser/resources/settings/people_page/sync_private_api.js
@@ -59,9 +59,7 @@ settings.SyncPrefs;
* childUser: (boolean|undefined),
* hasError: (boolean|undefined),
* hasUnrecoverableError: (boolean|undefined),
- * iconURL: (string|undefined),
* managed: (boolean|undefined),
- * name: (string|undefined),
* setupCompleted: (boolean|undefined),
* setupInProgress: (boolean|undefined),
* signedIn: (boolean|undefined),
@@ -92,6 +90,12 @@ cr.define('settings', function() {
*/
function SyncPrivateApi() {}
+ /** @private {?function(!string, !string)} */
+ SyncPrivateApi.getProfileInfoCallback_ = null;
+
+ /** @private {?function(!Array<string>)} */
+ SyncPrivateApi.getAvailableIconsCallback_ = null;
+
/** @private {?function(settings.SyncPrefs)} */
SyncPrivateApi.syncPrefsCallback_ = null;
@@ -99,6 +103,52 @@ cr.define('settings', function() {
SyncPrivateApi.setPageStatusCallback_ = null;
/**
+ * Called from JavaScript. Gets the current profile name and icon.
+ * @param {?function(!string, !string)} callback
+ */
+ SyncPrivateApi.getProfileInfo = function(callback) {
+ SyncPrivateApi.getProfileInfoCallback_ = callback;
+ chrome.send('getProfileInfo');
+ };
+
+ /**
+ * Called from C++ as a response to getIconsAndNames.
+ * @param {!string} name The current profile name.
+ * @param {!string} iconUrl The current profile icon's URL. Can be a data URL.
+ */
+ SyncPrivateApi.receiveProfileInfo = function(name, iconUrl) {
+ if (SyncPrivateApi.getProfileInfoCallback_)
+ SyncPrivateApi.getProfileInfoCallback_(name, iconUrl);
+ };
+
+ /**
+ * Called from JavaScript. Gets the available profile icons to choose from.
+ * @param {!function(!Array<string>)} callback
+ */
+ SyncPrivateApi.getAvailableIcons = function(callback) {
+ SyncPrivateApi.getAvailableIconsCallback_ = callback;
+ chrome.send('requestDefaultProfileIcons');
+ };
+
+ /**
+ * Called from C++ as a response to getAvailableIcons.
+ * @param {!Array<string>} iconUrls An array of icon URLs.
+ */
+ SyncPrivateApi.receiveAvailableIcons = function(iconUrls) {
+ if (SyncPrivateApi.getAvailableIconsCallback_)
+ SyncPrivateApi.getAvailableIconsCallback_(iconUrls);
+ };
+
+ /**
+ * Called from JavaScript. Sets the profile icon and name.
+ * @param {!string} iconUrl The new profile URL.
+ * @param {!string} name The new profile name.
+ */
+ SyncPrivateApi.setProfileIconAndName = function(iconUrl, name) {
+ chrome.send('setProfileIconAndName', [iconUrl, name]);
+ };
+
+ /**
* Starts the signin process for the user. Does nothing if the user is
* already signed in.
* @private

Powered by Google App Engine
This is Rietveld 408576698