Commit 9469a8d3 authored by Rachel Carpenter's avatar Rachel Carpenter Committed by Commit Bot

Gives chrome://help-app a launcher icon.

This is shown in the launcher with --enable-features=HelpAppV2, otherwise existing Get Help app is shown.

Bug: 1012578, b/140960611
Change-Id: I18a56bce24733fa2efa847ad4d2b8db5a7eccc6e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1902174
Commit-Queue: Rachel Carpenter <carpenterr@google.com>
Reviewed-by: default avatarTrent Apted <tapted@chromium.org>
Cr-Commit-Position: refs/heads/master@{#713367}
parent a93ccf4a
......@@ -63,6 +63,7 @@ source_set("web_applications") {
if (is_chromeos) {
deps += [
"//ash/public/cpp:cpp",
"//chromeos/components/help_app_ui",
"//chromeos/components/media_app_ui",
"//chromeos/constants",
"//components/arc:arc_base",
......
......@@ -112,6 +112,7 @@ source_set("browser_tests") {
if (is_chromeos) {
deps += [
"//chromeos/components/help_app_ui",
"//chromeos/components/media_app_ui",
"//chromeos/constants",
]
......
......@@ -12,6 +12,7 @@
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/browser/web_applications/system_web_app_manager.h"
#include "chromeos/components/help_app_ui/url_constants.h"
#include "chromeos/components/media_app_ui/url_constants.h"
#include "chromeos/constants/chromeos_features.h"
#include "content/public/browser/web_ui.h"
......@@ -31,7 +32,47 @@ class SystemWebAppManagerBrowserTestChromeos
public:
SystemWebAppManagerBrowserTestChromeos()
: SystemWebAppManagerBrowserTest(false /* install_mock */) {
scoped_feature_list_.InitAndEnableFeature(chromeos::features::kMediaApp);
scoped_feature_list_.InitWithFeatures(
{chromeos::features::kHelpAppV2, chromeos::features::kMediaApp}, {});
}
// Runs basic tests on a System Web App. E.g. ensures it exists, and
// loads/navigates with an expected title that matches the manifest app name.
void ExpectSystemWebAppValid(SystemAppType app_type,
const GURL& url,
const std::string& title) {
Browser* app_browser = WaitForSystemAppInstallAndLaunch(app_type);
const extensions::Extension* installed_app =
extensions::util::GetInstalledPwaForUrl(browser()->profile(), url);
EXPECT_TRUE(GetManager().IsSystemWebApp(installed_app->id()));
EXPECT_TRUE(installed_app->from_bookmark());
EXPECT_EQ(title, installed_app->name());
EXPECT_EQ(base::ASCIIToUTF16(title),
app_browser->window()->GetNativeWindow()->GetTitle());
EXPECT_EQ(extensions::Manifest::EXTERNAL_COMPONENT,
installed_app->location());
// The installed app should match the opened app window.
EXPECT_EQ(installed_app, GetExtensionForAppBrowser(app_browser));
content::WebContents* web_contents =
app_browser->tab_strip_model()->GetActiveWebContents();
// The opened window should be showing the url with attached WebUI.
EXPECT_EQ(url, web_contents->GetVisibleURL());
content::TestNavigationObserver observer(web_contents);
observer.WaitForNavigationFinished();
EXPECT_EQ(url, web_contents->GetLastCommittedURL());
content::WebUI* web_ui = web_contents->GetCommittedWebUI();
ASSERT_TRUE(web_ui);
EXPECT_TRUE(web_ui->GetController());
// A completed navigation could change the window title. Check again.
EXPECT_EQ(base::ASCIIToUTF16(title),
app_browser->window()->GetNativeWindow()->GetTitle());
}
private:
......@@ -43,41 +84,17 @@ class SystemWebAppManagerBrowserTestChromeos
// Test that the Media App installs and launches correctly. Runs some spot
// checks on the manifest.
IN_PROC_BROWSER_TEST_F(SystemWebAppManagerBrowserTestChromeos, MediaApp) {
Browser* app_browser = WaitForSystemAppInstallAndLaunch(SystemAppType::MEDIA);
const extensions::Extension* installed_app =
extensions::util::GetInstalledPwaForUrl(
browser()->profile(),
content::GetWebUIURL(chromeos::kChromeUIMediaAppHost));
EXPECT_TRUE(GetManager().IsSystemWebApp(installed_app->id()));
EXPECT_TRUE(installed_app->from_bookmark());
EXPECT_EQ("Media App", installed_app->name());
EXPECT_EQ(base::ASCIIToUTF16("Media App"),
app_browser->window()->GetNativeWindow()->GetTitle());
EXPECT_EQ(extensions::Manifest::EXTERNAL_COMPONENT,
installed_app->location());
// The installed app should match the opened app window.
EXPECT_EQ(installed_app, GetExtensionForAppBrowser(app_browser));
content::WebContents* web_contents =
app_browser->tab_strip_model()->GetActiveWebContents();
// The opened window should be showing chrome://media-app with attached WebUI.
EXPECT_EQ(chromeos::kChromeUIMediaAppURL, web_contents->GetVisibleURL());
content::TestNavigationObserver observer(web_contents);
observer.WaitForNavigationFinished();
EXPECT_EQ(chromeos::kChromeUIMediaAppURL,
web_contents->GetLastCommittedURL());
content::WebUI* web_ui = web_contents->GetCommittedWebUI();
ASSERT_TRUE(web_ui);
EXPECT_TRUE(web_ui->GetController());
// A completed navigation could change the window title. Check again.
EXPECT_EQ(base::ASCIIToUTF16("Media App"),
app_browser->window()->GetNativeWindow()->GetTitle());
const GURL* url = new GURL(chromeos::kChromeUIMediaAppURL);
EXPECT_NO_FATAL_FAILURE(
ExpectSystemWebAppValid(SystemAppType::MEDIA, *url, "Media App"));
}
// Test that the Help App installs and launches correctly. Runs some spot
// checks on the manifest.
IN_PROC_BROWSER_TEST_F(SystemWebAppManagerBrowserTestChromeos, HelpAppV2) {
const GURL* url = new GURL(chromeos::kChromeUIHelpAppURL);
EXPECT_NO_FATAL_FAILURE(
ExpectSystemWebAppValid(SystemAppType::HELP, *url, "Help App"));
}
} // namespace web_app
......@@ -31,6 +31,7 @@
#if defined(OS_CHROMEOS)
#include "ash/public/cpp/app_list/internal_app_id_constants.h"
#include "chrome/browser/chromeos/extensions/default_web_app_ids.h"
#include "chromeos/components/help_app_ui/url_constants.h"
#include "chromeos/components/media_app_ui/url_constants.h"
#include "chromeos/constants/chromeos_features.h"
#endif // defined(OS_CHROMEOS)
......@@ -73,6 +74,10 @@ base::flat_map<SystemAppType, SystemAppInfo> CreateSystemWebApps() {
constexpr char kChromeTerminalPWAURL[] = "chrome://terminal/html/pwa.html";
infos[SystemAppType::TERMINAL].install_url = GURL(kChromeTerminalPWAURL);
}
if (SystemWebAppManager::IsAppEnabled(SystemAppType::HELP)) {
constexpr char kChromeHelpAppPWAURL[] = "chrome://help-app/pwa.html";
infos[SystemAppType::HELP].install_url = {GURL(kChromeHelpAppPWAURL)};
}
if (SystemWebAppManager::IsAppEnabled(SystemAppType::MEDIA)) {
constexpr char kChromeMediaAppURL[] = "chrome://media-app/pwa.html";
infos[SystemAppType::MEDIA].install_url = {GURL(kChromeMediaAppURL)};
......@@ -128,6 +133,8 @@ bool SystemWebAppManager::IsAppEnabled(SystemAppType type) {
return base::FeatureList::IsEnabled(features::kTerminalSystemApp);
case SystemAppType::MEDIA:
return base::FeatureList::IsEnabled(chromeos::features::kMediaApp);
case SystemAppType::HELP:
return base::FeatureList::IsEnabled(chromeos::features::kHelpAppV2);
}
#else
return false;
......
......@@ -42,6 +42,7 @@ enum class SystemAppType {
CAMERA,
TERMINAL,
MEDIA,
HELP,
};
// The configuration options for a System App.
......
......@@ -19,6 +19,9 @@ content::WebUIDataSource* CreateDataSource() {
// TODO(crbug.com/1012578): This is a placeholder only, update with the
// actual app content.
source->SetDefaultResource(IDR_HELP_APP_INDEX_HTML);
source->AddResourcePath("pwa.html", IDR_HELP_APP_PWA_HTML);
source->AddResourcePath("manifest.json", IDR_HELP_APP_MANIFEST);
source->AddResourcePath("app_icon_192.png", IDR_HELP_APP_ICON_192);
return source;
}
} // namespace
......
......@@ -16,6 +16,11 @@
<!-- TODO(crbug.com/1012578): Add the run time resources .grdp here. -->
<include name="IDR_HELP_APP_INDEX_HTML" file="index.html"
type="BINDATA" />
<include name="IDR_HELP_APP_PWA_HTML" file="pwa.html" type="BINDATA" />
<include name="IDR_HELP_APP_MANIFEST" file="manifest.json"
type="BINDATA" />
<include name="IDR_HELP_APP_ICON_192" file="app_icon_192.png"
type="BINDATA" />
</includes>
</release>
</grit>
{
"name": "Help App",
"short_name": "Help App",
"start_url": "/",
"display": "standalone",
"theme_color": "#4285F4",
"background_color": "#ffffff",
"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">
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