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

Unified Diff: components/webapks_ui/resources/about_webapks.js

Issue 2629573004: Add a chrome://webapks page. (Closed)
Patch Set: Makes the listWebApks method receive a callback on the Java side 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: 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..05e1fc2d7cf78ce5ba074cf2b11c5a40e8201d50
--- /dev/null
+++ b/components/webapks_ui/resources/about_webapks.js
@@ -0,0 +1,56 @@
+// 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) {
+ var node = document.createElement('span');
pkotwicz 2017/01/18 02:08:21 You should use createElementWithClassName() to mak
pkotwicz 2017/01/19 19:37:16 ^^^ I think that you missed this comment
+ node.textContent = text;
+ node.className = className;
+ 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.
+ */
+function returnWebApksInfo(webApksList) {
+ for (const i in webApksList) {
+ addWebApk(webApksList[i]);
+ }
+}
+
+function addWebApk(webApkInfo) {
+ var webApksList = $('webapks-list');
+
+ webApksList.appendChild(document.createElement("BR"));
pkotwicz 2017/01/18 02:08:21 Nit: It looks like most of the other places in the
pkotwicz 2017/01/19 19:37:16 ^^^ I think that you missed this comment
gonzalon 2017/01/19 23:50:15 Done.
+ webApksList.appendChild(document.createElement("BR"));
+ webApksList.appendChild(
+ createTextElementWithClassName(webApkInfo.shortName, "app-name"));
+
+ webApksList.appendChild(document.createElement("BR"));
+ webApksList.appendChild(createTextElementWithClassName(
+ loadTimeData.getString('packageName'), "app-property-label"));
+ webApksList.appendChild(document.createTextNode(webApkInfo.packageName));
+
+ webApksList.appendChild(document.createElement("BR"));
+ webApksList.appendChild(createTextElementWithClassName(
+ loadTimeData.getString('shellApkVersion'), "app-property-label"));
+ webApksList.appendChild(document.createTextNode(webApkInfo.shellApkVersion));
+
+ webApksList.appendChild(document.createElement("BR"));
+ webApksList.appendChild(createTextElementWithClassName(
+ loadTimeData.getString('versionCode'), "app-property-label"));
+ webApksList.appendChild(document.createTextNode(webApkInfo.versionCode));
+}
+
+/* All the work we do onload. */
+function onLoadWork() {
+ chrome.send('requestWebApksInfo');
+}
+
+document.addEventListener('DOMContentLoaded', onLoadWork);

Powered by Google App Engine
This is Rietveld 408576698