Chromium Code Reviews| Index: chrome/browser/resources/webapks/about_webapks.js |
| diff --git a/chrome/browser/resources/webapks/about_webapks.js b/chrome/browser/resources/webapks/about_webapks.js |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..57333d7c2ca60d9647738e4df56e202cdbbff6b7 |
| --- /dev/null |
| +++ b/chrome/browser/resources/webapks/about_webapks.js |
| @@ -0,0 +1,56 @@ |
| +// Copyright 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. |
|
Dan Beam
2017/01/25 23:27:33
@return {HTMLElement}
gonzalon
2017/01/26 17:02:49
Done.
|
| + */ |
| +function createSpanWithTextAndClass(text, className) { |
| + var node = createElementWithClassName('span', className); |
|
Dan Beam
2017/01/25 23:27:33
nit: name this el? Node and Element are different
gonzalon
2017/01/26 17:02:49
Done.
|
| + 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. |
| + * |
| + * @param webApkList List of objects with information about WebAPKs installed. |
|
Dan Beam
2017/01/25 23:27:33
you need a type name in this @param. an example:
gonzalon
2017/01/26 17:02:49
Done.
|
| + */ |
| +function returnWebApksInfo(webApkList) { |
| + for (var i in webApkList) { |
| + addWebApk(webApkList[i]); |
| + } |
| +} |
| + |
| +/** |
| + * Adds a new entry to the page with the information of a WebAPK. |
| + * |
| + * @param webApkInfo Information about an installed WebAPK. |
|
Dan Beam
2017/01/25 23:27:33
@param {WebApkInfo} webApkInfo
gonzalon
2017/01/26 17:02:49
Done.
|
| + */ |
| +function addWebApk(webApkInfo) { |
| + var webApkList = $('webapk-list'); |
| + |
| + webApkList.appendChild( |
| + createSpanWithTextAndClass(webApkInfo.shortName, 'app-name')); |
| + |
| + webApkList.appendChild( |
| + createSpanWithTextAndClass('Package name: ', 'app-property-label')); |
| + webApkList.appendChild(document.createTextNode(webApkInfo.packageName)); |
| + |
| + webApkList.appendChild(document.createElement('br')); |
| + webApkList.appendChild(createSpanWithTextAndClass( |
| + 'Shell APK version: ', 'app-property-label')); |
| + webApkList.appendChild(document.createTextNode(webApkInfo.shellApkVersion)); |
| + |
| + webApkList.appendChild(document.createElement('br')); |
| + webApkList.appendChild( |
| + createSpanWithTextAndClass('Version code: ', 'app-property-label')); |
| + webApkList.appendChild(document.createTextNode(webApkInfo.versionCode)); |
| +} |
| + |
| +document.addEventListener('DOMContentLoaded', function() { |
| + chrome.send('requestWebApksInfo'); |
| +}); |