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

Side by Side Diff: chrome/browser/resources/md_user_manager/user_manager.js

Issue 1630903002: material design user manager with create profile flow (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: addressed tommy's comments Created 4 years, 10 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 /* Copyright 2016 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 */
5
4 <include src="../../../../ui/login/screen.js"> 6 <include src="../../../../ui/login/screen.js">
5 <include src="../../../../ui/login/bubble.js"> 7 <include src="../../../../ui/login/bubble.js">
6 <include src="../../../../ui/login/login_ui_tools.js"> 8 <include src="../../../../ui/login/login_ui_tools.js">
7 <include src="../../../../ui/login/display_manager.js"> 9 <include src="../../../../ui/login/display_manager.js">
8 <include src="control_bar.js">
9 <include src="../../../../ui/login/account_picker/screen_account_picker.js"> 10 <include src="../../../../ui/login/account_picker/screen_account_picker.js">
10 <include src="../../../../ui/login/account_picker/user_pod_row.js"> 11 <include src="../../../../ui/login/account_picker/user_pod_row.js">
11 <include src="../../../../ui/login/resource_loader.js"> 12 <include src="../../../../ui/login/resource_loader.js">
12 <include src="user_manager_tutorial.js"> 13
13 14
14 cr.define('cr.ui', function() { 15 cr.define('cr.ui', function() {
15 var DisplayManager = cr.ui.login.DisplayManager; 16 var DisplayManager = cr.ui.login.DisplayManager;
16 var UserManagerTutorial = cr.ui.login.UserManagerTutorial;
17 17
18 /** 18 /**
19 * Constructs an Out of box controller. It manages initialization of screens, 19 * Constructs an Out of box controller. It manages initialization of screens,
20 * transitions, error messages display. 20 * transitions, error messages display.
21 * @extends {DisplayManager} 21 * @constructor
22 * @constructor 22 * @extends {DisplayManager}
23 */ 23 */
24 function Oobe() { 24 function Oobe() {}
25 }
26 25
27 cr.addSingletonGetter(Oobe); 26 cr.addSingletonGetter(Oobe);
28 27
29 Oobe.prototype = { 28 Oobe.prototype = {
30 __proto__: DisplayManager.prototype, 29 __proto__: DisplayManager.prototype,
31 }; 30 };
32 31
33 /** 32 /**
34 * Shows the given screen. 33 * Shows the given screen.
35 * @param {bool} showGuest Whether the 'Browse as Guest' button is displayed. 34 * @param {boolean} showGuest whether |Browse as Guest| button is displayed.
tommycli 2016/02/08 18:45:19 "True if the... should be displayed."
Moe 2016/02/09 00:15:33 Done.
36 * @param {bool} showAddPerson Whether the 'Add Person' button is displayed. 35 * @param {boolean} showAddPerson wether |Add Person| button is displayed.
tommycli 2016/02/08 18:45:19 misspelled
Moe 2016/02/09 00:15:34 Done.
37 */ 36 */
38 Oobe.showUserManagerScreen = function(showGuest, showAddPerson) { 37 Oobe.showUserManagerScreen = function(showGuest, showAddPerson) {
39 Oobe.getInstance().showScreen({id: 'account-picker', 38 Oobe.getInstance().showScreen({id: 'account-picker',
40 data: {disableAddUser: false}}); 39 data: {disableAddUser: false}});
41 // The ChromeOS account-picker will hide the AddUser button if a user is
42 // logged in and the screen is "locked", so we must re-enabled it
43 $('add-user-header-bar-item').hidden = false;
44
45 // Hide control options if the user does not have the right permissions. 40 // Hide control options if the user does not have the right permissions.
46 $('guest-user-button').hidden = !showGuest; 41 document.querySelector('control-bar').showGuest = showGuest;
47 $('add-user-button').hidden = !showAddPerson; 42 document.querySelector('control-bar').showAddPerson = showAddPerson;
48 $('login-header-bar').hidden = false;
49 43
50 // Disable the context menu, as the Print/Inspect element items don't 44 // Disable the context menu, as the Print/Inspect element items don't
51 // make sense when displayed as a widget. 45 // make sense when displayed as a widget.
52 document.addEventListener('contextmenu', function(e) {e.preventDefault();}); 46 document.addEventListener('contextmenu', function(e) {e.preventDefault();});
53 47
54 var hash = window.location.hash; 48 var hash = window.location.hash;
55 if (hash && hash == '#tutorial') 49 if (hash && hash == '#tutorial')
56 UserManagerTutorial.startTutorial(); 50 document.querySelector('user-manager-tutorial').startTutorial();
57 }; 51 };
58 52
59 /** 53 /**
60 * Open a new browser for the given profile. 54 * Open a new browser for the given profile.
61 * @param {string} profilePath The profile's path. 55 * @param {!string} profilePath The profile's path.
tommycli 2016/02/08 18:45:19 I believe string is implicitly non-nullable.
Moe 2016/02/09 00:15:34 Done.
62 */ 56 */
63 Oobe.launchUser = function(profilePath) { 57 Oobe.launchUser = function(profilePath) {
64 chrome.send('launchUser', [profilePath]); 58 chrome.send('launchUser', [profilePath]);
65 }; 59 };
66 60
67 /** 61 /**
68 * Disables signin UI. 62 * Disables signin UI.
69 */ 63 */
70 Oobe.disableSigninUI = function() { 64 Oobe.disableSigninUI = function() {
71 DisplayManager.disableSigninUI(); 65 DisplayManager.disableSigninUI();
72 }; 66 };
73 67
74 /** 68 /**
75 * Shows signin UI. 69 * Shows signin UI.
76 * @param {string} opt_email An optional email for signin UI. 70 * @param {!string} optEmail An optional email for signin UI.
tommycli 2016/02/08 18:45:19 Is it blank if no email? or null?
Moe 2016/02/09 00:15:33 seems like either blank or an email. updated it ac
77 */ 71 */
78 Oobe.showSigninUI = function(opt_email) { 72 Oobe.showSigninUI = function(optEmail) {
79 DisplayManager.showSigninUI(opt_email); 73 DisplayManager.showSigninUI(optEmail);
80 }; 74 };
81 75
82 /** 76 /**
83 * Shows sign-in error bubble. 77 * Shows sign-in error bubble.
84 * @param {number} loginAttempts Number of login attemps tried. 78 * @param {!number} loginAttempts Number of login attemps tried.
85 * @param {string} message Error message to show. 79 * @param {!string} message Error message to show.
86 * @param {string} link Text to use for help link. 80 * @param {!string} link Text to use for help link.
87 * @param {number} helpId Help topic Id associated with help link. 81 * @param {!number} helpId Help topic Id associated with help link.
88 */ 82 */
89 Oobe.showSignInError = function(loginAttempts, message, link, helpId) { 83 Oobe.showSignInError = function(loginAttempts, message, link, helpId) {
90 DisplayManager.showSignInError(loginAttempts, message, link, helpId); 84 DisplayManager.showSignInError(loginAttempts, message, link, helpId);
91 }; 85 };
92 86
93 /** 87 /**
94 * Clears error bubble as well as optional menus that could be open. 88 * Clears error bubble as well as optional menus that could be open.
95 */ 89 */
96 Oobe.clearErrors = function() { 90 Oobe.clearErrors = function() {
97 DisplayManager.clearErrors(); 91 DisplayManager.clearErrors();
98 }; 92 };
99 93
100 /** 94 /**
101 * Clears password field in user-pod. 95 * Clears password field in user-pod.
102 */ 96 */
103 Oobe.clearUserPodPassword = function() { 97 Oobe.clearUserPodPassword = function() {
104 DisplayManager.clearUserPodPassword(); 98 DisplayManager.clearUserPodPassword();
105 }; 99 };
106 100
107 /** 101 /**
108 * Restores input focus to currently selected pod. 102 * Restores input focus to currently selected pod.
109 */ 103 */
110 Oobe.refocusCurrentPod = function() { 104 Oobe.refocusCurrentPod = function() {
111 DisplayManager.refocusCurrentPod(); 105 DisplayManager.refocusCurrentPod();
112 }; 106 };
113 107
114 /** 108 /**
115 * Show the user manager tutorial 109 * Show the user manager tutorial
116 * @param {string} email The user's email, if signed in.
117 * @param {string} displayName The user's display name.
118 */ 110 */
119 Oobe.showUserManagerTutorial = function() { 111 Oobe.showUserManagerTutorial = function() {
120 UserManagerTutorial.startTutorial(); 112 document.querySelector('user-manager-tutorial').startTutorial();
121 }; 113 };
122 114
123 // Export 115 // Export
124 return { 116 return {
125 Oobe: Oobe 117 Oobe: Oobe
126 }; 118 };
127 }); 119 });
128 120
129 cr.define('UserManager', function() { 121 cr.define('UserManager', function() {
130 'use strict'; 122 'use strict';
131 123
132 function initialize() { 124 function initialize() {
133 cr.ui.login.DisplayManager.initialize(); 125 cr.ui.login.DisplayManager.initialize();
134 cr.ui.login.UserManagerTutorial.initialize();
135 login.AccountPickerScreen.register(); 126 login.AccountPickerScreen.register();
136 cr.ui.Bubble.decorate($('bubble')); 127 cr.ui.Bubble.decorate($('bubble'));
137 login.HeaderBar.decorate($('login-header-bar'));
138
139 // Hide the header bar until the showUserManagerMethod can apply function
140 // parameters that affect widget visiblity.
141 $('login-header-bar').hidden = true;
142 128
143 chrome.send('userManagerInitialize', [window.location.hash]); 129 chrome.send('userManagerInitialize', [window.location.hash]);
144 } 130 }
145 131
146 // Return an object with all of the exports. 132 // Return an object with all of the exports.
147 return { 133 return {
148 initialize: initialize 134 initialize: initialize
149 }; 135 };
150 }); 136 });
151 137
152 var Oobe = cr.ui.Oobe; 138 var Oobe = cr.ui.Oobe;
153 139
154 // Allow selection events on components with editable text (password field) 140 // Allow selection events on components with editable text (password field)
155 // bug (http://code.google.com/p/chromium/issues/detail?id=125863) 141 // bug (http://code.google.com/p/chromium/issues/detail?id=125863)
156 disableTextSelectAndDrag(function(e) { 142 disableTextSelectAndDrag(function(e) {
157 var src = e.target; 143 var src = e.target;
158 return src instanceof HTMLTextAreaElement || 144 return src instanceof HTMLTextAreaElement ||
159 src instanceof HTMLInputElement && 145 src instanceof HTMLInputElement &&
160 /text|password|search/.test(src.type); 146 /text|password|search/.test(src.type);
161 }); 147 });
162 148
163 document.addEventListener('DOMContentLoaded', UserManager.initialize); 149 document.addEventListener('DOMContentLoaded', UserManager.initialize);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698