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="../login/screen.js"></include>
5 <include src="../login/bubble.js"></include>
6 <include src="../login/display_manager.js"></include>
7 <include src="control_bar.js"></include>
8 <include src="../login/screen_account_picker.js"></include>
9 <include src="../login/user_pod_row.js"></include>
10 <include src="../login/resource_loader.js"></include>
11 <include src="user_manager_tutorial.js"></include>
13 cr.define('cr.ui', function() {
14 var DisplayManager = cr.ui.login.DisplayManager;
15 var UserManagerTutorial = cr.ui.login.UserManagerTutorial;
18 * Constructs an Out of box controller. It manages initialization of screens,
19 * transitions, error messages display.
20 * @extends {DisplayManager}
26 cr.addSingletonGetter(Oobe);
29 __proto__: DisplayManager.prototype,
33 * Shows the given screen.
34 * @param {Object} screen Screen params dict, e.g. {id: screenId, data: data}
36 Oobe.showUserManagerScreen = function() {
37 Oobe.getInstance().showScreen({id: 'account-picker',
38 data: {disableAddUser: false}});
39 // The ChromeOS account-picker will hide the AddUser button if a user is
40 // logged in and the screen is "locked", so we must re-enabled it
41 $('add-user-header-bar-item').hidden = false;
43 var hash = window.location.hash;
44 if (hash && hash == '#tutorial')
45 UserManagerTutorial.startTutorial();
49 * Open a new browser for the given profile.
50 * @param {string} email The user's email, if signed in.
51 * @param {string} displayName The user's display name.
53 Oobe.launchUser = function(email, displayName) {
54 chrome.send('launchUser', [email, displayName]);
60 Oobe.disableSigninUI = function() {
61 DisplayManager.disableSigninUI();
66 * @param {string} opt_email An optional email for signin UI.
68 Oobe.showSigninUI = function(opt_email) {
69 DisplayManager.showSigninUI(opt_email);
73 * Shows sign-in error bubble.
74 * @param {number} loginAttempts Number of login attemps tried.
75 * @param {string} message Error message to show.
76 * @param {string} link Text to use for help link.
77 * @param {number} helpId Help topic Id associated with help link.
79 Oobe.showSignInError = function(loginAttempts, message, link, helpId) {
80 DisplayManager.showSignInError(loginAttempts, message, link, helpId);
84 * Clears error bubble as well as optional menus that could be open.
86 Oobe.clearErrors = function() {
87 DisplayManager.clearErrors();
91 * Clears password field in user-pod.
93 Oobe.clearUserPodPassword = function() {
94 DisplayManager.clearUserPodPassword();
98 * Restores input focus to currently selected pod.
100 Oobe.refocusCurrentPod = function() {
101 DisplayManager.refocusCurrentPod();
105 * Show the user manager tutorial
106 * @param {string} email The user's email, if signed in.
107 * @param {string} displayName The user's display name.
109 Oobe.showUserManagerTutorial = function() {
110 UserManagerTutorial.startTutorial();
119 cr.define('UserManager', function() {
122 function initialize() {
123 cr.ui.login.DisplayManager.initialize();
124 cr.ui.login.UserManagerTutorial.initialize();
125 login.AccountPickerScreen.register();
126 cr.ui.Bubble.decorate($('bubble'));
127 login.HeaderBar.decorate($('login-header-bar'));
128 chrome.send('userManagerInitialize');
131 // Return an object with all of the exports.
133 initialize: initialize
137 var Oobe = cr.ui.Oobe;
139 // Allow selection events on components with editable text (password field)
140 // bug (http://code.google.com/p/chromium/issues/detail?id=125863)
141 disableTextSelectAndDrag(function(e) {
143 return src instanceof HTMLTextAreaElement ||
144 src instanceof HTMLInputElement &&
145 /text|password|search/.test(src.type);
148 document.addEventListener('DOMContentLoaded', UserManager.initialize);