| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 Out of the box experience flow (OOBE). | 6 * @fileoverview Out of the box experience flow (OOBE). |
| 7 * This is the main code for the OOBE WebUI implementation. | 7 * This is the main code for the OOBE WebUI implementation. |
| 8 */ | 8 */ |
| 9 | 9 |
| 10 <include src="login_shared.js"> | 10 <include src="login_shared.js"> |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 cr.define('cr.ui.Oobe', function() { | 21 cr.define('cr.ui.Oobe', function() { |
| 22 return { | 22 return { |
| 23 /** | 23 /** |
| 24 * Setups given "select" element using the list and adds callback. | 24 * Setups given "select" element using the list and adds callback. |
| 25 * Creates option groups if needed. | 25 * Creates option groups if needed. |
| 26 * @param {!Element} select Select object to be updated. | 26 * @param {!Element} select Select object to be updated. |
| 27 * @param {!Object} list List of the options to be added. | 27 * @param {!Object} list List of the options to be added. |
| 28 * Elements with optionGroupName are considered option group. | 28 * Elements with optionGroupName are considered option group. |
| 29 * @param {string} callback Callback name which should be send to Chrome or | 29 * @param {string} callback Callback name which should be send to Chrome or |
| 30 * an empty string if the event listener shouldn't be added. | 30 * an empty string if the event listener shouldn't be added. |
| 31 * |
| 32 * Note: do not forget to update getSelectedTitle() below if this is |
| 33 * updated! |
| 31 */ | 34 */ |
| 32 setupSelect: function(select, list, callback) { | 35 setupSelect: function(select, list, callback) { |
| 33 select.innerHTML = ''; | 36 select.innerHTML = ''; |
| 34 var optgroup = select; | 37 var optgroup = select; |
| 35 for (var i = 0; i < list.length; ++i) { | 38 for (var i = 0; i < list.length; ++i) { |
| 36 var item = list[i]; | 39 var item = list[i]; |
| 37 if (item.optionGroupName) { | 40 if (item.optionGroupName) { |
| 38 optgroup = document.createElement('optgroup'); | 41 optgroup = document.createElement('optgroup'); |
| 39 optgroup.label = item.optionGroupName; | 42 optgroup.label = item.optionGroupName; |
| 40 select.appendChild(optgroup); | 43 select.appendChild(optgroup); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 56 13, // Enter | 59 13, // Enter |
| 57 27, // Escape | 60 27, // Escape |
| 58 ]; | 61 ]; |
| 59 if (keycodeInterested.indexOf(event.keyCode) >= 0) | 62 if (keycodeInterested.indexOf(event.keyCode) >= 0) |
| 60 runCallback(); | 63 runCallback(); |
| 61 }); | 64 }); |
| 62 } | 65 } |
| 63 }, | 66 }, |
| 64 | 67 |
| 65 /** | 68 /** |
| 69 * Returns title of the selected option (see setupSelect() above). |
| 70 * @param {!Object} list The same as in setupSelect() above. |
| 71 */ |
| 72 getSelectedTitle: function(list) { |
| 73 var firstTitle = ''; |
| 74 for (var i = 0; i < list.length; ++i) { |
| 75 var item = list[i]; |
| 76 if (item.optionGroupName) |
| 77 continue; |
| 78 |
| 79 if (!firstTitle) |
| 80 firstTitle = item.title; |
| 81 |
| 82 if (item.selected) |
| 83 return item.title; |
| 84 } |
| 85 return firstTitle; |
| 86 }, |
| 87 |
| 88 /** |
| 66 * Initializes the OOBE flow. This will cause all C++ handlers to | 89 * Initializes the OOBE flow. This will cause all C++ handlers to |
| 67 * be invoked to do final setup. | 90 * be invoked to do final setup. |
| 68 */ | 91 */ |
| 69 initialize: function() { | 92 initialize: function() { |
| 70 cr.ui.login.DisplayManager.initialize(); | 93 cr.ui.login.DisplayManager.initialize(); |
| 71 login.HIDDetectionScreen.register(); | 94 login.HIDDetectionScreen.register(); |
| 72 login.WrongHWIDScreen.register(); | 95 login.WrongHWIDScreen.register(); |
| 73 login.NetworkScreen.register(); | 96 login.NetworkScreen.register(); |
| 74 login.EulaScreen.register(); | 97 login.EulaScreen.register(); |
| 75 login.UpdateScreen.register(); | 98 login.UpdateScreen.register(); |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 reloadContent: function(data) { | 297 reloadContent: function(data) { |
| 275 // Reload global local strings, process DOM tree again. | 298 // Reload global local strings, process DOM tree again. |
| 276 loadTimeData.overrideValues(data); | 299 loadTimeData.overrideValues(data); |
| 277 i18nTemplate.process(document, loadTimeData); | 300 i18nTemplate.process(document, loadTimeData); |
| 278 | 301 |
| 279 // Update language and input method menu lists. | 302 // Update language and input method menu lists. |
| 280 Oobe.setupSelect($('language-select'), data.languageList); | 303 Oobe.setupSelect($('language-select'), data.languageList); |
| 281 Oobe.setupSelect($('keyboard-select'), data.inputMethodsList); | 304 Oobe.setupSelect($('keyboard-select'), data.inputMethodsList); |
| 282 Oobe.setupSelect($('timezone-select'), data.timezoneList); | 305 Oobe.setupSelect($('timezone-select'), data.timezoneList); |
| 283 | 306 |
| 307 // ---------- Welcome screen |
| 308 $('oobe-welcome-md').currentLanguage = |
| 309 Oobe.getSelectedTitle(data.languageList); |
| 310 |
| 311 if (data.newOobeUI == 'on') { |
| 312 $('oobe-connect').hidden = true; |
| 313 $('oobe-welcome-md').hidden = false; |
| 314 } else { |
| 315 $('oobe-connect').hidden = false; |
| 316 $('oobe-welcome-md').hidden = true; |
| 317 } |
| 318 // ---------- |
| 319 |
| 284 // Update localized content of the screens. | 320 // Update localized content of the screens. |
| 285 Oobe.updateLocalizedContent(); | 321 Oobe.updateLocalizedContent(); |
| 286 }, | 322 }, |
| 287 | 323 |
| 288 /** | 324 /** |
| 289 * Updates localized content of the screens. | 325 * Updates localized content of the screens. |
| 290 * Should be executed on language change. | 326 * Should be executed on language change. |
| 291 */ | 327 */ |
| 292 updateLocalizedContent: function() { | 328 updateLocalizedContent: function() { |
| 293 // Buttons, headers and links. | 329 // Buttons, headers and links. |
| 294 Oobe.getInstance().updateLocalizedContent_(); | 330 Oobe.getInstance().updateLocalizedContent_(); |
| 295 } | 331 } |
| 296 }; | 332 }; |
| 297 }); | 333 }); |
| OLD | NEW |