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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 /* Copyright 2016 The Chromium Authors. All rights reserved.
2 * Use of this source code is governed by a BSD-style license that can be
3 * found in the LICENSE file.
4 */
5
6 /** @typedef {{username:(string), profilePath:(string)}} */
7 var signedInUser;
Dan Beam 2016/02/12 23:42:24 SignedInUser
Moe 2016/02/20 00:20:59 Done.
8
9 /** @typedef {{name:(string), filePath:(string), isSupervised:(boolean)}} */
10 var profileInfo;
Dan Beam 2016/02/12 23:42:24 ProfileInfo
Moe 2016/02/20 00:20:59 Done.
11
12 cr.define('signin', function() {
13 /**
14 * API that encapsulates messaging between JS and C++ for creating/importing
15 * profiles in the user-manager page.
16 * @constructor
17 */
18 function ProfileApi() {}
19
20 /** @private {?function(!Array<string>)} */
21 ProfileApi.getAvailableIconsCallback_ = null;
22
23 /** @private {?function(!Array<signedInUser>)} */
24 ProfileApi.getSignedInUsersCallback_ = null;
25
26 /** @private {?function(!string)} */
27 ProfileApi.profileCreateErrorCallback_ = null;
28
29 /** @private {?function(!string)} */
30 ProfileApi.profileCreateWarningCallback_ = null;
31
32 /** @private {?function(!profileInfo)} */
33 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
34
35 /**
36 * Sets the profile create success callback.
37 * @param {?function(!profileInfo)} callback
38 */
39 ProfileApi.setProfileCreateSuccessCallback = function(callback) {
40 ProfileApi.profileCreateSuccessCallback_ = callback;
41 };
42
43 /**
44 * Sets the profile create warning callback.
45 * @param {?function(!string)} callback
46 */
47 ProfileApi.setProfileCreateWarningCallback = function(callback) {
48 ProfileApi.profileCreateWarningCallback_ = callback;
49 };
50
51 /**
52 * Sets the profile create error callback.
53 * @param {?function(!string)} callback
54 */
55 ProfileApi.setProfileCreateErrorCallback = function(callback) {
56 ProfileApi.profileCreateErrorCallback_ = callback;
57 };
58
59 /**
60 * Called from JavaScript. Gets the available profile icons to choose from.
61 * {!function(!Array<string>)} callback
62 */
63 ProfileApi.getAvailableIcons = function(callback) {
64 ProfileApi.getAvailableIconsCallback_ = callback;
65 chrome.send('requestDefaultProfileIcons');
66 };
67
68 /**
69 * Called from JavaScript. Gets the current signed-in users.
70 * {!function(!Array<string>)} callback
71 */
72 ProfileApi.getSignedInUsers = function(callback) {
73 ProfileApi.getSignedInUsersCallback_ = callback;
74 chrome.send('requestSignedInProfiles');
75 };
76
77 /**
78 * Called from C++ as a response to getAvailableIcons.
79 * @param {!Array<string>} iconUrls An array of icon URLs.
80 * @private
81 */
82 ProfileApi.updateAvailableIcons = function(iconUrls) {
83 if (ProfileApi.getAvailableIconsCallback_)
84 ProfileApi.getAvailableIconsCallback_(iconUrls);
85 };
86
87 /**
88 * Called from C++ in response to 'requestSignedInProfiles'.
89 * @param {!Array<signedInUser>} signedInUsers An array of email addresses of
90 * signed in users and the corresponding profile path.
91 * @private
92 */
93 ProfileApi.updateSignedInUsers = function(signedInUsers) {
94 if (ProfileApi.getSignedInUsersCallback_)
95 ProfileApi.getSignedInUsersCallback_(signedInUsers);
96 };
97
98 /**
99 * Called from C++ to report supervised profile create errors.
100 * @param {string} error The error raised while creating a profile.
101 * @private
102 */
103 ProfileApi.onCreateProfileError = function(error) {
104 if (ProfileApi.profileCreateErrorCallback_)
105 ProfileApi.profileCreateErrorCallback_(error);
106 };
107
108 /**
109 * Called from C++ to report supervised profile create warnings.
110 * @param {string} warning The warning issued while creating a profile.
111 * @private
112 */
113 ProfileApi.onCreateProfileWarning = function(warning) {
114 if (ProfileApi.profileCreateWarningCallback_)
115 ProfileApi.profileCreateWarningCallback_(warning);
116 };
117
118 /**
119 * Called from C++ to report successful creation of a profile.
120 * @param {!profileInfo} profileInfo
121 * @private
122 */
123 ProfileApi.onCreateProfileSuccess = function(profileInfo) {
124 if (ProfileApi.profileCreateSuccessCallback_)
125 ProfileApi.profileCreateSuccessCallback_(profileInfo);
126 };
127
128 return {
129 ProfileApi: ProfileApi,
130 };
131 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698