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