Chromium Code Reviews| Index: components/version_ui/resources/about_version.js |
| diff --git a/components/version_ui/resources/about_version.js b/components/version_ui/resources/about_version.js |
| index c335b6360cd8f58fdfb33b187ceea223db923bc0..05b187e3078ed5233d63a2f847a12a20f4ade3c7 100644 |
| --- a/components/version_ui/resources/about_version.js |
| +++ b/components/version_ui/resources/about_version.js |
| @@ -2,58 +2,62 @@ |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| -/** |
| - * Callback from the backend with the list of variations to display. |
| - * This call will build the variations section of the version page, or hide that |
| - * section if there are none to display. |
| - * @param {!Array<string>} variationsList The list of variations. |
| - */ |
| -function returnVariationInfo(variationsList) { |
| - $('variations-section').hidden = !variationsList.length; |
| - $('variations-list').appendChild( |
| - parseHtmlSubset(variationsList.join('<br>'), ['BR'])); |
| -} |
| - |
| -/** |
| - * Callback from the backend with the executable and profile paths to display. |
| - * @param {string} execPath The executable path to display. |
| - * @param {string} profilePath The profile path to display. |
| - */ |
| -function returnFilePaths(execPath, profilePath) { |
| - $('executable_path').textContent = execPath; |
| - $('profile_path').textContent = profilePath; |
| -} |
| - |
| -/** |
| - * Callback from the backend with the Flash version to display. |
| - * @param {string} flashVersion The Flash version to display. |
| - */ |
| -function returnFlashVersion(flashVersion) { |
| - $('flash_version').textContent = flashVersion; |
| -} |
| - |
| -/** |
| - * Callback from the backend with the OS version to display. |
| - * @param {string} osVersion The OS version to display. |
| - */ |
| -function returnOsVersion(osVersion) { |
| - $('os_version').textContent = osVersion; |
| +/** @return {!Promise} */ |
| +function getUiHandler() { |
| + return new Promise(function(resolve, reject) { |
| + define([ |
|
Eugene But (OOO till 7-30)
2016/06/02 22:23:12
define('main', [
Otherwise this does not work on
|
| + 'mojo/public/js/connection', |
| + 'chrome/browser/ui/webui/version.mojom', |
| + 'content/public/renderer/frame_service_registry', |
| + ], function(connection, versionMojom, serviceRegistry) { |
| + var uiHandler = connection.bindHandleToProxy( |
| + serviceRegistry.connectToService( |
| + versionMojom.VersionPageHandler.name), |
| + versionMojom.VersionPageHandler); |
| + resolve(uiHandler); |
| + }); |
| + }); |
| } |
| - |
| /** |
| - * Callback from the backend with the ARC version to display. |
| - * @param {string} arcVersion The ARC version to display. |
| + * @return {!Promise} Fires when DOMContentLoaded event is received. |
| */ |
| -function returnARCVersion(arcVersion) { |
| - $('arc_version').textContent = arcVersion; |
| - $('arc_holder').hidden = !arcVersion; |
| +function whenDomContentLoaded() { |
| + return new Promise(function(resolve, reject) { |
| + document.addEventListener('DOMContentLoaded', resolve); |
| + }); |
| } |
| -/* All the work we do onload. */ |
| -function onLoadWork() { |
| - chrome.send('requestVersionInfo'); |
| - $('arc_holder').hidden = true; |
| +function main() { |
| + Promise.all([ |
| + whenDomContentLoaded(), getUiHandler() |
| + ]).then(function(results) { |
| + var uiHandler = results[1]; |
| + uiHandler.getFilePaths().then(function(response) { |
|
Eugene But (OOO till 7-30)
2016/06/04 01:15:25
This should not be called for iOS
|
| + $('executable_path').textContent = response.execPath; |
| + $('profile_path').textContent = response.profilePath; |
| + }); |
| + uiHandler.getVariations().then(function(response) { |
| + $('variations-section').hidden = response.variations.length == 0; |
| + $('variations-list').appendChild( |
| + parseHtmlSubset(response.variations.join('<br>'), ['BR'])); |
| + }); |
| + |
| + if (!cr.isAndroid) { |
|
Eugene But (OOO till 7-30)
2016/06/04 01:15:25
ditto
|
| + uiHandler.getFlashVersion().then(function(response) { |
| + $('flash_version').textContent = response.flashVersion; |
| + }); |
| + } |
| + |
| + if (cr.isChromeOS) { |
| + uiHandler.getOsVersion().then(function(response) { |
| + $('os_version').textContent = response.osVersion; |
| + }); |
| + uiHandler.getArcVersion().then(function(response) { |
| + $('arc_version').textContent = response.arcVersion; |
| + $('arc_holder').hidden = !response.arcVersion; |
| + }); |
| + } |
| + }); |
| } |
| - |
| -document.addEventListener('DOMContentLoaded', onLoadWork); |
| +main(); |