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 476311bfae9837eed6419c27409ddf6eab078d8a..2fc47e3ac068026e8f998c98d2e63614af6c65d6 100644 |
| --- a/components/version_ui/resources/about_version.js |
| +++ b/components/version_ui/resources/about_version.js |
| @@ -2,47 +2,57 @@ |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
|
Dan Beam
2015/12/09 21:45:07
nit: remove extra line
dpapad
2015/12/10 01:08:27
Done.
|
| -/** |
| - * 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; |
| +/** @return {!Promise} */ |
| +function getUiHandler() { |
|
Dan Beam
2015/12/09 21:45:07
same question as below as to why this is a method
dpapad
2015/12/10 01:08:27
See answer at the end of this file.
|
| + return new Promise(function(resolve, reject) { |
| + define([ |
| + 'mojo/public/js/connection', |
| + 'chrome/browser/ui/webui/version.mojom', |
| + 'content/public/renderer/service_provider', |
| + ], function(connection, versionMojom, serviceProvider) { |
| + var uiHandler = connection.bindHandleToProxy( |
| + serviceProvider.connectToService( |
| + versionMojom.VersionHandlerMojo.name), |
| + versionMojom.VersionHandlerMojo); |
| + resolve(uiHandler); |
| + }); |
| + }); |
| } |
| -/** |
| - * 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. |
| + * @return {!Promise} Fires when DOMContentLoaded event is received. |
| */ |
| -function returnOsVersion(osVersion) { |
| - $('os_version').textContent = osVersion; |
| +function whenDomContentLoaded() { |
| + return new Promise(function(resolve, reject) { |
| + document.addEventListener('DOMContentLoaded', resolve); |
| + }); |
| } |
|
Dan Beam
2015/12/09 21:45:07
why is this a method when it's only called once?
dpapad
2015/12/10 01:08:27
See answer at the end of this file.
|
| -/* All the work we do onload. */ |
| -function onLoadWork() { |
| - chrome.send('requestVersionInfo'); |
| -} |
| -document.addEventListener('DOMContentLoaded', onLoadWork); |
| +function main() { |
| + Promise.all([ |
| + whenDomContentLoaded(), getUiHandler() |
| + ]).then(function(results) { |
| + var uiHandler = results[1]; |
| + uiHandler.getFilePaths().then(function(response) { |
| + $('executable_path').textContent = response.execPath; |
| + $('profile_path').textContent = response.profilePath; |
| + }); |
| + uiHandler.getFlashVersion().then(function(response) { |
|
Dan Beam
2015/12/09 21:45:07
you're calling this on Android even though flash i
dpapad
2015/12/10 01:08:27
Fixed.
|
| + $('flash_version').textContent = response.flashVersion; |
| + }); |
| + uiHandler.getVariations().then(function(response) { |
| + $('variations-section').hidden = response.variations.length == 0; |
| + $('variations-list').appendChild( |
| + parseHtmlSubset(response.variations.join('<br>'), ['BR'])); |
| + }); |
| + if (cr.isChromeOS) { |
|
Dan Beam
2015/12/09 21:45:07
this is a snapshot of the platforms that use this
dpapad
2015/12/10 01:08:27
I don't think that this should be the precedent fo
|
| + uiHandler.getOsVersion().then(function(response) { |
| + $('os_version').textContent = response.osVersion; |
| + }); |
| + } |
| + }); |
| +} |
| +main(); |
|
Dan Beam
2015/12/09 21:45:07
what's the point of main()? are we trying to be p
dpapad
2015/12/10 01:08:28
The point of this is just readability. It makes it
|