OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 /** |
| 6 * Creates and returns a node (with |text| as content) assigning it the |
| 7 * |className| class. |
| 8 */ |
| 9 function createSpanWithTextAndClass(text, className) { |
| 10 var node = createElementWithClassName('span', className); |
| 11 node.textContent = text; |
| 12 return node; |
| 13 } |
| 14 |
| 15 /** |
| 16 * Callback from the backend with the information of a WebAPK to display. |
| 17 * This will be called once for each WebAPK available on the device and each |
| 18 * one will be appended at the end of the other. |
| 19 * |
| 20 * @param webApkList List of objects with information about WebAPKs installed. |
| 21 */ |
| 22 function returnWebApksInfo(webApkList) { |
| 23 for (const i in webApkList) { |
| 24 addWebApk(webApkList[i]); |
| 25 } |
| 26 } |
| 27 |
| 28 /** |
| 29 * Adds a new entry to the page with the information of a WebAPK. |
| 30 * |
| 31 * @param webApkInfo Information about an installed WebAPK. |
| 32 */ |
| 33 function addWebApk(webApkInfo) { |
| 34 var webApkList = $('webapks-list'); |
| 35 |
| 36 webApkList.appendChild( |
| 37 createSpanWithTextAndClass(webApkInfo.shortName, 'app-name')); |
| 38 |
| 39 webApkList.appendChild( |
| 40 createSpanWithTextAndClass('Package name: ', 'app-property-label')); |
| 41 webApkList.appendChild(document.createTextNode(webApkInfo.packageName)); |
| 42 |
| 43 webApkList.appendChild(document.createElement('br')); |
| 44 webApkList.appendChild(createSpanWithTextAndClass( |
| 45 'Shell APK version: ', 'app-property-label')); |
| 46 webApkList.appendChild(document.createTextNode(webApkInfo.shellApkVersion)); |
| 47 |
| 48 webApkList.appendChild(document.createElement('br')); |
| 49 webApkList.appendChild( |
| 50 createSpanWithTextAndClass('Version code: ', 'app-property-label')); |
| 51 webApkList.appendChild(document.createTextNode(webApkInfo.versionCode)); |
| 52 } |
| 53 |
| 54 document.addEventListener('DOMContentLoaded', function() { |
| 55 chrome.send('requestWebApksInfo'); |
| 56 }); |
OLD | NEW |