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

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

Issue 1722843002: MD user manager (html/js/css for create profile flow) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed 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..c6099d565f545e36b397efe8e22699b0ade4871f
--- /dev/null
+++ b/chrome/browser/resources/md_user_manager/profile_api.js
@@ -0,0 +1,139 @@
+// 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.ProfileApi', function() {
+ /**
+ * API that encapsulates messaging between JS and C++ for creating/importing
+ * profiles in the user-manager page.
+ */
+ return {
+ /**
+ * Sets the profile create success callback.
+ * @param {?function(!ProfileInfo)} callback
+ */
+ setProfileCreateSuccessCallback: function(callback) {
+ this.profileCreateSuccessCallback_ = callback;
Dan Beam 2016/03/04 02:45:49 the closure compiler might say "dangerous use of t
Moe 2016/03/08 00:57:04 Reverted this to the old format.
+ },
+
+ /**
+ * Sets the profile create warning callback.
+ * @param {?function(!string)} callback
+ */
+ setProfileCreateWarningCallback: function(callback) {
+ this.profileCreateWarningCallback_ = callback;
+ },
+
+ /**
+ * Sets the profile create error callback.
+ * @param {?function(!string)} callback
+ */
+ setProfileCreateErrorCallback: function(callback) {
+ this.profileCreateErrorCallback_ = callback;
+ },
+
+ /**
+ * Called from JavaScript. Gets the available profile icons.
+ * @param {!function(!Array<string>)} callback
+ */
+ getAvailableIcons: function(callback) {
+ this.getAvailableIconsCallback_ = callback;
+ chrome.send('requestDefaultProfileIcons');
+ },
+
+ /**
+ * Called from JavaScript. Gets the current signed-in users.
+ * @param {!function(!Array<SignedInUser>)} callback
+ */
+ getSignedInUsers: function(callback) {
+ this.getSignedInUsersCallback_ = callback;
+ chrome.send('requestSignedInProfiles');
+ },
+
+ /**
+ * Called from JavaScript. Launches the guest user.
+ */
+ 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 profile icon.
+ * @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.
+ */
+ createProfile: function(profileName, profileIconUrl, isSupervised,
+ supervisorProfilePath) {
+ chrome.send('createProfile',
+ [profileName, profileIconUrl, false, isSupervised, '',
+ supervisorProfilePath]);
+ },
+
+ /**
+ * Called from JavaScript. Cancels creation of the new profile.
+ */
+ cancelCreateProfile: function() {
+ chrome.send('cancelCreateProfile');
+ },
+
+ /**
+ * Called from C++ as a response to getAvailableIcons.
+ * @param {!Array<string>} iconUrls An array of icon URLs.
+ * @private
+ */
+ updateAvailableIcons: function(iconUrls) {
+ if (this.getAvailableIconsCallback_)
+ this.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
+ */
+ updateSignedInUsers: function(signedInUsers) {
+ if (this.getSignedInUsersCallback_)
+ this.getSignedInUsersCallback_(signedInUsers);
+ },
+
+ /**
+ * Called from C++ to report supervised profile create errors.
+ * @param {string} error The error raised while creating a profile.
+ * @private
+ */
+ onCreateProfileError: function(error) {
+ if (this.profileCreateErrorCallback_)
+ this.profileCreateErrorCallback_(error);
+ },
+
+ /**
+ * Called from C++ to report supervised profile create warnings.
+ * @param {string} warning The warning issued while creating a profile.
+ * @private
+ */
+ onCreateProfileWarning: function(warning) {
+ if (this.profileCreateWarningCallback_)
+ this.profileCreateWarningCallback_(warning);
+ },
+
+ /**
+ * Called from C++ to report successful creation of a profile.
+ * @param {!ProfileInfo} profileInfo
+ * @private
+ */
+ onCreateProfileSuccess: function(profileInfo) {
+ if (this.profileCreateSuccessCallback_)
+ this.profileCreateSuccessCallback_(profileInfo);
+ }
+ };
+});

Powered by Google App Engine
This is Rietveld 408576698