Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(28)

Side by Side Diff: chrome/browser/resources/chromeos/login/login.js

Issue 13963004: Extract common OOBE controller code from oobe.js/login.js. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: small fixes Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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
5 /** 5 /**
6 * @fileoverview Login UI based on a stripped down OOBE controller. 6 * @fileoverview Login UI based on a stripped down OOBE controller.
7 * TODO(xiyuan): Refactoring this to get a better structure.
8 */ 7 */
9 8
10 <include src="../user_images_grid.js"></include> 9 <include src="oobe_common.js"></include>
11 <include src="apps_menu.js"></include>
12 <include src="bubble.js"></include>
13 <include src="display_manager.js"></include>
14 <include src="header_bar.js"></include>
15 <include src="network_dropdown.js"></include>
16 <include src="oobe_screen_oauth_enrollment.js"></include>
17 <include src="oobe_screen_user_image.js"></include>
18 <include src="oobe_screen_reset.js"></include>
19 <include src="screen_wrong_hwid.js"></include>
20 <include src="screen_account_picker.js"></include>
21 <include src="screen_gaia_signin.js"></include>
22 <include src="screen_error_message.js"></include>
23 <include src="screen_tpm_error.js"></include>
24 <include src="screen_password_changed.js"></include>
25 <include src="screen_locally_managed_user_creation.js"></include>
26 <include src="oobe_screen_terms_of_service.js"></include>
27 <include src="user_pod_row.js"></include>
28 10
29 cr.define('cr.ui', function() { 11 cr.define('cr.ui.Oobe', function() {
30 var DisplayManager = cr.ui.login.DisplayManager; 12 return {
13 /**
14 * Initializes the OOBE flow. This will cause all C++ handlers to
15 * be invoked to do final setup.
16 */
17 initialize: function() {
18 cr.ui.login.DisplayManager.initialize();
19 oobe.WrongHWIDScreen.register();
20 login.AccountPickerScreen.register();
21 login.GaiaSigninScreen.register();
22 oobe.OAuthEnrollmentScreen.register();
23 oobe.UserImageScreen.register(/* lazyInit= */ true);
24 oobe.ResetScreen.register();
25 login.ErrorMessageScreen.register();
26 login.TPMErrorMessageScreen.register();
27 login.PasswordChangedScreen.register();
28 login.LocallyManagedUserCreationScreen.register();
29 oobe.TermsOfServiceScreen.register();
31 30
32 /** 31 cr.ui.Bubble.decorate($('bubble'));
33 * Constructs an Out of box controller. It manages initialization of screens, 32 login.HeaderBar.decorate($('login-header-bar'));
34 * transitions, error messages display.
35 * @extends {DisplayManager}
36 * @constructor
37 */
38 function Oobe() {
39 }
40 33
41 cr.addSingletonGetter(Oobe); 34 chrome.send('screenStateInitialize');
35 },
42 36
43 Oobe.prototype = { 37 // Dummy Oobe functions not present with stripped login UI.
44 __proto__: DisplayManager.prototype, 38 initializeA11yMenu: function(e) {},
45 }; 39 handleAccessbilityLinkClick: function(e) {},
46 40 handleSpokenFeedbackClick: function(e) {},
47 /** 41 handleHighContrastClick: function(e) {},
48 * Initializes the OOBE flow. This will cause all C++ handlers to 42 handleScreenMagnifierClick: function(e) {},
49 * be invoked to do final setup. 43 enableContinueButton: function(enable) {},
50 */ 44 setUsageStats: function(checked) {},
51 Oobe.initialize = function() { 45 setOemEulaUrl: function(oemEulaUrl) {},
52 DisplayManager.initialize(); 46 setUpdateProgress: function(progress) {},
53 oobe.WrongHWIDScreen.register(); 47 showUpdateEstimatedTimeLeft: function(enable) {},
54 login.AccountPickerScreen.register(); 48 setUpdateEstimatedTimeLeft: function(seconds) {},
55 login.GaiaSigninScreen.register(); 49 setUpdateMessage: function(message) {},
56 oobe.OAuthEnrollmentScreen.register(); 50 showUpdateCurtain: function(enable) {},
57 oobe.UserImageScreen.register(/* lazyInit= */ true); 51 setTpmPassword: function(password) {},
58 oobe.ResetScreen.register(); 52 refreshA11yInfo: function(data) {},
59 login.ErrorMessageScreen.register(); 53 reloadContent: function(data) {},
60 login.TPMErrorMessageScreen.register();
61 login.PasswordChangedScreen.register();
62 login.LocallyManagedUserCreationScreen.register();
63 oobe.TermsOfServiceScreen.register();
64
65 cr.ui.Bubble.decorate($('bubble'));
66 login.HeaderBar.decorate($('login-header-bar'));
67
68 chrome.send('screenStateInitialize');
69 };
70
71 /**
72 * Handle accelerators. These are passed from native code instead of a JS
73 * event handler in order to make sure that embedded iframes cannot swallow
74 * them.
75 * @param {string} name Accelerator name.
76 */
77 Oobe.handleAccelerator = function(name) {
78 Oobe.getInstance().handleAccelerator(name);
79 };
80
81 /**
82 * Shows the given screen.
83 * @param {Object} screen Screen params dict, e.g. {id: screenId, data: data}
84 */
85 Oobe.showScreen = function(screen) {
86 Oobe.getInstance().showScreen(screen);
87 };
88
89 /**
90 * Shows the previous screen of workflow.
91 */
92 Oobe.goBack = function() {
93 Oobe.getInstance().goBack();
94 };
95
96 /**
97 * Dummy Oobe functions not present with stripped login UI.
98 */
99 Oobe.initializeA11yMenu = function(e) {};
100 Oobe.handleAccessbilityLinkClick = function(e) {};
101 Oobe.handleSpokenFeedbackClick = function(e) {};
102 Oobe.handleHighContrastClick = function(e) {};
103 Oobe.handleScreenMagnifierClick = function(e) {};
104 Oobe.enableContinueButton = function(enable) {};
105 Oobe.setUsageStats = function(checked) {};
106 Oobe.setOemEulaUrl = function(oemEulaUrl) {};
107 Oobe.setUpdateProgress = function(progress) {};
108 Oobe.showUpdateEstimatedTimeLeft = function(enable) {};
109 Oobe.setUpdateEstimatedTimeLeft = function(seconds) {};
110 Oobe.setUpdateMessage = function(message) {};
111 Oobe.showUpdateCurtain = function(enable) {};
112 Oobe.setTpmPassword = function(password) {};
113 Oobe.refreshA11yInfo = function(data) {};
114 Oobe.reloadContent = function(data) {};
115
116 /**
117 * Updates version label visibilty.
118 * @param {boolean} show True if version label should be visible.
119 */
120 Oobe.showVersion = function(show) {
121 Oobe.getInstance().showVersion(show);
122 };
123
124 /**
125 * Update body class to switch between OOBE UI and Login UI.
126 */
127 Oobe.showOobeUI = function(showOobe) {
128 if (showOobe) {
129 document.body.classList.remove('login-display');
130 } else {
131 document.body.classList.add('login-display');
132 Oobe.getInstance().prepareForLoginDisplay_();
133 }
134
135 // Don't show header bar for OOBE.
136 Oobe.getInstance().headerHidden = showOobe;
137 };
138
139 /**
140 * Disables signin UI.
141 */
142 Oobe.disableSigninUI = function() {
143 DisplayManager.disableSigninUI();
144 };
145
146 /**
147 * Shows signin UI.
148 * @param {string} opt_email An optional email for signin UI.
149 */
150 Oobe.showSigninUI = function(opt_email) {
151 DisplayManager.showSigninUI(opt_email);
152 };
153
154 /**
155 * Resets sign-in input fields.
156 * @param {boolean} forceOnline Whether online sign-in should be forced.
157 * If |forceOnline| is false previously used sign-in type will be used.
158 */
159 Oobe.resetSigninUI = function(forceOnline) {
160 DisplayManager.resetSigninUI(forceOnline);
161 };
162
163 /**
164 * Shows sign-in error bubble.
165 * @param {number} loginAttempts Number of login attemps tried.
166 * @param {string} message Error message to show.
167 * @param {string} link Text to use for help link.
168 * @param {number} helpId Help topic Id associated with help link.
169 */
170 Oobe.showSignInError = function(loginAttempts, message, link, helpId) {
171 DisplayManager.showSignInError(loginAttempts, message, link, helpId);
172 };
173
174 /**
175 * Shows password changed screen that offers migration.
176 * @param {boolean} showError Whether to show the incorrect password error.
177 */
178 Oobe.showPasswordChangedScreen = function(showError) {
179 DisplayManager.showPasswordChangedScreen(showError);
180 };
181
182 /**
183 * Shows dialog to create managed user.
184 */
185 Oobe.showManagedUserCreationScreen = function() {
186 DisplayManager.showManagedUserCreationScreen();
187 };
188
189 /**
190 * Shows TPM error screen.
191 */
192 Oobe.showTpmError = function() {
193 DisplayManager.showTpmError();
194 };
195
196 /**
197 * Clears error bubble.
198 */
199 Oobe.clearErrors = function() {
200 DisplayManager.clearErrors();
201 };
202
203 /**
204 * Displays animations on successful authentication, that have to happen
205 * before login UI is dismissed.
206 */
207 Oobe.animateAuthenticationSuccess = function() {
208 $('login-header-bar').animateOut(function() {
209 chrome.send('unlockOnLoginSuccess');
210 });
211 };
212
213 /**
214 * Displays animations that have to happen once login UI is fully displayed.
215 */
216 Oobe.animateOnceFullyDisplayed = function() {
217 $('login-header-bar').animateIn();
218 };
219
220 /**
221 * Handles login success notification.
222 */
223 Oobe.onLoginSuccess = function(username) {
224 if (Oobe.getInstance().currentScreen.id == SCREEN_ACCOUNT_PICKER) {
225 // TODO(nkostylev): Enable animation back when session start jank
226 // is reduced. See http://crosbug.com/11116 http://crosbug.com/18307
227 // $('pod-row').startAuthenticatedAnimation();
228 }
229 };
230
231 /**
232 * Sets text content for a div with |labelId|.
233 * @param {string} labelId Id of the label div.
234 * @param {string} labelText Text for the label.
235 */
236 Oobe.setLabelText = function(labelId, labelText) {
237 DisplayManager.setLabelText(labelId, labelText);
238 };
239
240 /**
241 * Sets the text content of the enterprise info message.
242 * If the text is empty, the entire notification will be hidden.
243 * @param {string} messageText The message text.
244 */
245 Oobe.setEnterpriseInfo = function(messageText) {
246 DisplayManager.setEnterpriseInfo(messageText);
247 };
248
249 /**
250 * Enforces focus on user pod of locked user.
251 */
252 Oobe.forceLockedUserPodFocus = function() {
253 login.AccountPickerScreen.forceLockedUserPodFocus();
254 };
255
256 /**
257 * Sets the domain name whose Terms of Service are being shown on the Terms of
258 * Service screen.
259 * @param {string} domain The domain name.
260 */
261 Oobe.setTermsOfServiceDomain = function(domain) {
262 oobe.TermsOfServiceScreen.setDomain(domain);
263 };
264
265 /**
266 * Displays an error message on the Terms of Service screen. Called when the
267 * download of the Terms of Service has failed.
268 */
269 Oobe.setTermsOfServiceLoadError = function() {
270 $('terms-of-service').classList.remove('tos-loading');
271 $('terms-of-service').classList.add('error');
272 };
273
274 /**
275 * Displays the given |termsOfService| on the Terms of Service screen.
276 * @param {string} termsOfService The terms of service, as plain text.
277 */
278 Oobe.setTermsOfService = function(termsOfService) {
279 oobe.TermsOfServiceScreen.setTermsOfService(termsOfService);
280 };
281
282 /**
283 * Clears password field in user-pod.
284 */
285 Oobe.clearUserPodPassword = function() {
286 DisplayManager.clearUserPodPassword();
287 };
288
289 // Export
290 return {
291 Oobe: Oobe
292 }; 54 };
293 }); 55 });
294 56
295 var Oobe = cr.ui.Oobe;
296
297 // Allow selection events on components with editable text (password field)
298 // bug (http://code.google.com/p/chromium/issues/detail?id=125863)
299 disableTextSelectAndDrag(function(e) {
300 var src = e.target;
301 return src instanceof HTMLTextAreaElement ||
302 src instanceof HTMLInputElement &&
303 /text|password|search/.test(src.type);
304 });
305
306 document.addEventListener('DOMContentLoaded', cr.ui.Oobe.initialize); 57 document.addEventListener('DOMContentLoaded', cr.ui.Oobe.initialize);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698