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

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, 11 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..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');
+});

Powered by Google App Engine
This is Rietveld 408576698