OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 Out of the box experience flow (OOBE). | 6 * @fileoverview Out of the box experience flow (OOBE). |
7 * This is the main code for the OOBE WebUI implementation. | 7 * This is the main code for the OOBE WebUI implementation. |
8 */ | 8 */ |
9 | 9 |
10 var localStrings = new LocalStrings(); | 10 var localStrings = new LocalStrings(); |
11 | 11 |
12 | 12 |
13 cr.define('cr.ui', function() { | 13 cr.define('cr.ui', function() { |
14 const SCREEN_SIGNIN = 'signin'; | 14 const SCREEN_SIGNIN = 'signin'; |
| 15 const SCREEN_GAIA_SIGNIN = 'gaia-signin'; |
15 const SCREEN_ACCOUNT_PICKER = 'account-picker'; | 16 const SCREEN_ACCOUNT_PICKER = 'account-picker'; |
16 | 17 |
| 18 /* Accelerator identifiers. Must be kept in sync with webui_login_view.cc. */ |
| 19 const ACCELERATOR_ACCESSIBILITY = 'accessibility'; |
| 20 const ACCELERATOR_ENROLLMENT = 'enrollment'; |
| 21 |
17 /** | 22 /** |
18 * Constructs an Out of box controller. It manages initialization of screens, | 23 * Constructs an Out of box controller. It manages initialization of screens, |
19 * transitions, error messages display. | 24 * transitions, error messages display. |
20 * | 25 * |
21 * @constructor | 26 * @constructor |
22 */ | 27 */ |
23 function Oobe() { | 28 function Oobe() { |
24 } | 29 } |
25 | 30 |
26 cr.addSingletonGetter(Oobe); | 31 cr.addSingletonGetter(Oobe); |
(...skipping 12 matching lines...) Expand all Loading... |
39 | 44 |
40 /** | 45 /** |
41 * Gets current screen element. | 46 * Gets current screen element. |
42 * @type {HTMLElement} | 47 * @type {HTMLElement} |
43 */ | 48 */ |
44 get currentScreen() { | 49 get currentScreen() { |
45 return $(this.screens_[this.currentStep_]); | 50 return $(this.screens_[this.currentStep_]); |
46 }, | 51 }, |
47 | 52 |
48 /** | 53 /** |
49 * Oobe keydown handler. | 54 * Handle accelerators. |
| 55 * @param {string} accelerator name. |
50 */ | 56 */ |
51 oobeKeyDown: function(e) { | 57 handleAccelerator: function(name) { |
52 var keystroke = String.fromCharCode(e.keyCode); | 58 if (name == ACCELERATOR_ACCESSIBILITY) { |
53 switch (keystroke) { | 59 chrome.send('toggleAccessibility', []); |
54 case 'Z': | 60 } else if (ACCELERATOR_ENROLLMENT) { |
55 if (e.altKey && e.ctrlKey) { | 61 var currentStepId = this.screens_[this.currentStep_]; |
56 chrome.send('toggleAccessibility', []); | 62 if (currentStepId == SCREEN_SIGNIN || |
57 break; | 63 currentStepId == SCREEN_GAIA_SIGNIN) { |
58 } | 64 chrome.send('toggleEnrollmentScreen', []); |
59 case 'E': | 65 } |
60 var currentStepId = this.screens_[this.currentStep_]; | 66 } |
61 if (currentStepId == SCREEN_SIGNIN) { | |
62 if (e.altKey && e.ctrlKey) { | |
63 chrome.send('toggleEnrollmentScreen', []); | |
64 break; | |
65 } | |
66 } | |
67 } // switch | |
68 }, | 67 }, |
69 | 68 |
70 /** | 69 /** |
71 * Appends buttons to the button strip. | 70 * Appends buttons to the button strip. |
72 * @param {Array} buttons Array with the buttons to append. | 71 * @param {Array} buttons Array with the buttons to append. |
73 */ | 72 */ |
74 appendButtons_ : function(buttons) { | 73 appendButtons_ : function(buttons) { |
75 if (buttons) { | 74 if (buttons) { |
76 var buttonStrip = $('button-strip'); | 75 var buttonStrip = $('button-strip'); |
77 for (var i = 0; i < buttons.length; ++i) { | 76 for (var i = 0; i < buttons.length; ++i) { |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
284 $('bubble').showTextForElement($('add-user-button'), | 283 $('bubble').showTextForElement($('add-user-button'), |
285 localStrings.getString('addUserOfflineMessage')); | 284 localStrings.getString('addUserOfflineMessage')); |
286 } | 285 } |
287 }); | 286 }); |
288 $('cancel-add-user-button').addEventListener('click', function(e) { | 287 $('cancel-add-user-button').addEventListener('click', function(e) { |
289 this.hidden = true; | 288 this.hidden = true; |
290 $('add-user-button').hidden = false; | 289 $('add-user-button').hidden = false; |
291 Oobe.showScreen({id: SCREEN_ACCOUNT_PICKER}); | 290 Oobe.showScreen({id: SCREEN_ACCOUNT_PICKER}); |
292 }); | 291 }); |
293 | 292 |
294 document.addEventListener('keydown', function(e) { | 293 chrome.send('screenStateInitialize', []); |
295 Oobe.getInstance().oobeKeyDown(e); | 294 }; |
296 }, true); | |
297 | 295 |
298 chrome.send('screenStateInitialize', []); | 296 /** |
| 297 * Handle accelerators. These are passed from native code instead of a JS |
| 298 * event handler in order to make sure that embedded iframes cannot swallow |
| 299 * them. |
| 300 * @param {string} name accelerator name. |
| 301 */ |
| 302 Oobe.handleAccelerator = function(name) { |
| 303 Oobe.getInstance().handleAccelerator(name); |
299 }; | 304 }; |
300 | 305 |
301 /** | 306 /** |
302 * Shows the given screen. | 307 * Shows the given screen. |
303 * @param {Object} screen Screen params dict, e.g. {id: screenId, data: data} | 308 * @param {Object} screen Screen params dict, e.g. {id: screenId, data: data} |
304 */ | 309 */ |
305 Oobe.showScreen = function(screen) { | 310 Oobe.showScreen = function(screen) { |
306 Oobe.getInstance().showScreen(screen); | 311 Oobe.getInstance().showScreen(screen); |
307 }; | 312 }; |
308 | 313 |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
521 document.onselectstart = function(e) { | 526 document.onselectstart = function(e) { |
522 e.preventDefault(); | 527 e.preventDefault(); |
523 } | 528 } |
524 | 529 |
525 // Disable dragging. | 530 // Disable dragging. |
526 document.ondragstart = function(e) { | 531 document.ondragstart = function(e) { |
527 e.preventDefault(); | 532 e.preventDefault(); |
528 } | 533 } |
529 | 534 |
530 document.addEventListener('DOMContentLoaded', cr.ui.Oobe.initialize); | 535 document.addEventListener('DOMContentLoaded', cr.ui.Oobe.initialize); |
OLD | NEW |