Commit 4de0b24b authored by Christopher Lam's avatar Christopher Lam Committed by Commit Bot

[System PWAs] Add Manifest for Settings.

This CL adds the manifest.json for the Settings System Web App. It also
adds a generic PWA installation page for all System Web Apps to use,
which will be removed when installation directly from manifest URLs is
available.

Bug: 836128
Change-Id: I7cdebe6fde5851a3b90e46e39e3118eda1f2cf19
Reviewed-on: https://chromium-review.googlesource.com/c/1272780
Commit-Queue: calamity <calamity@chromium.org>
Reviewed-by: default avatarDemetrios Papadopoulos <dpapad@chromium.org>
Cr-Commit-Position: refs/heads/master@{#603422}
parent 43bcb486
...@@ -709,6 +709,7 @@ ...@@ -709,6 +709,7 @@
<include name="IDR_MEDIA_ENGAGEMENT_HTML" file="resources\media\media_engagement.html" flattenhtml="true" type="BINDATA" compress="gzip" allowexternalscript="true" /> <include name="IDR_MEDIA_ENGAGEMENT_HTML" file="resources\media\media_engagement.html" flattenhtml="true" type="BINDATA" compress="gzip" allowexternalscript="true" />
<include name="IDR_MEDIA_ENGAGEMENT_JS" file="resources\media\media_engagement.js" flattenhtml="true" type="BINDATA" compress="gzip" /> <include name="IDR_MEDIA_ENGAGEMENT_JS" file="resources\media\media_engagement.js" flattenhtml="true" type="BINDATA" compress="gzip" />
<include name="IDR_MEDIA_ENGAGEMENT_MOJO_JS" file="${root_gen_dir}\chrome\browser\media\media_engagement_score_details.mojom.js" use_base_dir="false" type="BINDATA" compress="gzip" /> <include name="IDR_MEDIA_ENGAGEMENT_MOJO_JS" file="${root_gen_dir}\chrome\browser\media\media_engagement_score_details.mojom.js" use_base_dir="false" type="BINDATA" compress="gzip" />
<include name="IDR_PWA_HTML" file="resources\pwa.html" type="BINDATA" />
<if expr="chromeos"> <if expr="chromeos">
<include name="IDR_SYS_INTERNALS_HTML" file="resources\chromeos\sys_internals\index.html" type="BINDATA" /> <include name="IDR_SYS_INTERNALS_HTML" file="resources\chromeos\sys_internals\index.html" type="BINDATA" />
<include name="IDR_SYS_INTERNALS_CSS" file="resources\chromeos\sys_internals\index.css" type="BINDATA" /> <include name="IDR_SYS_INTERNALS_CSS" file="resources\chromeos\sys_internals\index.css" type="BINDATA" />
......
<!-- TODO(calamity): Remove this once manifest URL installs are implemented. -->
<!-- See https://crbug.com/896575 for details -->
<html>
<head>
<link rel="manifest" href="manifest.json">
</head>
</html>
{
"name": "Settings",
"display": "standalone",
"icons": [
{
"src": "icon-192.png",
"sizes": "192x192",
"type": "image/png"
}
],
"start_url": "/",
"theme_color": "#254FAE"
}
...@@ -34,6 +34,10 @@ ...@@ -34,6 +34,10 @@
<structure name="IDR_SETTINGS_TTS_SUBPAGE_HTML" <structure name="IDR_SETTINGS_TTS_SUBPAGE_HTML"
file="a11y_page/tts_subpage.html" file="a11y_page/tts_subpage.html"
type="chrome_html" /> type="chrome_html" />
<structure name="IDR_MD_SETTINGS_MANIFEST"
file="manifest.json"
type="chrome_html" />
</if> </if>
<structure name="IDR_SETTINGS_ABOUT_PAGE_BROWSER_PROXY_HTML" <structure name="IDR_SETTINGS_ABOUT_PAGE_BROWSER_PROXY_HTML"
file="about_page/about_page_browser_proxy.html" file="about_page/about_page_browser_proxy.html"
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
<include name="IDR_MD_SETTINGS_LAZY_LOAD_VULCANIZED_HTML" file="${root_gen_dir}\chrome\browser\resources\settings\lazy_load.vulcanized.html" use_base_dir="false" flattenhtml="true" allowexternalscript="true" type="BINDATA" compress="gzip" /> <include name="IDR_MD_SETTINGS_LAZY_LOAD_VULCANIZED_HTML" file="${root_gen_dir}\chrome\browser\resources\settings\lazy_load.vulcanized.html" use_base_dir="false" flattenhtml="true" allowexternalscript="true" type="BINDATA" compress="gzip" />
<include name="IDR_MD_SETTINGS_LAZY_LOAD_VULCANIZED_P2_HTML" file="${root_gen_dir}\chrome\browser\resources\settings\lazy_load.vulcanized.p2.html" use_base_dir="false" flattenhtml="true" allowexternalscript="true" type="BINDATA" compress="gzip" /> <include name="IDR_MD_SETTINGS_LAZY_LOAD_VULCANIZED_P2_HTML" file="${root_gen_dir}\chrome\browser\resources\settings\lazy_load.vulcanized.p2.html" use_base_dir="false" flattenhtml="true" allowexternalscript="true" type="BINDATA" compress="gzip" />
<include name="IDR_MD_SETTINGS_LAZY_LOAD_CRISPER_JS" file="${root_gen_dir}\chrome\browser\resources\settings\lazy_load.crisper.js" use_base_dir="false" flattenhtml="true" type="BINDATA" compress="gzip" /> <include name="IDR_MD_SETTINGS_LAZY_LOAD_CRISPER_JS" file="${root_gen_dir}\chrome\browser\resources\settings\lazy_load.crisper.js" use_base_dir="false" flattenhtml="true" type="BINDATA" compress="gzip" />
<include name="IDR_MD_SETTINGS_MANIFEST" file="manifest.json" type="BINDATA" compress="gzip" />
</includes> </includes>
</release> </release>
</grit> </grit>
...@@ -1259,6 +1259,10 @@ jumbo_split_static_library("ui") { ...@@ -1259,6 +1259,10 @@ jumbo_split_static_library("ui") {
deps += [ deps += [
"//chrome/browser/web_applications", "//chrome/browser/web_applications",
# TODO(calamity): Remove once SystemWebAppManager is moved into
# web_applications/.
"//chrome/browser/web_applications/bookmark_apps",
# TODO(loyso): Erase these. crbug.com/877898. # TODO(loyso): Erase these. crbug.com/877898.
"//chrome/browser/web_applications:web_applications_on_extensions", "//chrome/browser/web_applications:web_applications_on_extensions",
"//chrome/browser/web_applications/components", "//chrome/browser/web_applications/components",
......
...@@ -70,6 +70,7 @@ ...@@ -70,6 +70,7 @@
#endif // defined(OS_WIN) || defined(OS_CHROMEOS) #endif // defined(OS_WIN) || defined(OS_CHROMEOS)
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
#include "ash/public/cpp/resources/grit/ash_public_unscaled_resources.h"
#include "ash/public/cpp/stylus_utils.h" #include "ash/public/cpp/stylus_utils.h"
#include "chrome/browser/browser_process.h" #include "chrome/browser/browser_process.h"
#include "chrome/browser/chromeos/arc/arc_util.h" #include "chrome/browser/chromeos/arc/arc_util.h"
...@@ -97,7 +98,9 @@ ...@@ -97,7 +98,9 @@
#include "chrome/browser/ui/webui/settings/chromeos/internet_handler.h" #include "chrome/browser/ui/webui/settings/chromeos/internet_handler.h"
#include "chrome/browser/ui/webui/settings/chromeos/multidevice_handler.h" #include "chrome/browser/ui/webui/settings/chromeos/multidevice_handler.h"
#include "chrome/browser/ui/webui/settings/chromeos/smb_handler.h" #include "chrome/browser/ui/webui/settings/chromeos/smb_handler.h"
#include "chrome/browser/web_applications/bookmark_apps/system_web_app_manager.h"
#include "chrome/common/chrome_switches.h" #include "chrome/common/chrome_switches.h"
#include "chrome/grit/browser_resources.h"
#include "chromeos/account_manager/account_manager.h" #include "chromeos/account_manager/account_manager.h"
#include "chromeos/account_manager/account_manager_factory.h" #include "chromeos/account_manager/account_manager_factory.h"
#include "chromeos/chromeos_features.h" #include "chromeos/chromeos_features.h"
...@@ -374,6 +377,18 @@ MdSettingsUI::MdSettingsUI(content::WebUI* web_ui) ...@@ -374,6 +377,18 @@ MdSettingsUI::MdSettingsUI(content::WebUI* web_ui)
// Add the metrics handler to write uma stats. // Add the metrics handler to write uma stats.
web_ui->AddMessageHandler(std::make_unique<MetricsHandler>()); web_ui->AddMessageHandler(std::make_unique<MetricsHandler>());
#if defined(OS_CHROMEOS)
// Add the System Web App resources for Settings.
if (web_app::SystemWebAppManager::ShouldEnableForProfile(profile)) {
html_source->AddResourcePath("icon-192.png", IDR_SETTINGS_LOGO_192);
html_source->AddResourcePath("pwa.html", IDR_PWA_HTML);
#if BUILDFLAG(OPTIMIZE_WEBUI)
exclude_from_gzip.push_back("icon-192.png");
exclude_from_gzip.push_back("pwa.html");
#endif // BUILDFLAG(OPTIMIZE_WEBUI)
}
#endif // defined (OS_CHROMEOS)
#if BUILDFLAG(OPTIMIZE_WEBUI) #if BUILDFLAG(OPTIMIZE_WEBUI)
const bool use_polymer_2 = const bool use_polymer_2 =
base::FeatureList::IsEnabled(features::kWebUIPolymer2); base::FeatureList::IsEnabled(features::kWebUIPolymer2);
...@@ -388,6 +403,9 @@ MdSettingsUI::MdSettingsUI(content::WebUI* web_ui) ...@@ -388,6 +403,9 @@ MdSettingsUI::MdSettingsUI(content::WebUI* web_ui)
? IDR_MD_SETTINGS_VULCANIZED_P2_HTML ? IDR_MD_SETTINGS_VULCANIZED_P2_HTML
: IDR_MD_SETTINGS_VULCANIZED_HTML); : IDR_MD_SETTINGS_VULCANIZED_HTML);
html_source->UseGzip(exclude_from_gzip); html_source->UseGzip(exclude_from_gzip);
#if defined(OS_CHROMEOS)
html_source->AddResourcePath("manifest.json", IDR_MD_SETTINGS_MANIFEST);
#endif // defined (OS_CHROMEOS)
#else #else
// Add all settings resources. // Add all settings resources.
for (size_t i = 0; i < kSettingsResourcesSize; ++i) { for (size_t i = 0; i < kSettingsResourcesSize; ++i) {
......
...@@ -85,7 +85,8 @@ std::vector<GURL> SystemWebAppManager::CreateSystemWebApps() { ...@@ -85,7 +85,8 @@ std::vector<GURL> SystemWebAppManager::CreateSystemWebApps() {
// TODO(calamity): Split this into per-platform functions. // TODO(calamity): Split this into per-platform functions.
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
urls.emplace_back(chrome::kChromeUIDiscoverURL); urls.emplace_back(chrome::kChromeUIDiscoverURL);
urls.emplace_back(chrome::kChromeUISettingsURL); constexpr char kChromeSettingsPWAURL[] = "chrome://settings/pwa.html";
urls.emplace_back(kChromeSettingsPWAURL);
#endif // OS_CHROMEOS #endif // OS_CHROMEOS
return urls; return urls;
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include "chrome/browser/web_applications/web_app_provider_factory.h" #include "chrome/browser/web_applications/web_app_provider_factory.h"
#include "chrome/common/chrome_features.h" #include "chrome/common/chrome_features.h"
#include "chrome/common/extensions/manifest_handlers/app_theme_color_info.h" #include "chrome/common/extensions/manifest_handlers/app_theme_color_info.h"
#include "chrome/grit/browser_resources.h"
#include "chrome/grit/chrome_unscaled_resources.h" #include "chrome/grit/chrome_unscaled_resources.h"
#include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents.h"
#include "content/public/browser/web_ui.h" #include "content/public/browser/web_ui.h"
...@@ -46,9 +47,6 @@ constexpr char kSystemAppManifestText[] = ...@@ -46,9 +47,6 @@ constexpr char kSystemAppManifestText[] =
"theme_color": "#00FF00" "theme_color": "#00FF00"
})"; })";
constexpr char kSystemAppHTMLText[] =
R"(<html><head><link rel="manifest" href="manifest.json"></head></html>)";
// WebUIController that serves a System PWA. // WebUIController that serves a System PWA.
class TestWebUIController : public content::WebUIController { class TestWebUIController : public content::WebUIController {
public: public:
...@@ -57,20 +55,17 @@ class TestWebUIController : public content::WebUIController { ...@@ -57,20 +55,17 @@ class TestWebUIController : public content::WebUIController {
content::WebUIDataSource* data_source = content::WebUIDataSource* data_source =
content::WebUIDataSource::Create("test-system-app"); content::WebUIDataSource::Create("test-system-app");
data_source->AddResourcePath("icon-256.png", IDR_PRODUCT_LOGO_256); data_source->AddResourcePath("icon-256.png", IDR_PRODUCT_LOGO_256);
data_source->AddResourcePath("pwa.html", IDR_PWA_HTML);
data_source->SetRequestFilter(base::BindRepeating( data_source->SetRequestFilter(base::BindRepeating(
[](const std::string& id, [](const std::string& id,
const content::WebUIDataSource::GotDataCallback& callback) { const content::WebUIDataSource::GotDataCallback& callback) {
scoped_refptr<base::RefCountedString> ref_contents( scoped_refptr<base::RefCountedString> ref_contents(
new base::RefCountedString); new base::RefCountedString);
if (id == "manifest.json") if (id != "manifest.json")
ref_contents->data() = kSystemAppManifestText;
if (id == "pwa.html")
ref_contents->data() = kSystemAppHTMLText;
if (ref_contents->data().empty())
return false; return false;
ref_contents->data() = kSystemAppManifestText;
callback.Run(ref_contents); callback.Run(ref_contents);
return true; return true;
})); }));
......
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