1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 <include src="../chromeos/login/screen.js"></include>
5 <include src="../chromeos/login/bubble.js"></include>
6 <include src="../chromeos/login/display_manager.js"></include>
7 <include src="control_bar.js"></include>
8 <include src="../chromeos/login/screen_account_picker.js"></include>
9 <include src="../chromeos/login/user_pod_row.js"></include>
10 <include src="../chromeos/login/resource_loader.js"></include>
12 cr.define('cr.ui', function() {
13 var DisplayManager = cr.ui.login.DisplayManager;
16 * Constructs an Out of box controller. It manages initialization of screens,
17 * transitions, error messages display.
18 * @extends {DisplayManager}
24 cr.addSingletonGetter(Oobe);
27 __proto__: DisplayManager.prototype,
31 * Shows the given screen.
32 * @param {Object} screen Screen params dict, e.g. {id: screenId, data: data}
34 Oobe.showUserManagerScreen = function() {
35 Oobe.getInstance().showScreen({id: 'account-picker',
36 data: {disableAddUser: false}});
37 // The ChromeOS account-picker will hide the AddUser button if a user is
38 // logged in and the screen is "locked", so we must re-enabled it
39 $('add-user-header-bar-item').hidden = false;
44 * @param {string} opt_email An optional email for signin UI.
46 Oobe.launchUser = function(email, displayName) {
47 chrome.send('launchUser', [email, displayName]);
53 Oobe.disableSigninUI = function() {
54 DisplayManager.disableSigninUI();
59 * @param {string} opt_email An optional email for signin UI.
61 Oobe.showSigninUI = function(opt_email) {
62 DisplayManager.showSigninUI(opt_email);
66 * Shows sign-in error bubble.
67 * @param {number} loginAttempts Number of login attemps tried.
68 * @param {string} message Error message to show.
69 * @param {string} link Text to use for help link.
70 * @param {number} helpId Help topic Id associated with help link.
72 Oobe.showSignInError = function(loginAttempts, message, link, helpId) {
73 DisplayManager.showSignInError(loginAttempts, message, link, helpId);
77 * Clears error bubble as well as optional menus that could be open.
79 Oobe.clearErrors = function() {
80 DisplayManager.clearErrors();
84 * Clears password field in user-pod.
86 Oobe.clearUserPodPassword = function() {
87 DisplayManager.clearUserPodPassword();
91 * Restores input focus to currently selected pod.
93 Oobe.refocusCurrentPod = function() {
94 DisplayManager.refocusCurrentPod();
103 cr.define('UserManager', function() {
106 function initialize() {
107 cr.ui.login.DisplayManager.initialize();
108 login.AccountPickerScreen.register();
109 cr.ui.Bubble.decorate($('bubble'));
110 login.HeaderBar.decorate($('login-header-bar'));
111 chrome.send('userManagerInitialize');
114 // Return an object with all of the exports.
116 initialize: initialize
120 var Oobe = cr.ui.Oobe;
122 // Allow selection events on components with editable text (password field)
123 // bug (http://code.google.com/p/chromium/issues/detail?id=125863)
124 disableTextSelectAndDrag(function(e) {
126 return src instanceof HTMLTextAreaElement ||
127 src instanceof HTMLInputElement &&
128 /text|password|search/.test(src.type);
131 document.addEventListener('DOMContentLoaded', UserManager.initialize);