OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 |
4 <include src="../../../../ui/login/screen.js"> | 5 <include src="../../../../ui/login/screen.js"> |
5 <include src="../../../../ui/login/bubble.js"> | 6 <include src="../../../../ui/login/bubble.js"> |
6 <include src="../../../../ui/login/login_ui_tools.js"> | 7 <include src="../../../../ui/login/login_ui_tools.js"> |
7 <include src="../../../../ui/login/display_manager.js"> | 8 <include src="../../../../ui/login/display_manager.js"> |
8 <include src="control_bar.js"> | |
9 <include src="../../../../ui/login/account_picker/screen_account_picker.js"> | 9 <include src="../../../../ui/login/account_picker/screen_account_picker.js"> |
10 <include src="../../../../ui/login/account_picker/user_pod_row.js"> | 10 <include src="../../../../ui/login/account_picker/user_pod_row.js"> |
11 <include src="../../../../ui/login/resource_loader.js"> | 11 |
12 <include src="user_manager_tutorial.js"> | |
13 | 12 |
14 cr.define('cr.ui', function() { | 13 cr.define('cr.ui', function() { |
15 var DisplayManager = cr.ui.login.DisplayManager; | 14 var DisplayManager = cr.ui.login.DisplayManager; |
16 var UserManagerTutorial = cr.ui.login.UserManagerTutorial; | |
17 | 15 |
18 /** | 16 /** |
19 * Constructs an Out of box controller. It manages initialization of screens, | 17 * Manages initialization of screens, transitions, and error messages. |
20 * transitions, error messages display. | 18 * @constructor |
21 * @extends {DisplayManager} | 19 * @extends {DisplayManager} |
22 * @constructor | |
23 */ | 20 */ |
24 function Oobe() { | 21 function UserManager() {} |
25 } | |
26 | 22 |
27 cr.addSingletonGetter(Oobe); | 23 cr.addSingletonGetter(UserManager); |
28 | 24 |
29 Oobe.prototype = { | 25 UserManager.prototype = { |
30 __proto__: DisplayManager.prototype, | 26 __proto__: DisplayManager.prototype, |
31 }; | 27 }; |
32 | 28 |
33 /** | 29 /** |
| 30 * Initializes the UserManager. |
| 31 */ |
| 32 UserManager.initialize = function() { |
| 33 cr.ui.login.DisplayManager.initialize(); |
| 34 login.AccountPickerScreen.register(); |
| 35 cr.ui.Bubble.decorate($('bubble')); |
| 36 |
| 37 signin.ProfileBrowserProxyImpl.getInstance().initializeUserManager( |
| 38 window.location.hash); |
| 39 }; |
| 40 |
| 41 /** |
34 * Shows the given screen. | 42 * Shows the given screen. |
35 * @param {bool} showGuest Whether the 'Browse as Guest' button is displayed. | 43 * @param {boolean} showGuest True if 'Browse as Guest' button should be |
36 * @param {bool} showAddPerson Whether the 'Add Person' button is displayed. | 44 * displayed. |
| 45 * @param {boolean} showAddPerson True if 'Add Person' button should be |
| 46 * displayed. |
37 */ | 47 */ |
38 Oobe.showUserManagerScreen = function(showGuest, showAddPerson) { | 48 UserManager.showUserManagerScreen = function(showGuest, showAddPerson) { |
39 Oobe.getInstance().showScreen({id: 'account-picker', | 49 UserManager.getInstance().showScreen({id: 'account-picker', |
40 data: {disableAddUser: false}}); | 50 data: {disableAddUser: false}}); |
41 // The ChromeOS account-picker will hide the AddUser button if a user is | |
42 // logged in and the screen is "locked", so we must re-enabled it | |
43 $('add-user-header-bar-item').hidden = false; | |
44 | |
45 // Hide control options if the user does not have the right permissions. | 51 // Hide control options if the user does not have the right permissions. |
46 $('guest-user-button').hidden = !showGuest; | 52 var controlBar = document.querySelector('control-bar'); |
47 $('add-user-button').hidden = !showAddPerson; | 53 controlBar.showGuest = showGuest; |
48 $('login-header-bar').hidden = false; | 54 controlBar.showAddPerson = showAddPerson; |
49 | 55 |
50 // Disable the context menu, as the Print/Inspect element items don't | 56 // Disable the context menu, as the Print/Inspect element items don't |
51 // make sense when displayed as a widget. | 57 // make sense when displayed as a widget. |
52 document.addEventListener('contextmenu', function(e) {e.preventDefault();}); | 58 document.addEventListener('contextmenu', function(e) {e.preventDefault();}); |
53 | 59 |
54 var hash = window.location.hash; | 60 // TODO(mahmadi): start the tutorial if the location hash is #tutorial. |
55 if (hash && hash == '#tutorial') | |
56 UserManagerTutorial.startTutorial(); | |
57 }; | 61 }; |
58 | 62 |
59 /** | 63 /** |
60 * Open a new browser for the given profile. | 64 * Open a new browser for the given profile. |
61 * @param {string} profilePath The profile's path. | 65 * @param {string} profilePath The profile's path. |
62 */ | 66 */ |
63 Oobe.launchUser = function(profilePath) { | 67 UserManager.launchUser = function(profilePath) { |
64 chrome.send('launchUser', [profilePath]); | 68 signin.ProfileBrowserProxyImpl.getInstance().launchUser(profilePath); |
65 }; | 69 }; |
66 | 70 |
67 /** | 71 /** |
68 * Disables signin UI. | 72 * Disables signin UI. |
69 */ | 73 */ |
70 Oobe.disableSigninUI = function() { | 74 UserManager.disableSigninUI = function() { |
71 DisplayManager.disableSigninUI(); | 75 DisplayManager.disableSigninUI(); |
72 }; | 76 }; |
73 | 77 |
74 /** | 78 /** |
75 * Shows signin UI. | 79 * Shows signin UI. |
76 * @param {string} opt_email An optional email for signin UI. | 80 * @param {string=} opt_email An optional email for signin UI. |
77 */ | 81 */ |
78 Oobe.showSigninUI = function(opt_email) { | 82 UserManager.showSigninUI = function(opt_email) { |
79 DisplayManager.showSigninUI(opt_email); | 83 DisplayManager.showSigninUI(opt_email); |
80 }; | 84 }; |
81 | 85 |
82 /** | 86 /** |
83 * Shows sign-in error bubble. | 87 * Shows sign-in error bubble. |
84 * @param {number} loginAttempts Number of login attemps tried. | 88 * @param {number} loginAttempts Number of login attempts tried. |
85 * @param {string} message Error message to show. | 89 * @param {string} message Error message to show. |
86 * @param {string} link Text to use for help link. | 90 * @param {string} link Text to use for help link. |
87 * @param {number} helpId Help topic Id associated with help link. | 91 * @param {number} helpId Help topic Id associated with help link. |
88 */ | 92 */ |
89 Oobe.showSignInError = function(loginAttempts, message, link, helpId) { | 93 UserManager.showSignInError = function(loginAttempts, message, link, helpId) { |
90 DisplayManager.showSignInError(loginAttempts, message, link, helpId); | 94 DisplayManager.showSignInError(loginAttempts, message, link, helpId); |
91 }; | 95 }; |
92 | 96 |
93 /** | 97 /** |
94 * Clears error bubble as well as optional menus that could be open. | 98 * Clears error bubble as well as optional menus that could be open. |
95 */ | 99 */ |
96 Oobe.clearErrors = function() { | 100 UserManager.clearErrors = function() { |
97 DisplayManager.clearErrors(); | 101 DisplayManager.clearErrors(); |
98 }; | 102 }; |
99 | 103 |
100 /** | |
101 * Clears password field in user-pod. | |
102 */ | |
103 Oobe.clearUserPodPassword = function() { | |
104 DisplayManager.clearUserPodPassword(); | |
105 }; | |
106 | |
107 /** | |
108 * Restores input focus to currently selected pod. | |
109 */ | |
110 Oobe.refocusCurrentPod = function() { | |
111 DisplayManager.refocusCurrentPod(); | |
112 }; | |
113 | |
114 /** | |
115 * Show the user manager tutorial | |
116 * @param {string} email The user's email, if signed in. | |
117 * @param {string} displayName The user's display name. | |
118 */ | |
119 Oobe.showUserManagerTutorial = function() { | |
120 UserManagerTutorial.startTutorial(); | |
121 }; | |
122 | |
123 // Export | 104 // Export |
124 return { | 105 return { |
125 Oobe: Oobe | 106 UserManager: UserManager |
126 }; | 107 }; |
127 }); | 108 }); |
128 | 109 |
129 cr.define('UserManager', function() { | 110 // Alias to Oobe for use in src/ui/login/account_picker/user_pod_row.js |
130 'use strict'; | 111 var Oobe = cr.ui.UserManager; |
131 | |
132 function initialize() { | |
133 cr.ui.login.DisplayManager.initialize(); | |
134 cr.ui.login.UserManagerTutorial.initialize(); | |
135 login.AccountPickerScreen.register(); | |
136 cr.ui.Bubble.decorate($('bubble')); | |
137 login.HeaderBar.decorate($('login-header-bar')); | |
138 | |
139 // Hide the header bar until the showUserManagerMethod can apply function | |
140 // parameters that affect widget visiblity. | |
141 $('login-header-bar').hidden = true; | |
142 | |
143 chrome.send('userManagerInitialize', [window.location.hash]); | |
144 } | |
145 | |
146 // Return an object with all of the exports. | |
147 return { | |
148 initialize: initialize | |
149 }; | |
150 }); | |
151 | |
152 var Oobe = cr.ui.Oobe; | |
153 | 112 |
154 // Allow selection events on components with editable text (password field) | 113 // Allow selection events on components with editable text (password field) |
155 // bug (http://code.google.com/p/chromium/issues/detail?id=125863) | 114 // bug (http://code.google.com/p/chromium/issues/detail?id=125863) |
156 disableTextSelectAndDrag(function(e) { | 115 disableTextSelectAndDrag(function(e) { |
157 var src = e.target; | 116 var src = e.target; |
158 return src instanceof HTMLTextAreaElement || | 117 return src instanceof HTMLTextAreaElement || |
159 src instanceof HTMLInputElement && | 118 src instanceof HTMLInputElement && |
160 /text|password|search/.test(src.type); | 119 /text|password|search/.test(src.type); |
161 }); | 120 }); |
162 | 121 |
163 document.addEventListener('DOMContentLoaded', UserManager.initialize); | 122 document.addEventListener('DOMContentLoaded', cr.ui.UserManager.initialize); |
OLD | NEW |