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

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 #2 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..ea9fe0a3efa51146ada6312d4fe3f8a6da9e6f3b
--- /dev/null
+++ b/chrome/browser/resources/md_user_manager/profile_api.js
@@ -0,0 +1,159 @@
+// 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;
+
+/** @typedef {{name:(string), filePath:(string), isSupervised:(boolean)}} */
+var ProfileInfo;
+
+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;
+
+ /**
+ * 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.
+ * @param {!function(!Array<string>)} callback
+ */
+ ProfileApi.getAvailableIcons = function(callback) {
+ ProfileApi.getAvailableIconsCallback_ = callback;
+ chrome.send('requestDefaultProfileIcons');
+ };
+
+ /**
+ * Called from JavaScript. Gets the current signed-in users.
+ * @param {!function(!Array<SignedInUser>)} callback
+ */
+ ProfileApi.getSignedInUsers = function(callback) {
+ ProfileApi.getSignedInUsersCallback_ = callback;
+ chrome.send('requestSignedInProfiles');
+ };
+
+ /**
+ * Called from JavaScript. Launches the guest user.
+ */
+ ProfileApi.launchGuestUser = function() {
+ chrome.send('launchGuest');
+ };
+
+ /**
+ * Called from JavaScript. Creates a profile.
+ * @param {string} ProfileName Name of the new profile.
+ * @param {string} profileIconUrl URL of the selected icon of the new profile.
+ * @param {boolean} isSupervised True if the new profile is supervised.
+ * @param {string|undefined} supervisorProfilePath Profile path of the
+ * supervisor if the new profile is supervised.
+ */
+ ProfileApi.createProfile = function(profileName, profileIconUrl, isSupervised,
+ supervisorProfilePath) {
+ chrome.send('createProfile',
+ [profileName, profileIconUrl, false, isSupervised, '',
+ supervisorProfilePath]);
+ };
+
+ /**
+ * Called from JavaScript. Cancels creation of the new profile.
+ */
+ ProfileApi.cancelCreateProfile = function() {
+ cchrome.send('cancelCreateProfile');
+ };
+
+ /**
+ * 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,
+ };
+});
« no previous file with comments | « chrome/browser/resources/md_user_manager/profile_api.html ('k') | chrome/browser/resources/md_user_manager/strings.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698