OLD | NEW |
---|---|
(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 /** @typedef {{username: string, profilePath: string}} */ | |
6 var SignedInUser; | |
7 | |
8 /** @typedef {{name: string, filePath: string, isSupervised: boolean}} */ | |
9 var ProfileInfo; | |
10 | |
11 cr.define('signin.ProfileApi', function() { | |
12 /** | |
13 * API that encapsulates messaging between JS and C++ for creating/importing | |
14 * profiles in the user-manager page. | |
15 */ | |
16 return { | |
17 /** | |
18 * Sets the profile create success callback. | |
19 * @param {?function(!ProfileInfo)} callback | |
20 */ | |
21 setProfileCreateSuccessCallback: function(callback) { | |
22 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.
| |
23 }, | |
24 | |
25 /** | |
26 * Sets the profile create warning callback. | |
27 * @param {?function(!string)} callback | |
28 */ | |
29 setProfileCreateWarningCallback: function(callback) { | |
30 this.profileCreateWarningCallback_ = callback; | |
31 }, | |
32 | |
33 /** | |
34 * Sets the profile create error callback. | |
35 * @param {?function(!string)} callback | |
36 */ | |
37 setProfileCreateErrorCallback: function(callback) { | |
38 this.profileCreateErrorCallback_ = callback; | |
39 }, | |
40 | |
41 /** | |
42 * Called from JavaScript. Gets the available profile icons. | |
43 * @param {!function(!Array<string>)} callback | |
44 */ | |
45 getAvailableIcons: function(callback) { | |
46 this.getAvailableIconsCallback_ = callback; | |
47 chrome.send('requestDefaultProfileIcons'); | |
48 }, | |
49 | |
50 /** | |
51 * Called from JavaScript. Gets the current signed-in users. | |
52 * @param {!function(!Array<SignedInUser>)} callback | |
53 */ | |
54 getSignedInUsers: function(callback) { | |
55 this.getSignedInUsersCallback_ = callback; | |
56 chrome.send('requestSignedInProfiles'); | |
57 }, | |
58 | |
59 /** | |
60 * Called from JavaScript. Launches the guest user. | |
61 */ | |
62 launchGuestUser: function() { | |
63 chrome.send('launchGuest'); | |
64 }, | |
65 | |
66 /** | |
67 * Called from JavaScript. Creates a profile. | |
68 * @param {string} profileName Name of the new profile. | |
69 * @param {string} profileIconUrl URL of the selected profile icon. | |
70 * @param {boolean} isSupervised True if the new profile is supervised. | |
71 * @param {(string|undefined)} supervisorProfilePath Profile path of the | |
72 * supervisor if the new profile is supervised. | |
73 */ | |
74 createProfile: function(profileName, profileIconUrl, isSupervised, | |
75 supervisorProfilePath) { | |
76 chrome.send('createProfile', | |
77 [profileName, profileIconUrl, false, isSupervised, '', | |
78 supervisorProfilePath]); | |
79 }, | |
80 | |
81 /** | |
82 * Called from JavaScript. Cancels creation of the new profile. | |
83 */ | |
84 cancelCreateProfile: function() { | |
85 chrome.send('cancelCreateProfile'); | |
86 }, | |
87 | |
88 /** | |
89 * Called from C++ as a response to getAvailableIcons. | |
90 * @param {!Array<string>} iconUrls An array of icon URLs. | |
91 * @private | |
92 */ | |
93 updateAvailableIcons: function(iconUrls) { | |
94 if (this.getAvailableIconsCallback_) | |
95 this.getAvailableIconsCallback_(iconUrls); | |
96 }, | |
97 | |
98 /** | |
99 * Called from C++ in response to 'requestSignedInProfiles'. | |
100 * @param {!Array<SignedInUser>} signedInUsers An array of email addresses | |
101 * of signed in users and the corresponding profile path. | |
102 * @private | |
103 */ | |
104 updateSignedInUsers: function(signedInUsers) { | |
105 if (this.getSignedInUsersCallback_) | |
106 this.getSignedInUsersCallback_(signedInUsers); | |
107 }, | |
108 | |
109 /** | |
110 * Called from C++ to report supervised profile create errors. | |
111 * @param {string} error The error raised while creating a profile. | |
112 * @private | |
113 */ | |
114 onCreateProfileError: function(error) { | |
115 if (this.profileCreateErrorCallback_) | |
116 this.profileCreateErrorCallback_(error); | |
117 }, | |
118 | |
119 /** | |
120 * Called from C++ to report supervised profile create warnings. | |
121 * @param {string} warning The warning issued while creating a profile. | |
122 * @private | |
123 */ | |
124 onCreateProfileWarning: function(warning) { | |
125 if (this.profileCreateWarningCallback_) | |
126 this.profileCreateWarningCallback_(warning); | |
127 }, | |
128 | |
129 /** | |
130 * Called from C++ to report successful creation of a profile. | |
131 * @param {!ProfileInfo} profileInfo | |
132 * @private | |
133 */ | |
134 onCreateProfileSuccess: function(profileInfo) { | |
135 if (this.profileCreateSuccessCallback_) | |
136 this.profileCreateSuccessCallback_(profileInfo); | |
137 } | |
138 }; | |
139 }); | |
OLD | NEW |