Commit 8043eaf0 authored by Wei Lee's avatar Wei Lee Committed by Commit Bot

[CCA WebUI] Land on init.js rather than main.js when startup

There are many things we want to setup before starting the app (e.g.
Error handling, Test coordination). Therefore, we change to land on
init.js and then dynamically load main.js so that we can load other .js
files only when we finish the essential setup.

Bug: 980846
Test: CCA works normally
Change-Id: I5a0bf0c305a06562a4bde54422459376f9a2321e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2352261
Commit-Queue: Wei Lee <wtlee@chromium.org>
Reviewed-by: default avatarShik Chen <shik@chromium.org>
Auto-Submit: Wei Lee <wtlee@chromium.org>
Cr-Commit-Position: refs/heads/master@{#802124}
parent ed7f883c
...@@ -98,6 +98,7 @@ copy("chrome_camera_app_js") { ...@@ -98,6 +98,7 @@ copy("chrome_camera_app_js") {
"src/js/chrome_util.js", "src/js/chrome_util.js",
"src/js/error.js", "src/js/error.js",
"src/js/gallerybutton.js", "src/js/gallerybutton.js",
"src/js/init.js",
"src/js/intent.js", "src/js/intent.js",
"src/js/main.js", "src/js/main.js",
"src/js/metrics.js", "src/js/metrics.js",
......
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
<structure name="IDR_CAMERA_FILE_UTIL_JS" file="src/js/models/file_util.js" type="chrome_html" /> <structure name="IDR_CAMERA_FILE_UTIL_JS" file="src/js/models/file_util.js" type="chrome_html" />
<structure name="IDR_CAMERA_GALLERYBUTTON_JS" file="src/js/gallerybutton.js" type="chrome_html" /> <structure name="IDR_CAMERA_GALLERYBUTTON_JS" file="src/js/gallerybutton.js" type="chrome_html" />
<structure name="IDR_CAMERA_IMAGECAPTURE_JS" file="src/js/mojo/image_capture.js" type="chrome_html" /> <structure name="IDR_CAMERA_IMAGECAPTURE_JS" file="src/js/mojo/image_capture.js" type="chrome_html" />
<structure name="IDR_CAMERA_INIT_JS" file="src/js/init.js" type="chrome_html" />
<structure name="IDR_CAMERA_INTENT_JS" file="src/js/intent.js" type="chrome_html" /> <structure name="IDR_CAMERA_INTENT_JS" file="src/js/intent.js" type="chrome_html" />
<structure name="IDR_CAMERA_LAYOUT_JS" file="src/js/views/camera/layout.js" type="chrome_html" /> <structure name="IDR_CAMERA_LAYOUT_JS" file="src/js/views/camera/layout.js" type="chrome_html" />
<structure name="IDR_CAMERA_MAIN_CSS" file="src/css/main.css" type="chrome_html" /> <structure name="IDR_CAMERA_MAIN_CSS" file="src/css/main.css" type="chrome_html" />
......
...@@ -29,6 +29,7 @@ js_library("compile_resources") { ...@@ -29,6 +29,7 @@ js_library("compile_resources") {
"device/device_info_updater.js", "device/device_info_updater.js",
"error.js", "error.js",
"gallerybutton.js", "gallerybutton.js",
"init.js",
"intent.js", "intent.js",
"lib/comlink.js", "lib/comlink.js",
"lib/ffmpeg.js", "lib/ffmpeg.js",
......
// Copyright (c) 2020 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.
document.addEventListener('DOMContentLoaded', () => {
const mainScript = document.createElement('script');
mainScript.setAttribute('type', 'module');
mainScript.setAttribute('src', '../js/main.js');
document.head.appendChild(mainScript);
});
...@@ -261,7 +261,7 @@ let instance = null; ...@@ -261,7 +261,7 @@ let instance = null;
/** /**
* Creates the App object and starts camera stream. * Creates the App object and starts camera stream.
*/ */
document.addEventListener('DOMContentLoaded', async () => { (async () => {
if (instance !== null) { if (instance !== null) {
return; return;
} }
...@@ -319,4 +319,4 @@ document.addEventListener('DOMContentLoaded', async () => { ...@@ -319,4 +319,4 @@ document.addEventListener('DOMContentLoaded', async () => {
instance = new App( instance = new App(
/** @type {!BackgroundOps} */ (bgOps)); /** @type {!BackgroundOps} */ (bgOps));
await instance.start(); await instance.start();
}); })();
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
<script src="../js/mojo/camera_intent.mojom-lite.js"></script> <script src="../js/mojo/camera_intent.mojom-lite.js"></script>
<script src="../js/mojo/camera_app.mojom-lite.js"></script> <script src="../js/mojo/camera_app.mojom-lite.js"></script>
<script src="../js/mojo/camera_app_helper.mojom-lite.js"></script> <script src="../js/mojo/camera_app_helper.mojom-lite.js"></script>
<script type="module" src="../js/main.js"></script> <script type="module" src="../js/init.js"></script>
</head> </head>
<body class="sound mirror mic _3x3"> <body class="sound mirror mic _3x3">
<div id="view-camera"> <div id="view-camera">
......
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