Chromium Code Reviews| 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 /** | |
| 6 * @fileoverview Helper object and related behavior that encapsulate messaging | |
| 7 * between JS and C++ for creating/importing profiles in the user-manager page. | |
| 8 */ | |
| 9 | |
| 10 /** @typedef {{username: string, profilePath: string}} */ | |
| 11 var SignedInUser; | |
| 12 | |
| 13 /** @typedef {{name: string, filePath: string, isSupervised: boolean}} */ | |
| 14 var ProfileInfo; | |
| 15 | |
| 16 cr.define('signin', function() { | |
| 17 /** @interface */ | |
| 18 function ProfileBrowserProxy() {} | |
| 19 | |
| 20 ProfileBrowserProxy.prototype = { | |
| 21 /** | |
| 22 * Gets the available profile icons to choose from. | |
| 23 */ | |
| 24 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.
| |
| 25 | |
| 26 /** | |
| 27 * Gets the current signed-in users. | |
| 28 */ | |
| 29 getSignedInUsers: function() {}, | |
| 30 | |
| 31 /** | |
| 32 * Launches the guest user. | |
| 33 */ | |
| 34 launchGuestUser: function() {}, | |
| 35 | |
| 36 /** | |
| 37 * Creates a profile. | |
| 38 * @param {string} profileName Name of the new profile. | |
| 39 * @param {string} profileIconUrl URL of the selected icon of the new profil e. | |
|
Dan Beam
2016/03/09 18:21:37
80 col wrap
Moe
2016/03/09 19:30:08
Done.
| |
| 40 * @param {boolean} isSupervised True if the new profile is supervised. | |
| 41 * @param {string|undefined} supervisorProfilePath Profile path of the | |
| 42 * supervisor if the new profile is supervised. | |
| 43 */ | |
| 44 createProfile: function(profileName, profileIconUrl, isSupervised, | |
| 45 supervisorProfilePath) {}, | |
| 46 | |
| 47 /** | |
| 48 * Cancels creation of the new profile. | |
| 49 */ | |
| 50 cancelCreateProfile: function() {}, | |
| 51 | |
| 52 /** | |
| 53 * Initializes the UserManager | |
| 54 * @param {string} locationHash | |
| 55 */ | |
| 56 initializeUserManager: function(locationHash) {}, | |
| 57 | |
| 58 /** | |
| 59 * Launches the user with the given |profilePath| | |
| 60 * @param {string} profilePath Profile Path of the user. | |
| 61 */ | |
| 62 launchUser: function(profilePath) {} | |
| 63 }; | |
| 64 | |
| 65 /** | |
| 66 * @constructor | |
| 67 * @implements {signin.ProfileBrowserProxy} | |
| 68 */ | |
| 69 function ProfileBrowserProxyImpl() {} | |
| 70 | |
| 71 // The singleton instance_ is replaced with a test version of this wrapper | |
| 72 // during testing. | |
| 73 cr.addSingletonGetter(ProfileBrowserProxyImpl); | |
| 74 | |
| 75 ProfileBrowserProxyImpl.prototype = { | |
| 76 /** @override */ | |
| 77 getAvailableIcons: function() { | |
| 78 chrome.send('requestDefaultProfileIcons'); | |
| 79 }, | |
| 80 | |
| 81 /** @override */ | |
| 82 getSignedInUsers: function() { | |
| 83 chrome.send('requestSignedInProfiles'); | |
| 84 }, | |
| 85 | |
| 86 /** @override */ | |
| 87 launchGuestUser: function() { | |
| 88 chrome.send('launchGuest'); | |
| 89 }, | |
| 90 | |
| 91 /** @override */ | |
| 92 createProfile: function(profileName, profileIconUrl, isSupervised, | |
| 93 supervisorProfilePath) { | |
| 94 chrome.send('createProfile', | |
| 95 [profileName, profileIconUrl, false, isSupervised, '', | |
| 96 supervisorProfilePath]); | |
| 97 }, | |
| 98 | |
| 99 /** @override */ | |
| 100 cancelCreateProfile: function() { | |
| 101 chrome.send('cancelCreateProfile'); | |
| 102 }, | |
| 103 | |
| 104 /** @override */ | |
| 105 initializeUserManager: function(locationHash) { | |
| 106 chrome.send('userManagerInitialize', [locationHash]); | |
| 107 }, | |
| 108 | |
| 109 /** @override */ | |
| 110 launchUser: function(profilePath) { | |
| 111 chrome.send('launchUser', [profilePath]); | |
| 112 } | |
| 113 }; | |
| 114 | |
| 115 return { | |
| 116 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.
| |
| 117 ProfileBrowserProxyImpl: ProfileBrowserProxyImpl, | |
| 118 }; | |
| 119 }); | |
| 120 | |
|
Dan Beam
2016/03/09 18:21:37
nit: remove extra \n
Moe
2016/03/09 19:30:08
Done.
| |
| 121 | |
| 122 cr.define('signin', function() { | |
| 123 /** @polymerBehavior */ | |
| 124 var ProfileBrowserProxyBehavior = { | |
| 125 properties: { | |
| 126 /** @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.
| |
| 127 browserProxy_: Object, | |
| 128 }, | |
| 129 | |
| 130 /** @override */ | |
| 131 created: function() { | |
| 132 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.
| |
| 133 } | |
| 134 }; | |
| 135 | |
| 136 return { | |
| 137 ProfileBrowserProxyBehavior: ProfileBrowserProxyBehavior | |
| 138 }; | |
| 139 }); | |
| OLD | NEW |