Commit 718eeca2 authored by Wei Lee's avatar Wei Lee Committed by Commit Bot

[CCA WebUI] Install the camera SWA through WebApplicationInfo

This CL replaces pwa.html and manifest.json by CameraSystemWebAppInfo to
reduce the flakiness and slowness of SWA installation.

Bug: 980846, 1085274
Test: Launch CCA (SWA) successfully
Change-Id: I72d350077d8e8a7328572e27a16a97e4863516a7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2422927Reviewed-by: default avatarGiovanni Ortuño Urquidi <ortuno@chromium.org>
Reviewed-by: default avatarShik Chen <shik@chromium.org>
Commit-Queue: Wei Lee <wtlee@chromium.org>
Cr-Commit-Position: refs/heads/master@{#809213}
parent 1fe08e14
......@@ -2674,6 +2674,8 @@ source_set("chromeos") {
"usb/cros_usb_detector.h",
"virtual_machines/virtual_machines_util.cc",
"virtual_machines/virtual_machines_util.h",
"web_applications/camera_system_web_app_info.cc",
"web_applications/camera_system_web_app_info.h",
"web_applications/chrome_camera_app_ui_delegate.cc",
"web_applications/chrome_camera_app_ui_delegate.h",
"web_applications/chrome_help_app_ui_delegate.cc",
......
// Copyright 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.
#include "chrome/browser/chromeos/web_applications/camera_system_web_app_info.h"
#include "chrome/browser/chromeos/web_applications/system_web_app_install_utils.h"
#include "chrome/browser/web_applications/components/web_app_constants.h"
#include "chrome/common/web_application_info.h"
#include "chromeos/components/camera_app_ui/resources.h"
#include "chromeos/components/camera_app_ui/url_constants.h"
#include "ui/base/l10n/l10n_util.h"
std::unique_ptr<WebApplicationInfo> CreateWebAppInfoForCameraSystemWebApp() {
auto info = std::make_unique<WebApplicationInfo>();
info->start_url = GURL(chromeos::kChromeUICameraAppMainURL);
info->scope = GURL(chromeos::kChromeUICameraAppURL);
info->title = l10n_util::GetStringUTF16(IDS_NAME);
web_app::CreateIconInfoForSystemWebApp(
info->start_url,
{
{"camera_app_icons_48.png", 48, IDR_CAMERA_CAMERA_APP_ICONS_48_PNG},
{"camera_app_icons_128.png", 128,
IDR_CAMERA_CAMERA_APP_ICONS_128_PNG},
{"camera_app_icons_192.png", 192,
IDR_CAMERA_CAMERA_APP_ICONS_192_PNG},
},
*info);
info->theme_color = 0xff000000;
info->display_mode = blink::mojom::DisplayMode::kStandalone;
info->open_as_window = true;
return info;
}
// Copyright 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.
#ifndef CHROME_BROWSER_CHROMEOS_WEB_APPLICATIONS_CAMERA_SYSTEM_WEB_APP_INFO_H_
#define CHROME_BROWSER_CHROMEOS_WEB_APPLICATIONS_CAMERA_SYSTEM_WEB_APP_INFO_H_
#include <memory>
struct WebApplicationInfo;
// Return a WebApplicationInfo used to install the app.
std::unique_ptr<WebApplicationInfo> CreateWebAppInfoForCameraSystemWebApp();
#endif // CHROME_BROWSER_CHROMEOS_WEB_APPLICATIONS_CAMERA_SYSTEM_WEB_APP_INFO_H_
......@@ -45,6 +45,7 @@
#include "ash/public/cpp/app_list/internal_app_id_constants.h"
#include "base/values.h"
#include "chrome/browser/chromeos/policy/system_features_disable_list_policy_handler.h"
#include "chrome/browser/chromeos/web_applications/camera_system_web_app_info.h"
#include "chrome/browser/chromeos/web_applications/default_web_app_ids.h"
#include "chrome/browser/chromeos/web_applications/diagnostics_system_web_app_info.h"
#include "chrome/browser/chromeos/web_applications/media_web_app_info.h"
......@@ -111,9 +112,10 @@ base::flat_map<SystemAppType, SystemAppInfo> CreateSystemWebApps() {
}
if (SystemWebAppManager::IsAppEnabled(SystemAppType::CAMERA)) {
infos.emplace(
SystemAppType::CAMERA,
SystemAppInfo("Camera", GURL("chrome://camera-app/pwa.html")));
infos.emplace(SystemAppType::CAMERA,
SystemAppInfo("Camera", GURL("chrome://camera-app"),
base::BindRepeating(
&CreateWebAppInfoForCameraSystemWebApp)));
infos.at(SystemAppType::CAMERA).uninstall_and_replace = {
extension_misc::kCameraAppId};
// We need "FileHandling" to use File Handling API to set launch directory.
......
......@@ -44,7 +44,6 @@
<structure name="IDR_CAMERA_MAIN_CSS" file="src/css/main.css" type="chrome_html" />
<structure name="IDR_CAMERA_MAIN_HTML" file="src/views/main.html" type="chrome_html" />
<structure name="IDR_CAMERA_MAIN_JS" file="src/js/main.js" type="chrome_html" />
<structure name="IDR_CAMERA_MANIFEST" file="manifest.json" type="chrome_html" />
<structure name="IDR_CAMERA_METRICS_JS" file="src/js/metrics.js" type="chrome_html" />
<structure name="IDR_CAMERA_MODE_MODE_BASE_JS" file="src/js/views/camera/mode/mode_base.js" type="chrome_html" />
<structure name="IDR_CAMERA_MODE_INDEX_JS" file="src/js/views/camera/mode/index.js" type="chrome_html" />
......@@ -60,7 +59,6 @@
<structure name="IDR_CAMERA_OPTIONS_JS" file="src/js/views/camera/options.js" type="chrome_html" />
<structure name="IDR_CAMERA_PERF_JS" file="src/js/perf.js" type="chrome_html" />
<structure name="IDR_CAMERA_PREVIEW_JS" file="src/js/views/camera/preview.js" type="chrome_html" />
<structure name="IDR_CAMERA_PWA_HTML" file="pwa.html" type="chrome_html" />
<structure name="IDR_CAMERA_RESULT_SAVER_JS" file="src/js/models/result_saver.js" type="chrome_html" />
<structure name="IDR_CAMERA_REVIEW_RESULT_JS" file="src/js/views/camera/review_result.js" type="chrome_html" />
<structure name="IDR_CAMERA_SETTINGS_JS" file="src/js/views/settings.js" type="chrome_html" />
......
{
"name": "Camera",
"display": "standalone",
"icons": [
{
"src": "src/images/camera_app_icons_192.png",
"sizes": "192x192",
"type": "image/png"
},
{
"src": "src/images/camera_app_icons_128.png",
"sizes": "128x128",
"type": "image/png"
},
{
"src": "src/images/camera_app_icons_48.png",
"sizes": "48x48",
"type": "image/png"
}
],
"start_url": "src/views/main.html",
"theme_color": "#000000"
}
<!-- Copyright 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. -->
<!-- TODO(crbug.com/896575): Delete when manifest URL installs are implemented.
-->
<!DOCTYPE html>
<link rel="manifest" href="manifest.json">
\ No newline at end of file
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