| 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..64f02a6af6ba0fc47bdfa26754a050d2f128defa
|
| --- /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() {
|
| + /**
|
| + * API that encapsulates messaging between JS and C++ for user-manager page.
|
| + */
|
| + function ProfileApi() {}
|
| +
|
| + ProfileApi.getAvailableIconsCallback_ = null;
|
| + 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('requestCreateProfileUpdate');
|
| + };
|
| +
|
| + /**
|
| + * Called from C++ as a response to getAvailableIcons.
|
| + */
|
| + ProfileApi.receiveAvailableIcons = function(iconUrls) {
|
| + if (ProfileApi.getAvailableIconsCallback_)
|
| + ProfileApi.getAvailableIconsCallback_(iconUrls);
|
| + };
|
| +
|
| + /**
|
| + * Called from C++ in response to 'requestCreateProfileUpdate'.
|
| + */
|
| + 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,
|
| + };
|
| +});
|
|
|