Commit e73df51a authored by dpapad's avatar dpapad Committed by Commit Bot

Remove HTML Imports from chrome://webapks.

Use JS modules instead, since HTML Imports are being removed.

Replace CallJavascriptFunction() with FireWebUIListener(), since within
a JS module context, all variables/functions are private (unlike previous
behavior of being global), and can't be called from the outside

Bug: 937747
Test: Visit chrome://webapks, should no longer see HTML import warnings in DevTools.
Change-Id: I4319d6b78a9a4c370a2f9152e7448e7c3325adf4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1850271
Auto-Submit: Demetrios Papadopoulos <dpapad@chromium.org>
Reviewed-by: default avatarCalder Kitagawa <ckitagawa@chromium.org>
Reviewed-by: default avatarRebekah Potter <rbpotter@chromium.org>
Commit-Queue: Demetrios Papadopoulos <dpapad@chromium.org>
Cr-Commit-Position: refs/heads/master@{#705203}
parent 718aa02d
......@@ -12,9 +12,8 @@ js_type_check("closure_compile") {
js_library("about_webapks") {
deps = [
"//ui/webui/resources/js:cr",
"//ui/webui/resources/js:load_time_data",
"//ui/webui/resources/js:util",
"//ui/webui/resources/js:cr.m",
"//ui/webui/resources/js:util.m",
]
externs_list = [ "$externs_path/chrome_send.js" ]
}
......@@ -11,12 +11,8 @@ about:webapks template page
<title>About WebAPKs</title>
<link rel="stylesheet" href="chrome://resources/css/text_defaults.css">
<link rel="stylesheet" href="about_webapks.css">
<link rel="import" href="chrome://resources/html/cr.html">
<link rel="import" href="chrome://resources/html/load_time_data.html">
<link rel="import" href="chrome://resources/html/util.html">
<script src="chrome://webapks/webapks.js"></script>
<script src="chrome://webapks/strings.js"></script>
<script type="module" src="webapks.js"></script>
</head>
<body>
......
......@@ -2,6 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import './strings.m.js';
import {addWebUIListener} from 'chrome://resources/js/cr.m.js';
import {$, createElementWithClassName} from 'chrome://resources/js/util.m.js';
/**
* @typedef {{
* name: string,
......@@ -53,17 +58,6 @@ function createElementWithTextAndClass(text, type, className) {
return element;
}
/**
* Callback from the backend with the information of a WebAPK to display.
* This will be called once per WebAPK.
*
* @param {!WebApkInfo} webApkInfo Object with information about an
* installed WebAPK.
*/
function returnWebApkInfo(webApkInfo) {
addWebApk(webApkInfo);
}
/**
* @param {HTMLElement} webApkList List of elements which contain WebAPK
* attributes.
......@@ -96,7 +90,7 @@ function addWebApkButton(webApkList, text, callback) {
/**
* Adds a new entry to the page with the information of a WebAPK.
*
* @param {WebApkInfo} webApkInfo Information about an installed WebAPK.
* @param {!WebApkInfo} webApkInfo Information about an installed WebAPK.
*/
function addWebApk(webApkInfo) {
/** @type {HTMLElement} */ const webApkList = $('webapk-list');
......@@ -160,5 +154,8 @@ function addWebApk(webApkInfo) {
}
document.addEventListener('DOMContentLoaded', function() {
// Add a WebUI listener for the 'web-apk-info' event emmitted from the
// backend. This will be triggered once per WebAPK.
addWebUIListener('web-apk-info', addWebApk);
chrome.send('requestWebApksInfo');
});
......@@ -78,5 +78,5 @@ void WebApksHandler::OnWebApkInfoRetrieved(const WebApkInfo& webapk_info) {
webapk_info.is_backing_browser
? webapk_info.update_status
: "Current browser doesn't own this WebAPK.");
CallJavascriptFunction("returnWebApkInfo", result);
FireWebUIListener("web-apk-info", result);
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment