Chromium Code Reviews| Index: components/webapks_ui/resources/about_webapks.js |
| diff --git a/components/webapks_ui/resources/about_webapks.js b/components/webapks_ui/resources/about_webapks.js |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..6e49b6eb14cfc8ca7e6400493317da8f7ec3be94 |
| --- /dev/null |
| +++ b/components/webapks_ui/resources/about_webapks.js |
| @@ -0,0 +1,55 @@ |
| +// Copyright (c) 2017 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +/** |
| + * Creates and returns a node (with |text| as content) assigning it the |
| + * |className| class. |
| + */ |
| +function createTextElementWithClassName(text, className) { |
|
Dan Beam
2017/01/24 18:41:50
createSpanWithTextAndClass?
gonzalon
2017/01/24 20:43:29
Done.
|
| + var node = createElementWithClassName('span', className); |
| + node.textContent = text; |
| + return node; |
| +} |
| + |
| +/** |
| + * Callback from the backend with the information of a WebAPK to display. |
| + * This will be called once for each WebAPK available on the device and each |
| + * one will be appended at the end of the other. |
|
Dan Beam
2017/01/24 18:41:50
@param {...some type goes here...} webApksList ...
gonzalon
2017/01/24 20:43:29
Done.
|
| + */ |
| +function returnWebApksInfo(webApksList) { |
|
Dan Beam
2017/01/24 18:41:50
can this just be webApkList?
gonzalon
2017/01/24 20:43:29
Done.
|
| + for (const i in webApksList) { |
| + addWebApk(webApksList[i]); |
| + } |
| +} |
| + |
|
Dan Beam
2017/01/24 18:41:50
@param for webApkInfo
gonzalon
2017/01/24 20:43:29
Done.
|
| +function addWebApk(webApkInfo) { |
| + var webApksList = $('webapks-list'); |
| + |
| + webApksList.appendChild(document.createElement('br')); |
| + webApksList.appendChild(document.createElement('br')); |
|
Dan Beam
2017/01/24 18:41:50
don't use br
gonzalon
2017/01/24 20:43:29
Done.
|
| + webApksList.appendChild( |
| + createTextElementWithClassName(webApkInfo.shortName, 'app-name')); |
| + |
| + webApksList.appendChild(document.createElement('br')); |
| + webApksList.appendChild( |
| + createTextElementWithClassName('Package name: ', 'app-property-label')); |
| + webApksList.appendChild(document.createTextNode(webApkInfo.packageName)); |
| + |
| + webApksList.appendChild(document.createElement('br')); |
| + webApksList.appendChild(createTextElementWithClassName( |
| + 'Shell APK version: ', 'app-property-label')); |
| + webApksList.appendChild(document.createTextNode(webApkInfo.shellApkVersion)); |
| + |
| + webApksList.appendChild(document.createElement('br')); |
| + webApksList.appendChild( |
| + createTextElementWithClassName('Version code: ', 'app-property-label')); |
| + webApksList.appendChild(document.createTextNode(webApkInfo.versionCode)); |
| +} |
| + |
| +/* All the work we do onload. */ |
| +function onLoadWork() { |
| + chrome.send('requestWebApksInfo'); |
| +} |
| + |
| +document.addEventListener('DOMContentLoaded', onLoadWork); |
|
Dan Beam
2017/01/24 18:41:50
can we just inline this function?
document.addEve
gonzalon
2017/01/24 20:43:29
Done.
|