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

Unified Diff: chrome/browser/resources/md_user_manager/profile_api.js

Issue 1630903002: material design user manager with create profile flow (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed Dan's comments Created 4 years, 10 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/md_user_manager/profile_api.js
diff --git a/chrome/browser/resources/md_user_manager/profile_api.js b/chrome/browser/resources/md_user_manager/profile_api.js
new file mode 100644
index 0000000000000000000000000000000000000000..544fef55d9c3770c84141e5f7b76abc4863b1576
--- /dev/null
+++ b/chrome/browser/resources/md_user_manager/profile_api.js
@@ -0,0 +1,131 @@
+/* Copyright 2016 The Chromium Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/** @typedef {{username:(string), profilePath:(string)}} */
+var signedInUser;
Dan Beam 2016/02/12 23:42:24 SignedInUser
Moe 2016/02/20 00:20:59 Done.
+
+/** @typedef {{name:(string), filePath:(string), isSupervised:(boolean)}} */
+var profileInfo;
Dan Beam 2016/02/12 23:42:24 ProfileInfo
Moe 2016/02/20 00:20:59 Done.
+
+cr.define('signin', function() {
+ /**
+ * API that encapsulates messaging between JS and C++ for creating/importing
+ * profiles in the user-manager page.
+ * @constructor
+ */
+ function ProfileApi() {}
+
+ /** @private {?function(!Array<string>)} */
+ ProfileApi.getAvailableIconsCallback_ = null;
+
+ /** @private {?function(!Array<signedInUser>)} */
+ ProfileApi.getSignedInUsersCallback_ = null;
+
+ /** @private {?function(!string)} */
+ ProfileApi.profileCreateErrorCallback_ = null;
+
+ /** @private {?function(!string)} */
+ ProfileApi.profileCreateWarningCallback_ = null;
+
+ /** @private {?function(!profileInfo)} */
+ ProfileApi.profileCreateSuccessCallback_ = null;
Dan Beam 2016/02/12 23:42:24 why are you using globals? this means that async
Moe 2016/02/20 00:20:59 I followed the pattern used in sync_private_api.js
+
+ /**
+ * Sets the profile create success callback.
+ * @param {?function(!profileInfo)} callback
+ */
+ ProfileApi.setProfileCreateSuccessCallback = function(callback) {
+ ProfileApi.profileCreateSuccessCallback_ = callback;
+ };
+
+ /**
+ * Sets the profile create warning callback.
+ * @param {?function(!string)} callback
+ */
+ ProfileApi.setProfileCreateWarningCallback = function(callback) {
+ ProfileApi.profileCreateWarningCallback_ = callback;
+ };
+
+ /**
+ * Sets the profile create error callback.
+ * @param {?function(!string)} callback
+ */
+ ProfileApi.setProfileCreateErrorCallback = function(callback) {
+ ProfileApi.profileCreateErrorCallback_ = callback;
+ };
+
+ /**
+ * Called from JavaScript. Gets the available profile icons to choose from.
+ * {!function(!Array<string>)} callback
+ */
+ ProfileApi.getAvailableIcons = function(callback) {
+ ProfileApi.getAvailableIconsCallback_ = callback;
+ chrome.send('requestDefaultProfileIcons');
+ };
+
+ /**
+ * Called from JavaScript. Gets the current signed-in users.
+ * {!function(!Array<string>)} callback
+ */
+ ProfileApi.getSignedInUsers = function(callback) {
+ ProfileApi.getSignedInUsersCallback_ = callback;
+ chrome.send('requestSignedInProfiles');
+ };
+
+ /**
+ * Called from C++ as a response to getAvailableIcons.
+ * @param {!Array<string>} iconUrls An array of icon URLs.
+ * @private
+ */
+ ProfileApi.updateAvailableIcons = function(iconUrls) {
+ if (ProfileApi.getAvailableIconsCallback_)
+ ProfileApi.getAvailableIconsCallback_(iconUrls);
+ };
+
+ /**
+ * Called from C++ in response to 'requestSignedInProfiles'.
+ * @param {!Array<signedInUser>} signedInUsers An array of email addresses of
+ * signed in users and the corresponding profile path.
+ * @private
+ */
+ ProfileApi.updateSignedInUsers = function(signedInUsers) {
+ if (ProfileApi.getSignedInUsersCallback_)
+ ProfileApi.getSignedInUsersCallback_(signedInUsers);
+ };
+
+ /**
+ * Called from C++ to report supervised profile create errors.
+ * @param {string} error The error raised while creating a profile.
+ * @private
+ */
+ ProfileApi.onCreateProfileError = function(error) {
+ if (ProfileApi.profileCreateErrorCallback_)
+ ProfileApi.profileCreateErrorCallback_(error);
+ };
+
+ /**
+ * Called from C++ to report supervised profile create warnings.
+ * @param {string} warning The warning issued while creating a profile.
+ * @private
+ */
+ ProfileApi.onCreateProfileWarning = function(warning) {
+ if (ProfileApi.profileCreateWarningCallback_)
+ ProfileApi.profileCreateWarningCallback_(warning);
+ };
+
+ /**
+ * Called from C++ to report successful creation of a profile.
+ * @param {!profileInfo} profileInfo
+ * @private
+ */
+ ProfileApi.onCreateProfileSuccess = function(profileInfo) {
+ if (ProfileApi.profileCreateSuccessCallback_)
+ ProfileApi.profileCreateSuccessCallback_(profileInfo);
+ };
+
+ return {
+ ProfileApi: ProfileApi,
+ };
+});

Powered by Google App Engine
This is Rietveld 408576698