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() { ...@@ -97,6 +97,13 @@ base::flat_map<SystemAppType, SystemAppInfo> CreateSystemWebApps() {
infos.emplace(SystemAppType::MEDIA, infos.emplace(SystemAppType::MEDIA,
SystemAppInfo("Media", GURL("chrome://media-app/pwa.html"))); 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 #endif // OS_CHROMEOS
return infos; return infos;
...@@ -150,6 +157,11 @@ bool SystemWebAppManager::IsAppEnabled(SystemAppType type) { ...@@ -150,6 +157,11 @@ bool SystemWebAppManager::IsAppEnabled(SystemAppType type) {
return base::FeatureList::IsEnabled(chromeos::features::kMediaApp); return base::FeatureList::IsEnabled(chromeos::features::kMediaApp);
case SystemAppType::HELP: case SystemAppType::HELP:
return base::FeatureList::IsEnabled(chromeos::features::kHelpAppV2); return base::FeatureList::IsEnabled(chromeos::features::kHelpAppV2);
#if !defined(OFFICIAL_BUILD)
case SystemAppType::SAMPLE:
NOTREACHED();
return false;
#endif // !defined(OFFICIAL_BUILD)
} }
#else #else
return false; return false;
......
...@@ -43,6 +43,9 @@ enum class SystemAppType { ...@@ -43,6 +43,9 @@ enum class SystemAppType {
TERMINAL, TERMINAL,
MEDIA, MEDIA,
HELP, HELP,
#if !defined(OFFICIAL_BUILD)
SAMPLE,
#endif // !defined(OFFICIAL_BUILD)
}; };
// The configuration options for a System App. // The configuration options for a System App.
......
...@@ -2444,6 +2444,9 @@ if (!is_android) { ...@@ -2444,6 +2444,9 @@ if (!is_android) {
"base/interactive_test_utils_aura.h", "base/interactive_test_utils_aura.h",
"base/interactive_test_utils_views.cc", "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) { if (use_cups) {
sources += sources +=
[ "../browser/chromeos/extensions/printing/printing_apitest.cc" ] [ "../browser/chromeos/extensions/printing/printing_apitest.cc" ]
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
found in the LICENSE file. --> found in the LICENSE file. -->
<!DOCTYPE html> <!DOCTYPE html>
<meta charset="utf-8"> <meta charset="utf-8">
<title>Sample System App</title> <title>Sample System Web App</title>
<h1 id="header">Sample System Web App</h1> <h1 id="header">Sample System Web App</h1>
<!-- Below mojo script required to run browser tests --> <!-- Below mojo script required to run browser tests -->
<script src="chrome://resources/mojo/mojo/public/js/mojo_bindings_lite.js"></script> <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 @@ ...@@ -15,7 +15,10 @@
<!-- Privileged app host contents. --> <!-- Privileged app host contents. -->
<if expr="is_official_build == false"> <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_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_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> </if>
</includes> </includes>
</release> </release>
......
...@@ -20,7 +20,12 @@ SampleSystemWebAppUI::SampleSystemWebAppUI(content::WebUI* web_ui) ...@@ -20,7 +20,12 @@ SampleSystemWebAppUI::SampleSystemWebAppUI(content::WebUI* web_ui)
content::WebUIDataSource::Create(kChromeUISampleSystemWebAppHost)); content::WebUIDataSource::Create(kChromeUISampleSystemWebAppHost));
html_source->AddResourcePath("", IDR_SAMPLE_SYSTEM_WEB_APP_INDEX_HTML); 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("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 !DCHECK_IS_ON()
// If a user goes to an invalid url and non-DCHECK mode (DHECK = debug mode) // If a user goes to an invalid url and non-DCHECK mode (DHECK = debug mode)
...@@ -36,4 +41,4 @@ SampleSystemWebAppUI::SampleSystemWebAppUI(content::WebUI* web_ui) ...@@ -36,4 +41,4 @@ SampleSystemWebAppUI::SampleSystemWebAppUI(content::WebUI* web_ui)
SampleSystemWebAppUI::~SampleSystemWebAppUI() = default; SampleSystemWebAppUI::~SampleSystemWebAppUI() = default;
} // namespace chromeos } // namespace chromeos
\ No newline at end of file
...@@ -7,5 +7,6 @@ ...@@ -7,5 +7,6 @@
namespace chromeos { namespace chromeos {
const char kChromeUISampleSystemWebAppHost[] = "sample-system-web-app"; const char kChromeUISampleSystemWebAppHost[] = "sample-system-web-app";
const char kChromeUISampleSystemWebAppURL[] = "chrome://sample-system-web-app";
} // namespace chromeos } // namespace chromeos
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
namespace chromeos { namespace chromeos {
extern const char kChromeUISampleSystemWebAppHost[]; extern const char kChromeUISampleSystemWebAppHost[];
extern const char kChromeUISampleSystemWebAppURL[];
} // namespace chromeos } // 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