Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(56)

Unified Diff: components/version_ui/resources/about_version.js

Issue 1486403002: Mojo-ifying chrome://version. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: change slashes Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..20730b7cd2fd891cd1b6f84fd2dfd3defe40b86c 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([
+ 'mojo/public/js/connection',
+ 'components/version_ui/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) {
+ $('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) {
+ 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();
« no previous file with comments | « components/version_ui/resources/about_version.html ('k') | components/version_ui/resources/about_version_ios.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698