Chromium Code Reviews| 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 |
| 17 /** | 18 /** |
| 18 * Constructs an Out of box controller. It manages initialization of screens, | 19 * Constructs an Out of box controller. It manages initialization of screens, |
| 19 * transitions, error messages display. | 20 * transitions, error messages display. |
| 20 * | 21 * |
| 21 * @constructor | 22 * @constructor |
| 22 */ | 23 */ |
| 23 function Oobe() { | 24 function Oobe() { |
| 24 } | 25 } |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 39 | 40 |
| 40 /** | 41 /** |
| 41 * Gets current screen element. | 42 * Gets current screen element. |
| 42 * @type {HTMLElement} | 43 * @type {HTMLElement} |
| 43 */ | 44 */ |
| 44 get currentScreen() { | 45 get currentScreen() { |
| 45 return $(this.screens_[this.currentStep_]); | 46 return $(this.screens_[this.currentStep_]); |
| 46 }, | 47 }, |
| 47 | 48 |
| 48 /** | 49 /** |
| 49 * Oobe keydown handler. | 50 * Handle accelerators. |
| 51 * @param {string} accelerator name. | |
| 50 */ | 52 */ |
| 51 oobeKeyDown: function(e) { | 53 handleAccelerator: function(name) { |
| 52 var keystroke = String.fromCharCode(e.keyCode); | 54 if (name == 'accessibility') { |
|
whywhat
2011/08/08 08:09:08
optional: define accelerator names as constants ab
Mattias Nissler (ping if slow)
2011/08/08 11:11:47
Done.
| |
| 53 switch (keystroke) { | 55 chrome.send('toggleAccessibility', []); |
| 54 case 'Z': | 56 } else if (name == 'enrollment') { |
| 55 if (e.altKey && e.ctrlKey) { | 57 var currentStepId = this.screens_[this.currentStep_]; |
| 56 chrome.send('toggleAccessibility', []); | 58 if (currentStepId == SCREEN_SIGNIN || |
| 57 break; | 59 currentStepId == SCREEN_GAIA_SIGNIN) { |
| 58 } | 60 chrome.send('toggleEnrollmentScreen', []); |
| 59 case 'E': | 61 } |
| 60 var currentStepId = this.screens_[this.currentStep_]; | 62 } |
| 61 if (currentStepId == SCREEN_SIGNIN) { | |
| 62 if (e.altKey && e.ctrlKey) { | |
| 63 chrome.send('toggleEnrollmentScreen', []); | |
| 64 break; | |
| 65 } | |
| 66 } | |
| 67 } // switch | |
| 68 }, | 63 }, |
| 69 | 64 |
| 70 /** | 65 /** |
| 71 * Appends buttons to the button strip. | 66 * Appends buttons to the button strip. |
| 72 * @param {Array} buttons Array with the buttons to append. | 67 * @param {Array} buttons Array with the buttons to append. |
| 73 */ | 68 */ |
| 74 appendButtons_ : function(buttons) { | 69 appendButtons_ : function(buttons) { |
| 75 if (buttons) { | 70 if (buttons) { |
| 76 var buttonStrip = $('button-strip'); | 71 var buttonStrip = $('button-strip'); |
| 77 for (var i = 0; i < buttons.length; ++i) { | 72 for (var i = 0; i < buttons.length; ++i) { |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 289 $('bubble').showTextForElement($('add-user-button'), | 284 $('bubble').showTextForElement($('add-user-button'), |
| 290 localStrings.getString('addUserOfflineMessage')); | 285 localStrings.getString('addUserOfflineMessage')); |
| 291 } | 286 } |
| 292 }); | 287 }); |
| 293 $('cancel-add-user-button').addEventListener('click', function(e) { | 288 $('cancel-add-user-button').addEventListener('click', function(e) { |
| 294 this.hidden = true; | 289 this.hidden = true; |
| 295 $('add-user-button').hidden = false; | 290 $('add-user-button').hidden = false; |
| 296 Oobe.showScreen({id: SCREEN_ACCOUNT_PICKER}); | 291 Oobe.showScreen({id: SCREEN_ACCOUNT_PICKER}); |
| 297 }); | 292 }); |
| 298 | 293 |
| 299 document.addEventListener('keydown', function(e) { | 294 chrome.send('screenStateInitialize', []); |
| 300 Oobe.getInstance().oobeKeyDown(e); | 295 }; |
| 301 }, true); | |
| 302 | 296 |
| 303 chrome.send('screenStateInitialize', []); | 297 /** |
| 298 * Handle accelerators. These are passed from native code instead of a JS | |
| 299 * event handler in order to make sure that embedded iframes cannot swallow | |
| 300 * them. | |
| 301 * | |
|
James Hawkins
2011/08/05 20:19:50
Remove blank line.
Mattias Nissler (ping if slow)
2011/08/08 11:11:47
Done.
| |
| 302 * @param {string} accelerator name. | |
|
whywhat
2011/08/08 08:09:08
nit: Should be @param {string} name Accelerator na
Mattias Nissler (ping if slow)
2011/08/08 11:11:47
Done.
| |
| 303 */ | |
| 304 Oobe.handleAccelerator = function(name) { | |
| 305 Oobe.getInstance().handleAccelerator(name); | |
| 304 }; | 306 }; |
| 305 | 307 |
| 306 /** | 308 /** |
| 307 * Shows the given screen. | 309 * Shows the given screen. |
| 308 * @param {Object} screen Screen params dict, e.g. {id: screenId, data: data} | 310 * @param {Object} screen Screen params dict, e.g. {id: screenId, data: data} |
| 309 */ | 311 */ |
| 310 Oobe.showScreen = function(screen) { | 312 Oobe.showScreen = function(screen) { |
| 311 Oobe.getInstance().showScreen(screen); | 313 Oobe.getInstance().showScreen(screen); |
| 312 }; | 314 }; |
| 313 | 315 |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 538 document.onselectstart = function(e) { | 540 document.onselectstart = function(e) { |
| 539 e.preventDefault(); | 541 e.preventDefault(); |
| 540 } | 542 } |
| 541 | 543 |
| 542 // Disable dragging. | 544 // Disable dragging. |
| 543 document.ondragstart = function(e) { | 545 document.ondragstart = function(e) { |
| 544 e.preventDefault(); | 546 e.preventDefault(); |
| 545 } | 547 } |
| 546 | 548 |
| 547 document.addEventListener('DOMContentLoaded', cr.ui.Oobe.initialize); | 549 document.addEventListener('DOMContentLoaded', cr.ui.Oobe.initialize); |
| OLD | NEW |