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

Side by Side Diff: chrome/browser/resources/chromeos/login/oobe_common.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: remove resource paths 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
« no previous file with comments | « chrome/browser/resources/chromeos/login/oobe.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
Nikita (slow) 2013/04/16 13:01:55 nit: Makes sense to call this file login_common.js
dconnelly 2013/04/16 14:19:38 Done.
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 Common OOBE controller methods.
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="../user_images_grid.js"></include>
11 <include src="apps_menu.js"></include> 10 <include src="apps_menu.js"></include>
12 <include src="bubble.js"></include> 11 <include src="bubble.js"></include>
13 <include src="display_manager.js"></include> 12 <include src="display_manager.js"></include>
14 <include src="header_bar.js"></include> 13 <include src="header_bar.js"></include>
15 <include src="network_dropdown.js"></include> 14 <include src="network_dropdown.js"></include>
16 <include src="oobe_screen_oauth_enrollment.js"></include> 15 <include src="oobe_screen_oauth_enrollment.js"></include>
16 <include src="oobe_screen_reset.js"></include>
17 <include src="oobe_screen_terms_of_service.js"></include>
17 <include src="oobe_screen_user_image.js"></include> 18 <include src="oobe_screen_user_image.js"></include>
18 <include src="oobe_screen_reset.js"></include> 19 <include src="screen_account_picker.js"></include>
20 <include src="screen_error_message.js"></include>
21 <include src="screen_gaia_signin.js"></include>
22 <include src="screen_locally_managed_user_creation.js"></include>
23 <include src="screen_password_changed.js"></include>
24 <include src="screen_tpm_error.js"></include>
19 <include src="screen_wrong_hwid.js"></include> 25 <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> 26 <include src="user_pod_row.js"></include>
28 27
29 cr.define('cr.ui', function() { 28 cr.define('cr.ui', function() {
30 var DisplayManager = cr.ui.login.DisplayManager; 29 var DisplayManager = cr.ui.login.DisplayManager;
31 30
32 /** 31 /**
33 * Constructs an Out of box controller. It manages initialization of screens, 32 * Constructs an Out of box controller. It manages initialization of screens,
34 * transitions, error messages display. 33 * transitions, error messages display.
35 * @extends {DisplayManager} 34 * @extends {DisplayManager}
36 * @constructor 35 * @constructor
37 */ 36 */
38 function Oobe() { 37 function Oobe() {
39 } 38 }
40 39
41 cr.addSingletonGetter(Oobe); 40 cr.addSingletonGetter(Oobe);
42 41
43 Oobe.prototype = { 42 Oobe.prototype = {
44 __proto__: DisplayManager.prototype, 43 __proto__: DisplayManager.prototype,
45 }; 44 };
46 45
47 /** 46 /**
48 * Initializes the OOBE flow. This will cause all C++ handlers to
49 * be invoked to do final setup.
50 */
51 Oobe.initialize = function() {
52 DisplayManager.initialize();
53 oobe.WrongHWIDScreen.register();
54 login.AccountPickerScreen.register();
55 login.GaiaSigninScreen.register();
56 oobe.OAuthEnrollmentScreen.register();
57 oobe.UserImageScreen.register(/* lazyInit= */ true);
58 oobe.ResetScreen.register();
59 login.ErrorMessageScreen.register();
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 47 * 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 48 * event handler in order to make sure that embedded iframes cannot swallow
74 * them. 49 * them.
75 * @param {string} name Accelerator name. 50 * @param {string} name Accelerator name.
76 */ 51 */
77 Oobe.handleAccelerator = function(name) { 52 Oobe.handleAccelerator = function(name) {
78 Oobe.getInstance().handleAccelerator(name); 53 Oobe.getInstance().handleAccelerator(name);
79 }; 54 };
80 55
81 /** 56 /**
82 * Shows the given screen. 57 * Shows the given screen.
83 * @param {Object} screen Screen params dict, e.g. {id: screenId, data: data} 58 * @param {Object} screen Screen params dict, e.g. {id: screenId, data: data}
84 */ 59 */
85 Oobe.showScreen = function(screen) { 60 Oobe.showScreen = function(screen) {
86 Oobe.getInstance().showScreen(screen); 61 Oobe.getInstance().showScreen(screen);
87 }; 62 };
88 63
89 /** 64 /**
90 * Shows the previous screen of workflow. 65 * Shows the previous screen of workflow.
91 */ 66 */
92 Oobe.goBack = function() { 67 Oobe.goBack = function() {
93 Oobe.getInstance().goBack(); 68 Oobe.getInstance().goBack();
94 }; 69 };
95 70
96 /** 71 /**
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. 72 * Updates version label visibilty.
118 * @param {boolean} show True if version label should be visible. 73 * @param {boolean} show True if version label should be visible.
119 */ 74 */
120 Oobe.showVersion = function(show) { 75 Oobe.showVersion = function(show) {
121 Oobe.getInstance().showVersion(show); 76 Oobe.getInstance().showVersion(show);
122 }; 77 };
123 78
124 /** 79 /**
125 * Update body class to switch between OOBE UI and Login UI. 80 * Update body class to switch between OOBE UI and Login UI.
126 */ 81 */
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 }; 142 };
188 143
189 /** 144 /**
190 * Shows TPM error screen. 145 * Shows TPM error screen.
191 */ 146 */
192 Oobe.showTpmError = function() { 147 Oobe.showTpmError = function() {
193 DisplayManager.showTpmError(); 148 DisplayManager.showTpmError();
194 }; 149 };
195 150
196 /** 151 /**
197 * Clears error bubble. 152 * Clears error bubble as well as optional menus that could be open.
198 */ 153 */
199 Oobe.clearErrors = function() { 154 Oobe.clearErrors = function() {
155 var accessibilityMenu = $('accessibility-menu');
156 if (accessibilityMenu)
157 accessibilityMenu.hide();
200 DisplayManager.clearErrors(); 158 DisplayManager.clearErrors();
201 }; 159 };
202 160
203 /** 161 /**
204 * Displays animations on successful authentication, that have to happen 162 * Displays animations on successful authentication, that have to happen
205 * before login UI is dismissed. 163 * before login UI is dismissed.
206 */ 164 */
207 Oobe.animateAuthenticationSuccess = function() { 165 Oobe.animateAuthenticationSuccess = function() {
208 $('login-header-bar').animateOut(function() { 166 login.HeaderBar.animateOut(function() {
209 chrome.send('unlockOnLoginSuccess'); 167 chrome.send('unlockOnLoginSuccess');
210 }); 168 });
211 }; 169 };
212 170
213 /** 171 /**
214 * Displays animations that have to happen once login UI is fully displayed. 172 * Displays animations that have to happen once login UI is fully displayed.
215 */ 173 */
216 Oobe.animateOnceFullyDisplayed = function() { 174 Oobe.animateOnceFullyDisplayed = function() {
217 $('login-header-bar').animateIn(); 175 login.HeaderBar.animateIn();
218 }; 176 };
219 177
220 /** 178 /**
221 * Handles login success notification. 179 * Handles login success notification.
222 */ 180 */
223 Oobe.onLoginSuccess = function(username) { 181 Oobe.onLoginSuccess = function(username) {
224 if (Oobe.getInstance().currentScreen.id == SCREEN_ACCOUNT_PICKER) { 182 if (Oobe.getInstance().currentScreen.id == SCREEN_ACCOUNT_PICKER) {
225 // TODO(nkostylev): Enable animation back when session start jank 183 // TODO(nkostylev): Enable animation back when session start jank
226 // is reduced. See http://crosbug.com/11116 http://crosbug.com/18307 184 // is reduced. See http://crosbug.com/11116 http://crosbug.com/18307
227 // $('pod-row').startAuthenticatedAnimation(); 185 // $('pod-row').startAuthenticatedAnimation();
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 var Oobe = cr.ui.Oobe; 253 var Oobe = cr.ui.Oobe;
296 254
297 // Allow selection events on components with editable text (password field) 255 // Allow selection events on components with editable text (password field)
298 // bug (http://code.google.com/p/chromium/issues/detail?id=125863) 256 // bug (http://code.google.com/p/chromium/issues/detail?id=125863)
299 disableTextSelectAndDrag(function(e) { 257 disableTextSelectAndDrag(function(e) {
300 var src = e.target; 258 var src = e.target;
301 return src instanceof HTMLTextAreaElement || 259 return src instanceof HTMLTextAreaElement ||
302 src instanceof HTMLInputElement && 260 src instanceof HTMLInputElement &&
303 /text|password|search/.test(src.type); 261 /text|password|search/.test(src.type);
304 }); 262 });
305
306 document.addEventListener('DOMContentLoaded', cr.ui.Oobe.initialize);
OLDNEW
« no previous file with comments | « chrome/browser/resources/chromeos/login/oobe.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698