Index: chrome/browser/resources/md_user_manager/profile_browser_proxy.js |
diff --git a/chrome/browser/resources/md_user_manager/profile_browser_proxy.js b/chrome/browser/resources/md_user_manager/profile_browser_proxy.js |
new file mode 100644 |
index 0000000000000000000000000000000000000000..78e82c284fc1f4f8c2bcdbaf167328fefaec9320 |
--- /dev/null |
+++ b/chrome/browser/resources/md_user_manager/profile_browser_proxy.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. |
+ |
+/** |
+ * @fileoverview Helper object and related behavior that encapsulate messaging |
+ * between JS and C++ for creating/importing profiles in the user-manager page. |
+ */ |
+ |
+/** @typedef {{username: string, profilePath: string}} */ |
+var SignedInUser; |
+ |
+/** @typedef {{name: string, filePath: string, isSupervised: boolean}} */ |
+var ProfileInfo; |
+ |
+cr.define('signin', function() { |
+ /** @interface */ |
+ function ProfileBrowserProxy() {} |
+ |
+ ProfileBrowserProxy.prototype = { |
+ /** |
+ * Gets the available profile icons to choose from. |
+ */ |
+ getAvailableIcons: function() {}, |
Dan Beam
2016/03/09 18:21:37
nit: can this be assertNotReached or something els
Moe
2016/03/09 19:30:08
Done.
|
+ |
+ /** |
+ * Gets the current signed-in users. |
+ */ |
+ getSignedInUsers: function() {}, |
+ |
+ /** |
+ * Launches the guest user. |
+ */ |
+ launchGuestUser: function() {}, |
+ |
+ /** |
+ * Creates a profile. |
+ * @param {string} profileName Name of the new profile. |
+ * @param {string} profileIconUrl URL of the selected icon of the new profile. |
Dan Beam
2016/03/09 18:21:37
80 col wrap
Moe
2016/03/09 19:30:08
Done.
|
+ * @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) {}, |
+ |
+ /** |
+ * Cancels creation of the new profile. |
+ */ |
+ cancelCreateProfile: function() {}, |
+ |
+ /** |
+ * Initializes the UserManager |
+ * @param {string} locationHash |
+ */ |
+ initializeUserManager: function(locationHash) {}, |
+ |
+ /** |
+ * Launches the user with the given |profilePath| |
+ * @param {string} profilePath Profile Path of the user. |
+ */ |
+ launchUser: function(profilePath) {} |
+ }; |
+ |
+ /** |
+ * @constructor |
+ * @implements {signin.ProfileBrowserProxy} |
+ */ |
+ function ProfileBrowserProxyImpl() {} |
+ |
+ // The singleton instance_ is replaced with a test version of this wrapper |
+ // during testing. |
+ cr.addSingletonGetter(ProfileBrowserProxyImpl); |
+ |
+ ProfileBrowserProxyImpl.prototype = { |
+ /** @override */ |
+ getAvailableIcons: function() { |
+ chrome.send('requestDefaultProfileIcons'); |
+ }, |
+ |
+ /** @override */ |
+ getSignedInUsers: function() { |
+ chrome.send('requestSignedInProfiles'); |
+ }, |
+ |
+ /** @override */ |
+ launchGuestUser: function() { |
+ chrome.send('launchGuest'); |
+ }, |
+ |
+ /** @override */ |
+ createProfile: function(profileName, profileIconUrl, isSupervised, |
+ supervisorProfilePath) { |
+ chrome.send('createProfile', |
+ [profileName, profileIconUrl, false, isSupervised, '', |
+ supervisorProfilePath]); |
+ }, |
+ |
+ /** @override */ |
+ cancelCreateProfile: function() { |
+ chrome.send('cancelCreateProfile'); |
+ }, |
+ |
+ /** @override */ |
+ initializeUserManager: function(locationHash) { |
+ chrome.send('userManagerInitialize', [locationHash]); |
+ }, |
+ |
+ /** @override */ |
+ launchUser: function(profilePath) { |
+ chrome.send('launchUser', [profilePath]); |
+ } |
+ }; |
+ |
+ return { |
+ ProfileBrowserProxy: ProfileBrowserProxy, |
Moe
2016/03/09 15:29:03
I noticed in the existing examples under settings/
Dan Beam
2016/03/09 18:21:37
yeah, this is because of 2 things:
1) technically
Moe
2016/03/09 19:30:08
Acknowledged.
|
+ ProfileBrowserProxyImpl: ProfileBrowserProxyImpl, |
+ }; |
+}); |
+ |
Dan Beam
2016/03/09 18:21:37
nit: remove extra \n
Moe
2016/03/09 19:30:08
Done.
|
+ |
+cr.define('signin', function() { |
+ /** @polymerBehavior */ |
+ var ProfileBrowserProxyBehavior = { |
+ properties: { |
+ /** @private {!signin.ProfileBrowserProxy} */ |
Dan Beam
2016/03/09 18:21:37
this should not be @private if it's externally use
Moe
2016/03/09 19:30:08
Done.
|
+ browserProxy_: Object, |
+ }, |
+ |
+ /** @override */ |
+ created: function() { |
+ this.browserProxy_ = signin.ProfileBrowserProxyImpl.getInstance(); |
Dan Beam
2016/03/09 18:21:37
i think it's probably better to set/inject this or
Moe
2016/03/09 19:30:08
Done.
|
+ } |
+ }; |
+ |
+ return { |
+ ProfileBrowserProxyBehavior: ProfileBrowserProxyBehavior |
+ }; |
+}); |