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

Unified Diff: chrome/browser/resources/webapks/about_webapks.js

Issue 2629573004: Add a chrome://webapks page. (Closed)
Patch Set: Add a chrome://webapks page. Created 3 years, 10 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: 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..ae929d6ed4c1a2b5e4d0cf3ad78bc26693bde1e3
--- /dev/null
+++ b/chrome/browser/resources/webapks/about_webapks.js
@@ -0,0 +1,71 @@
+// 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.
+
+/**
+ * @typedef {{
+ * shortName: string,
+ * packageName: string,
+ * shellApkVersion: number,
+ * versionCode: number
+ * }}
+ */
+var WebApkInfo;
+
+/**
+ * Creates and returns an element (with |text| as content) assigning it the
+ * |className| class.
+ *
+ * @param {string} text Text to be shown in the span.
+ * @param {string} className Class to be assigned to the new element.
+ * @return {Element} The created element.
+ */
+function createSpanWithTextAndClass(text, className) {
+ var element = createElementWithClassName('span', className);
+ element.textContent = text;
+ return element;
+}
+
+/**
+ * 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 {!Array<WebApkInfo>} webApkList List of objects with information about
+ * WebAPKs installed.
+ */
+function returnWebApksInfo(webApkList) {
+ for (let webApkInfo of webApkList) {
+ addWebApk(webApkInfo);
+ }
+}
+
+/**
+ * Adds a new entry to the page with the information of a WebAPK.
+ *
+ * @param {WebApkInfo} webApkInfo Information about an installed WebAPK.
+ */
+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');
+});
« no previous file with comments | « chrome/browser/resources/webapks/about_webapks.html ('k') | chrome/browser/resources/webapks/compiled_resources2.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698