Chromium Code Reviews| Index: chrome/browser/resources/md_user_manager/user_manager.js |
| diff --git a/chrome/browser/resources/user_manager/user_manager.js b/chrome/browser/resources/md_user_manager/user_manager.js |
| similarity index 47% |
| copy from chrome/browser/resources/user_manager/user_manager.js |
| copy to chrome/browser/resources/md_user_manager/user_manager.js |
| index 39d76d4764abe302a71089b17d7563c0322f5290..30bdc5942cdc33c2eaf54f0d56d30e2a63616aaf 100644 |
| --- a/chrome/browser/resources/user_manager/user_manager.js |
| +++ b/chrome/browser/resources/md_user_manager/user_manager.js |
| @@ -1,155 +1,114 @@ |
| -// Copyright 2013 The Chromium Authors. All rights reserved. |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| + |
| <include src="../../../../ui/login/screen.js"> |
| <include src="../../../../ui/login/bubble.js"> |
| <include src="../../../../ui/login/login_ui_tools.js"> |
| <include src="../../../../ui/login/display_manager.js"> |
| -<include src="control_bar.js"> |
| <include src="../../../../ui/login/account_picker/screen_account_picker.js"> |
| <include src="../../../../ui/login/account_picker/user_pod_row.js"> |
| <include src="../../../../ui/login/resource_loader.js"> |
| -<include src="user_manager_tutorial.js"> |
| + |
| cr.define('cr.ui', function() { |
| var DisplayManager = cr.ui.login.DisplayManager; |
| - var UserManagerTutorial = cr.ui.login.UserManagerTutorial; |
| /** |
| - * Constructs an Out of box controller. It manages initialization of screens, |
| - * transitions, error messages display. |
| - * @extends {DisplayManager} |
| - * @constructor |
| + * Manages initialization of screens, transitions, and error messages. |
| + * @constructor |
| + * @extends {DisplayManager} |
| */ |
| - function Oobe() { |
| - } |
| + function UserManager() {} |
| - cr.addSingletonGetter(Oobe); |
| + cr.addSingletonGetter(UserManager); |
| - Oobe.prototype = { |
| + UserManager.prototype = { |
| __proto__: DisplayManager.prototype, |
| }; |
| /** |
| + * Initializes the UserManager. |
| + */ |
| + UserManager.initialize = function() { |
| + cr.ui.login.DisplayManager.initialize(); |
| + login.AccountPickerScreen.register(); |
| + cr.ui.Bubble.decorate($('bubble')); |
| + |
| + chrome.send('userManagerInitialize', [window.location.hash]); |
| + }; |
| + |
| + /** |
| * Shows the given screen. |
| - * @param {bool} showGuest Whether the 'Browse as Guest' button is displayed. |
| - * @param {bool} showAddPerson Whether the 'Add Person' button is displayed. |
| + * @param {boolean} showGuest True if 'Browse as Guest' button should be |
| + * displayed. |
|
Dan Beam
2016/03/04 02:45:49
@param ...
... extra likes wrap at 4\s indent
Moe
2016/03/08 00:57:05
Done.
|
| + * @param {boolean} showAddPerson True if 'Add Person' button should be |
| + * displayed. |
| */ |
| - Oobe.showUserManagerScreen = function(showGuest, showAddPerson) { |
| - Oobe.getInstance().showScreen({id: 'account-picker', |
| + UserManager.showUserManagerScreen = function(showGuest, showAddPerson) { |
| + UserManager.getInstance().showScreen({id: 'account-picker', |
| data: {disableAddUser: false}}); |
|
Dan Beam
2016/03/04 02:45:49
indent off
Moe
2016/03/08 00:57:05
Done.
|
| - // The ChromeOS account-picker will hide the AddUser button if a user is |
| - // logged in and the screen is "locked", so we must re-enabled it |
| - $('add-user-header-bar-item').hidden = false; |
| - |
| // Hide control options if the user does not have the right permissions. |
| - $('guest-user-button').hidden = !showGuest; |
| - $('add-user-button').hidden = !showAddPerson; |
| - $('login-header-bar').hidden = false; |
| + var controlBar = document.querySelector('control-bar'); |
| + controlBar.showGuest = showGuest; |
| + controlBar.showAddPerson = showAddPerson; |
| // Disable the context menu, as the Print/Inspect element items don't |
| // make sense when displayed as a widget. |
| document.addEventListener('contextmenu', function(e) {e.preventDefault();}); |
| - var hash = window.location.hash; |
| - if (hash && hash == '#tutorial') |
| - UserManagerTutorial.startTutorial(); |
| + // TODO(mahmadi): start the tutorial if the location hash is #tutorial. |
| }; |
| /** |
| * Open a new browser for the given profile. |
| * @param {string} profilePath The profile's path. |
| */ |
| - Oobe.launchUser = function(profilePath) { |
| + UserManager.launchUser = function(profilePath) { |
| chrome.send('launchUser', [profilePath]); |
| }; |
| /** |
| * Disables signin UI. |
| */ |
| - Oobe.disableSigninUI = function() { |
| + UserManager.disableSigninUI = function() { |
| DisplayManager.disableSigninUI(); |
| }; |
| /** |
| * Shows signin UI. |
| - * @param {string} opt_email An optional email for signin UI. |
| + * @param {string=} opt_email An optional email for signin UI. |
| */ |
| - Oobe.showSigninUI = function(opt_email) { |
| + UserManager.showSigninUI = function(opt_email) { |
| DisplayManager.showSigninUI(opt_email); |
| }; |
| /** |
| * Shows sign-in error bubble. |
| - * @param {number} loginAttempts Number of login attemps tried. |
| + * @param {number} loginAttempts Number of login attempts tried. |
| * @param {string} message Error message to show. |
| * @param {string} link Text to use for help link. |
| * @param {number} helpId Help topic Id associated with help link. |
| */ |
| - Oobe.showSignInError = function(loginAttempts, message, link, helpId) { |
| + UserManager.showSignInError = function(loginAttempts, message, link, helpId) { |
| DisplayManager.showSignInError(loginAttempts, message, link, helpId); |
| }; |
| /** |
| * Clears error bubble as well as optional menus that could be open. |
| */ |
| - Oobe.clearErrors = function() { |
| + UserManager.clearErrors = function() { |
| DisplayManager.clearErrors(); |
| }; |
| - /** |
| - * Clears password field in user-pod. |
| - */ |
| - Oobe.clearUserPodPassword = function() { |
| - DisplayManager.clearUserPodPassword(); |
| - }; |
| - |
| - /** |
| - * Restores input focus to currently selected pod. |
| - */ |
| - Oobe.refocusCurrentPod = function() { |
| - DisplayManager.refocusCurrentPod(); |
| - }; |
| - |
| - /** |
| - * Show the user manager tutorial |
| - * @param {string} email The user's email, if signed in. |
| - * @param {string} displayName The user's display name. |
| - */ |
| - Oobe.showUserManagerTutorial = function() { |
| - UserManagerTutorial.startTutorial(); |
| - }; |
| - |
| // Export |
| return { |
| - Oobe: Oobe |
| - }; |
| -}); |
| - |
| -cr.define('UserManager', function() { |
| - 'use strict'; |
| - |
| - function initialize() { |
| - cr.ui.login.DisplayManager.initialize(); |
| - cr.ui.login.UserManagerTutorial.initialize(); |
| - login.AccountPickerScreen.register(); |
| - cr.ui.Bubble.decorate($('bubble')); |
| - login.HeaderBar.decorate($('login-header-bar')); |
| - |
| - // Hide the header bar until the showUserManagerMethod can apply function |
| - // parameters that affect widget visiblity. |
| - $('login-header-bar').hidden = true; |
| - |
| - chrome.send('userManagerInitialize', [window.location.hash]); |
| - } |
| - |
| - // Return an object with all of the exports. |
| - return { |
| - initialize: initialize |
| + UserManager: UserManager |
| }; |
| }); |
| -var Oobe = cr.ui.Oobe; |
| +// Alias to Oobe for use in src/ui/login/account_picker/user_pod_row.js |
| +var Oobe = cr.ui.UserManager; |
|
Dan Beam
2016/03/04 02:45:49
this is unfortunate but at least not in code i own
Moe
2016/03/08 00:57:05
I agree. The code is easier to understand now. We
|
| // Allow selection events on components with editable text (password field) |
| // bug (http://code.google.com/p/chromium/issues/detail?id=125863) |
| @@ -160,4 +119,4 @@ disableTextSelectAndDrag(function(e) { |
| /text|password|search/.test(src.type); |
| }); |
| -document.addEventListener('DOMContentLoaded', UserManager.initialize); |
| +document.addEventListener('DOMContentLoaded', cr.ui.UserManager.initialize); |