| OLD | NEW |
| 1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 | 4 |
| 5 /** | 5 /** |
| 6 * @fileoverview Login UI based on a stripped down OOBE controller. | 6 * @fileoverview Login UI based on a stripped down OOBE controller. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 // <include src="login_shared.js"> | 9 // <include src="login_shared.js"> |
| 10 | 10 |
| 11 /** | 11 /** |
| 12 * Asynchronously loads the pin keyboard. | 12 * Ensures that the pin keyboard is loaded. |
| 13 * @param {function()} onLoaded Callback run when the pin keyboard is loaded. |
| 13 */ | 14 */ |
| 14 function showPinKeyboardAsync() { | 15 function ensurePinKeyboardLoaded(onLoaded) { |
| 15 'use strict'; | 16 'use strict'; |
| 16 | 17 |
| 17 // This function could get called multiple times. Do nothing if we have | 18 // The element we want to see if loaded. |
| 18 // already loaded. This check needs to happen before the registerAssets call, | 19 var getPinKeyboard = function() { |
| 19 // because that will clobber the loaded state. | 20 return $('pod-row').querySelectorAll('pin-keyboard')[0]; |
| 20 if (cr.ui.login.ResourceLoader.hasDeferredAssets('custom-elements')) | 21 }; |
| 22 |
| 23 // Do not reload assets if they are already loaded. Run |onLoaded| once assets |
| 24 // are done loading, though. |
| 25 if (cr.ui.login.ResourceLoader.hasDeferredAssets('custom-elements')) { |
| 26 cr.ui.login.ResourceLoader.waitUntilLayoutComplete(getPinKeyboard, |
| 27 onLoaded); |
| 21 return; | 28 return; |
| 29 } |
| 22 | 30 |
| 23 // Register loader for custom elements. | 31 // Register loader for custom elements. |
| 24 cr.ui.login.ResourceLoader.registerAssets({ | 32 cr.ui.login.ResourceLoader.registerAssets({ |
| 25 id: 'custom-elements', | 33 id: 'custom-elements', |
| 26 html: [{ url: 'chrome://oobe/custom_elements.html' }] | 34 html: [{ url: 'chrome://oobe/custom_elements.html' }] |
| 27 }); | 35 }); |
| 28 | 36 |
| 29 // Called after polymer has been loaded. Fades the pin element in. | |
| 30 var onPinLoaded = function(pinKeyboard) { | |
| 31 var podRow = $('pod-row'); | |
| 32 podRow.toggleTransitions(true); | |
| 33 podRow.setFocusedPodPinVisibility(true); | |
| 34 }; | |
| 35 | |
| 36 // The element we want to see if loaded. | |
| 37 var getPinKeyboard = function() { | |
| 38 return $('pod-row').querySelectorAll('pin-keyboard')[0]; | |
| 39 }; | |
| 40 | |
| 41 // We only load the PIN element when it is actually shown so that lock screen | 37 // We only load the PIN element when it is actually shown so that lock screen |
| 42 // load times remain low when the user is not using a PIN. | 38 // load times remain low when the user is not using a PIN. |
| 43 // | 39 // |
| 44 // Loading the PIN element blocks the DOM, which will interrupt any running | 40 // Loading the PIN element blocks the DOM, which will interrupt any running |
| 45 // animations. We load the PIN after an idle notification to allow the pod | 41 // animations. We load the PIN after an idle notification to allow the pod |
| 46 // fly-in animation to complete without interruption. | 42 // fly-in animation to complete without interruption. |
| 47 cr.ui.login.ResourceLoader.loadAssetsOnIdle('custom-elements', function() { | 43 cr.ui.login.ResourceLoader.loadAssetsOnIdle('custom-elements', function() { |
| 48 cr.ui.login.ResourceLoader.waitUntilLayoutComplete(getPinKeyboard, | 44 cr.ui.login.ResourceLoader.waitUntilLayoutComplete(getPinKeyboard, |
| 49 onPinLoaded); | 45 onLoaded); |
| 50 }); | 46 }); |
| 51 } | 47 } |
| 52 | 48 |
| 53 cr.define('cr.ui.Oobe', function() { | 49 cr.define('cr.ui.Oobe', function() { |
| 54 return { | 50 return { |
| 55 /** | 51 /** |
| 56 * Initializes the OOBE flow. This will cause all C++ handlers to | 52 * Initializes the OOBE flow. This will cause all C++ handlers to |
| 57 * be invoked to do final setup. | 53 * be invoked to do final setup. |
| 58 */ | 54 */ |
| 59 initialize: function() { | 55 initialize: function() { |
| 60 cr.ui.login.DisplayManager.initialize(); | 56 cr.ui.login.DisplayManager.initialize(); |
| 61 login.AccountPickerScreen.register(); | 57 login.AccountPickerScreen.register(); |
| 62 | 58 |
| 63 cr.ui.Bubble.decorate($('bubble')); | 59 cr.ui.Bubble.decorate($('bubble')); |
| 64 login.HeaderBar.decorate($('login-header-bar')); | 60 login.HeaderBar.decorate($('login-header-bar')); |
| 65 | 61 |
| 66 chrome.send('screenStateInitialize'); | 62 chrome.send('screenStateInitialize'); |
| 67 }, | 63 }, |
| 68 | 64 |
| 69 /** | 65 /** |
| 70 * Notification from the host that the PIN keyboard will be used in the | 66 * Notification from the host that the PIN keyboard will be used in the |
| 71 * lock session so it should also get preloaded. | 67 * lock session so it should also get preloaded. |
| 72 */ | 68 */ |
| 73 preloadPinKeyboard: function() { | 69 preloadPinKeyboard: function() { |
| 74 showPinKeyboardAsync(); | 70 ensurePinKeyboardLoaded(function() {}); |
| 75 }, | 71 }, |
| 76 | 72 |
| 77 // Dummy Oobe functions not present with stripped login UI. | 73 // Dummy Oobe functions not present with stripped login UI. |
| 78 initializeA11yMenu: function(e) {}, | 74 initializeA11yMenu: function(e) {}, |
| 79 handleAccessibilityLinkClick: function(e) {}, | 75 handleAccessibilityLinkClick: function(e) {}, |
| 80 handleSpokenFeedbackClick: function(e) {}, | 76 handleSpokenFeedbackClick: function(e) {}, |
| 81 handleHighContrastClick: function(e) {}, | 77 handleHighContrastClick: function(e) {}, |
| 82 handleScreenMagnifierClick: function(e) {}, | 78 handleScreenMagnifierClick: function(e) {}, |
| 83 setUsageStats: function(checked) {}, | 79 setUsageStats: function(checked) {}, |
| 84 setOemEulaUrl: function(oemEulaUrl) {}, | 80 setOemEulaUrl: function(oemEulaUrl) {}, |
| 85 setTpmPassword: function(password) {}, | 81 setTpmPassword: function(password) {}, |
| 86 refreshA11yInfo: function(data) {}, | 82 refreshA11yInfo: function(data) {}, |
| 87 | 83 |
| 88 /** | 84 /** |
| 89 * Reloads content of the page. | 85 * Reloads content of the page. |
| 90 * @param {!Object} data New dictionary with i18n values. | 86 * @param {!Object} data New dictionary with i18n values. |
| 91 */ | 87 */ |
| 92 reloadContent: function(data) { | 88 reloadContent: function(data) { |
| 93 loadTimeData.overrideValues(data); | 89 loadTimeData.overrideValues(data); |
| 94 i18nTemplate.process(document, loadTimeData); | 90 i18nTemplate.process(document, loadTimeData); |
| 95 Oobe.getInstance().updateLocalizedContent_(); | 91 Oobe.getInstance().updateLocalizedContent_(); |
| 96 }, | 92 }, |
| 97 }; | 93 }; |
| 98 }); | 94 }); |
| OLD | NEW |