Commit 90cb292a authored by jessing's avatar jessing Committed by Commit Bot

system-web-apps: register sample system web app as a system app.

This is an example of how to register a system web app as a system app.

Bug: 1032810
Change-Id: If1e6c67305a7baeef8467eab6580e86fdf75db8f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1971039
Commit-Queue: Jessica Huang <jessing@google.com>
Reviewed-by: default avatarGiovanni Ortuño Urquidi <ortuno@chromium.org>
Cr-Commit-Position: refs/heads/master@{#726697}
parent 4fbd5d3d
// Copyright 2019 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/system_web_app_integration_test.h"
#include "chrome/browser/web_applications/system_web_app_manager.h"
#include "chromeos/components/sample_system_web_app_ui/url_constants.h"
#include "testing/gtest/include/gtest/gtest.h"
using SampleSystemWebAppIntegrationTest = SystemWebAppIntegrationTest;
// Test that the Sample System Web App installs and launches correctly. Runs
// some spot checks on the manifest.
IN_PROC_BROWSER_TEST_F(SampleSystemWebAppIntegrationTest, SampleSystemWebApp) {
const GURL url(chromeos::kChromeUISampleSystemWebAppURL);
EXPECT_NO_FATAL_FAILURE(ExpectSystemWebAppValid(
web_app::SystemAppType::SAMPLE, url, "Sample System Web App"));
}
......@@ -97,6 +97,13 @@ base::flat_map<SystemAppType, SystemAppInfo> CreateSystemWebApps() {
infos.emplace(SystemAppType::MEDIA,
SystemAppInfo("Media", GURL("chrome://media-app/pwa.html")));
}
#if !defined(OFFICIAL_BUILD)
infos.emplace(
SystemAppType::SAMPLE,
SystemAppInfo("Sample", GURL("chrome://sample-system-web-app/pwa.html")));
#endif // !defined(OFFICIAL_BUILD)
#endif // OS_CHROMEOS
return infos;
......@@ -150,6 +157,11 @@ bool SystemWebAppManager::IsAppEnabled(SystemAppType type) {
return base::FeatureList::IsEnabled(chromeos::features::kMediaApp);
case SystemAppType::HELP:
return base::FeatureList::IsEnabled(chromeos::features::kHelpAppV2);
#if !defined(OFFICIAL_BUILD)
case SystemAppType::SAMPLE:
NOTREACHED();
return false;
#endif // !defined(OFFICIAL_BUILD)
}
#else
return false;
......
......@@ -43,6 +43,9 @@ enum class SystemAppType {
TERMINAL,
MEDIA,
HELP,
#if !defined(OFFICIAL_BUILD)
SAMPLE,
#endif // !defined(OFFICIAL_BUILD)
};
// The configuration options for a System App.
......
......@@ -2444,6 +2444,9 @@ if (!is_android) {
"base/interactive_test_utils_aura.h",
"base/interactive_test_utils_views.cc",
]
if (!is_official_build) {
sources += [ "../browser/chromeos/web_applications/sample_system_web_app_integration_browsertest.cc" ]
}
if (use_cups) {
sources +=
[ "../browser/chromeos/extensions/printing/printing_apitest.cc" ]
......
......@@ -3,7 +3,7 @@
found in the LICENSE file. -->
<!DOCTYPE html>
<meta charset="utf-8">
<title>Sample System App</title>
<title>Sample System Web App</title>
<h1 id="header">Sample System Web App</h1>
<!-- Below mojo script required to run browser tests -->
<script src="chrome://resources/mojo/mojo/public/js/mojo_bindings_lite.js"></script>
{
"name": "Sample System Web App",
"short_name": "Sample App",
"start_url": "/",
"display": "standalone",
"theme_color": "#4285F4",
"background_color": "#ffffff",
"scope": "./",
"icons": [
{
"src": "app_icon_192.png",
"sizes": "192x192",
"type": "image/png"
}
]
}
<!-- Copyright 2019 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/896575): Delete when manifest URL installs are implemented. -->
<!DOCTYPE html>
<link rel="manifest" href="manifest.json">
......@@ -15,7 +15,10 @@
<!-- Privileged app host contents. -->
<if expr="is_official_build == false">
<include name="IDR_SAMPLE_SYSTEM_WEB_APP_INDEX_HTML" file="index.html" type="BINDATA" compress="gzip" />
<include name="IDR_SAMPLE_SYSTEM_WEB_APP_PWA_HTML" file="pwa.html" type="BINDATA" compress="gzip" />
<include name="IDR_SAMPLE_SYSTEM_WEB_APP_JS" file="js/app.js" type="BINDATA" compress="gzip" />
<include name="IDR_SAMPLE_SYSTEM_WEB_APP_MANIFEST" file="manifest.json" type="BINDATA" compress="gzip" />
<include name="IDR_SAMPLE_SYSTEM_WEB_APP_ICON_192" file="app_icon_192.png" type="BINDATA" compress="gzip" />
</if>
</includes>
</release>
......
......@@ -20,7 +20,12 @@ SampleSystemWebAppUI::SampleSystemWebAppUI(content::WebUI* web_ui)
content::WebUIDataSource::Create(kChromeUISampleSystemWebAppHost));
html_source->AddResourcePath("", IDR_SAMPLE_SYSTEM_WEB_APP_INDEX_HTML);
html_source->AddResourcePath("pwa.html", IDR_SAMPLE_SYSTEM_WEB_APP_PWA_HTML);
html_source->AddResourcePath("app.js", IDR_SAMPLE_SYSTEM_WEB_APP_JS);
html_source->AddResourcePath("manifest.json",
IDR_SAMPLE_SYSTEM_WEB_APP_MANIFEST);
html_source->AddResourcePath("app_icon_192.png",
IDR_SAMPLE_SYSTEM_WEB_APP_ICON_192);
#if !DCHECK_IS_ON()
// If a user goes to an invalid url and non-DCHECK mode (DHECK = debug mode)
......
......@@ -7,5 +7,6 @@
namespace chromeos {
const char kChromeUISampleSystemWebAppHost[] = "sample-system-web-app";
const char kChromeUISampleSystemWebAppURL[] = "chrome://sample-system-web-app";
} // namespace chromeos
......@@ -8,6 +8,7 @@
namespace chromeos {
extern const char kChromeUISampleSystemWebAppHost[];
extern const char kChromeUISampleSystemWebAppURL[];
} // namespace chromeos
......
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