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

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 the comments 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/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..26c99b2183a9b289f40e8c12ad9b5ee3b44b07ec
--- /dev/null
+++ b/chrome/browser/resources/md_user_manager/profile_api.js
@@ -0,0 +1,106 @@
+/* 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.
+ */
+
+cr.define('cr.ui', function() {
tommycli 2016/02/03 01:13:22 This and all of the JS should be compiled. See the
Moe 2016/02/05 17:58:39 Done.
+ /**
+ * API that encapsulates messaging between JS and C++ for user-manager page.
+ */
+ function ProfileApi() {}
+
+ ProfileApi.getAvailableIconsCallback_ = null;
tommycli 2016/02/03 01:13:22 Need annotations
Moe 2016/02/05 17:58:39 Done.
+ ProfileApi.getSignedInUsersCallback = null;
+ ProfileApi.profileCreateErrorCallback_ = null;
+ ProfileApi.profileCreateWarningCallback_ = null;
+ ProfileApi.profileCreateSuccessCallback_ = null;
+
+ ProfileApi.setProfileCreateSuccessCallback = function(callback) {
+ ProfileApi.profileCreateSuccessCallback_ = callback;
+ };
+
+ ProfileApi.setProfileCreateWarningCallback = function(callback) {
+ ProfileApi.profileCreateWarningCallback_ = callback;
+ };
+
+ ProfileApi.setProfileCreateErrorCallback = function(callback) {
+ ProfileApi.profileCreateErrorCallback_ = callback;
+ };
+
+ /**
+ * Called from JavaScript. Gets the available profile icons to choose from.
+ */
+ ProfileApi.getAvailableIcons = function(callback) {
+ ProfileApi.getAvailableIconsCallback_ = callback;
+ chrome.send('requestDefaultProfileIcons');
+ };
+
+ /**
+ * Called from JavaScript. Gets the current signed-in users.
+ */
+ ProfileApi.getSignedInUsers = function(callback) {
+ ProfileApi.getSignedInUsersCallback = callback;
+ chrome.send('requestSignedInProfiles');
+ };
+
+ /**
+ * Called from C++ as a response to getAvailableIcons.
+ */
+ ProfileApi.updateAvailableIcons = function(iconUrls) {
+ if (ProfileApi.getAvailableIconsCallback_)
+ ProfileApi.getAvailableIconsCallback_(iconUrls);
+ };
+
+ /**
+ * Called from C++ in response to 'requestSignedInProfiles'.
+ */
+ ProfileApi.updateSignedInUsers = function(signedIn_users) {
+ if (ProfileApi.getSignedInUsersCallback)
+ ProfileApi.getSignedInUsersCallback(signedIn_users);
+ };
+
+ /**
+ * Called from C++ to report supervised user import errors.
+ */
+ ProfileApi.onSupervisedUserImportError_ = function(error) {};
+
+ /**
+ * Called from C++ to report successful importing of a supervised user to
+ */
+ ProfileApi.onSupervisedUserImportSuccess_ = function() {};
+
+ /**
+ * Called from C++ to report supervised user create errors.
+ */
+ ProfileApi.onCreateProfileError = function(error) {
+ if (ProfileApi.profileCreateErrorCallback_)
+ ProfileApi.profileCreateErrorCallback_(error);
+ };
+
+ /**
+ * Called from C++ to report supervised user create warnings.
+ */
+ ProfileApi.onCreateProfileWarning = function(warning) {
+ if (ProfileApi.profileCreateWarningCallback_)
+ ProfileApi.profileCreateWarningCallback_(warning);
+ };
+
+ /**
+ * Called from C++ to report successful creation of a user.
+ * @param {Object}:
+ * profileInfo = {
+ * name: 'Profile Name',
+ * filePath: '/path/to/profile/data/on/disk'
+ * isSupervised: (true|false),
+ * };
+ * @private
+ */
+ ProfileApi.onCreateProfileSuccess = function(profileInfo) {
+ if (ProfileApi.profileCreateSuccessCallback_)
+ ProfileApi.profileCreateSuccessCallback_(profileInfo);
+ };
+
+ return {
+ ProfileApi: ProfileApi,
+ };
+});

Powered by Google App Engine
This is Rietveld 408576698