Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 |
|
Dan Beam
2015/12/09 21:45:07
nit: remove extra line
dpapad
2015/12/10 01:08:27
Done.
| |
| 5 /** | 5 |
| 6 * Callback from the backend with the list of variations to display. | 6 /** @return {!Promise} */ |
| 7 * This call will build the variations section of the version page, or hide that | 7 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.
| |
| 8 * section if there are none to display. | 8 return new Promise(function(resolve, reject) { |
| 9 * @param {!Array<string>} variationsList The list of variations. | 9 define([ |
| 10 */ | 10 'mojo/public/js/connection', |
| 11 function returnVariationInfo(variationsList) { | 11 'chrome/browser/ui/webui/version.mojom', |
| 12 $('variations-section').hidden = !variationsList.length; | 12 'content/public/renderer/service_provider', |
| 13 $('variations-list').appendChild( | 13 ], function(connection, versionMojom, serviceProvider) { |
| 14 parseHtmlSubset(variationsList.join('<br>'), ['BR'])); | 14 var uiHandler = connection.bindHandleToProxy( |
| 15 serviceProvider.connectToService( | |
| 16 versionMojom.VersionHandlerMojo.name), | |
| 17 versionMojom.VersionHandlerMojo); | |
| 18 resolve(uiHandler); | |
| 19 }); | |
| 20 }); | |
| 15 } | 21 } |
| 16 | 22 |
| 23 | |
| 17 /** | 24 /** |
| 18 * Callback from the backend with the executable and profile paths to display. | 25 * @return {!Promise} Fires when DOMContentLoaded event is received. |
| 19 * @param {string} execPath The executable path to display. | |
| 20 * @param {string} profilePath The profile path to display. | |
| 21 */ | 26 */ |
| 22 function returnFilePaths(execPath, profilePath) { | 27 function whenDomContentLoaded() { |
| 23 $('executable_path').textContent = execPath; | 28 return new Promise(function(resolve, reject) { |
| 24 $('profile_path').textContent = profilePath; | 29 document.addEventListener('DOMContentLoaded', resolve); |
| 30 }); | |
| 25 } | 31 } |
|
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.
| |
| 26 | 32 |
| 27 /** | 33 |
| 28 * Callback from the backend with the Flash version to display. | 34 function main() { |
| 29 * @param {string} flashVersion The Flash version to display. | 35 Promise.all([ |
| 30 */ | 36 whenDomContentLoaded(), getUiHandler() |
| 31 function returnFlashVersion(flashVersion) { | 37 ]).then(function(results) { |
| 32 $('flash_version').textContent = flashVersion; | 38 var uiHandler = results[1]; |
| 39 uiHandler.getFilePaths().then(function(response) { | |
| 40 $('executable_path').textContent = response.execPath; | |
| 41 $('profile_path').textContent = response.profilePath; | |
| 42 }); | |
| 43 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.
| |
| 44 $('flash_version').textContent = response.flashVersion; | |
| 45 }); | |
| 46 uiHandler.getVariations().then(function(response) { | |
| 47 $('variations-section').hidden = response.variations.length == 0; | |
| 48 $('variations-list').appendChild( | |
| 49 parseHtmlSubset(response.variations.join('<br>'), ['BR'])); | |
| 50 }); | |
| 51 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
| |
| 52 uiHandler.getOsVersion().then(function(response) { | |
| 53 $('os_version').textContent = response.osVersion; | |
| 54 }); | |
| 55 } | |
| 56 }); | |
| 33 } | 57 } |
| 34 | 58 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
| |
| 35 /** | |
| 36 * Callback from the backend with the OS version to display. | |
| 37 * @param {string} osVersion The OS version to display. | |
| 38 */ | |
| 39 function returnOsVersion(osVersion) { | |
| 40 $('os_version').textContent = osVersion; | |
| 41 } | |
| 42 | |
| 43 /* All the work we do onload. */ | |
| 44 function onLoadWork() { | |
| 45 chrome.send('requestVersionInfo'); | |
| 46 } | |
| 47 | |
| 48 document.addEventListener('DOMContentLoaded', onLoadWork); | |
| OLD | NEW |