Commit 4c2218c9 authored by David's avatar David Committed by Commit Bot

Hide the icon for the MediaApp in CrOS launcher.

This cl also
* adds the id of the MediaApp into chromium (will need it for metrics
  later)
* adds a test parameterized test (since SystemWebAppManagerBrowserTest is now paramterized), currently expects the inverse.

Bug: b/144886504, 877898, 1054195
Change-Id: I1d862b04d47092e45ad08415b707612a1e5464fa
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2082659
Commit-Queue: David Lei <dlei@google.com>
Reviewed-by: default avatarGiovanni Ortuño Urquidi <ortuno@chromium.org>
Reviewed-by: default avatarTrent Apted <tapted@chromium.org>
Cr-Commit-Position: refs/heads/master@{#749575}
parent c6997594
......@@ -522,6 +522,8 @@ void WebApps::OnArcAppListPrefsDestroyed() {
void WebApps::SetShowInFields(apps::mojom::AppPtr& app,
const web_app::WebApp* web_app) {
// TODO(crbug.com/1054195): Make web_apps read this from
// system_web_app_manager.
auto show = apps::mojom::OptionalBool::kTrue;
app->show_in_launcher = show;
app->show_in_search = show;
......
......@@ -67,8 +67,8 @@ class MediaAppIntegrationWithFilesAppTest : public MediaAppIntegrationTest {
file_manager::test::AddDefaultComponentExtensionsOnMainThread(profile());
// Add the Files App, but remove the Gallery app, since its own file
// handling may interfere. Long term, the Galley app will be removed.
// TODO(crbug/1030935): Rely on flags alone to remove the Gallery App (i.e.
// migrate this step to release code).
// TODO(crbug.com/1030935): Rely on flags alone to remove the Gallery App
// (i.e. migrate this step to release code).
extensions::ExtensionService* service =
extensions::ExtensionSystem::Get(profile())->extension_service();
service->component_loader()->Remove(file_manager::kGalleryAppId);
......@@ -210,6 +210,14 @@ IN_PROC_BROWSER_TEST_P(MediaAppIntegrationTest, MediaAppEligibleOpenTask) {
}
}
IN_PROC_BROWSER_TEST_P(MediaAppIntegrationTest, HiddenInLauncher) {
WaitForTestSystemAppInstall();
// Check system_web_app_manager has the correct attributes for Media App.
EXPECT_FALSE(
GetManager().ShouldShowInLauncher(web_app::SystemAppType::MEDIA));
}
// End-to-end test to ensure that the MediaApp successfully registers as a file
// handler with the ChromeOS file manager on startup and acts as the default
// handler for a given file.
......@@ -267,7 +275,7 @@ IN_PROC_BROWSER_TEST_P(MediaAppIntegrationWithFilesAppTest,
EXPECT_EQ("640x480", WaitForOpenedImage(web_ui));
// Clear the <img> src attribute to ensure we can detect changes reliably.
// TODO(crbug/893226): Use the alt-text to find the image instead.
// TODO(crbug.com/893226): Use the alt-text to find the image instead.
ClearOpenedImage(web_ui);
// Navigate to the next file in the directory.
......
......@@ -242,6 +242,10 @@ source_set("web_applications_browser_tests") {
"//chrome/test:test_support_ui",
"//components/permissions:permissions",
]
if (is_chromeos) {
deps += [ "//chrome/browser/ui" ]
}
}
# TODO(crbug.com/877898): Erase this and move WebAppProvider into
......
......@@ -122,6 +122,7 @@ base::flat_map<SystemAppType, SystemAppInfo> CreateSystemWebApps() {
infos.emplace(SystemAppType::MEDIA,
SystemAppInfo("Media", GURL("chrome://media-app/pwa.html")));
infos.at(SystemAppType::MEDIA).include_launch_directory = true;
infos.at(SystemAppType::MEDIA).show_in_launcher = false;
}
if (SystemWebAppManager::IsAppEnabled(SystemAppType::PRINT_MANAGEMENT)) {
......
......@@ -42,6 +42,13 @@
#include "third_party/blink/public/common/features.h"
#include "url/gurl.h"
#if defined(OS_CHROMEOS)
#include "chrome/browser/ui/app_list/app_list_client_impl.h"
#include "chrome/browser/ui/app_list/app_list_model_updater.h"
#include "chrome/browser/ui/app_list/extension_app_item.h"
#include "chrome/browser/ui/app_list/test/chrome_app_list_test_support.h"
#endif
namespace web_app {
SystemWebAppManagerBrowserTestBase::SystemWebAppManagerBrowserTestBase(
......@@ -72,6 +79,11 @@ void SystemWebAppManagerBrowserTestBase::WaitForTestSystemAppInstall() {
} else {
GetManager().InstallSystemAppsForTesting();
}
// Ensure apps are registered with the |AppService| and populated in
// |AppListModel|.
apps::AppServiceProxy* proxy =
apps::AppServiceProxyFactory::GetForProfile(browser()->profile());
proxy->FlushMojoCallsForTesting();
}
content::WebContents*
......@@ -571,6 +583,26 @@ IN_PROC_BROWSER_TEST_P(SystemWebAppManagerNotShownInLauncherTest,
EXPECT_EQ(apps::mojom::OptionalBool::kFalse, update.ShowInLauncher());
}
});
// OS Integration only relevant for Chrome OS.
#if defined(OS_CHROMEOS)
// The |AppList| should have all apps visible in the launcher, apps get
// removed from the |AppList| when they are hidden.
AppListClientImpl* client = AppListClientImpl::GetInstance();
ASSERT_TRUE(client);
AppListModelUpdater* model_updater = test::GetModelUpdater(client);
const ChromeAppListItem* mock_app = model_updater->FindItem(app_id);
// |mock_app| shouldn't be found in |AppList| because it should be hidden in
// launcher.
if (provider == ProviderType::kWebApps) {
// TODO(crbug.com/877898): |mock_app| should be hidden but web_apps.cc does
// not currently read from system_web_app_manager.cc. When
// DesktopPWAsWithoutExtensions launches this should change to
// EXPECT_FALSE().
EXPECT_TRUE(mock_app);
} else {
EXPECT_FALSE(mock_app);
}
#endif // defined(OS_CHROMEOS)
}
class SystemWebAppManagerAdditionalSearchTermsTest
......
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