Commit c729e172 authored by Giovanni Ortuño Urquidi's avatar Giovanni Ortuño Urquidi Committed by Commit Bot

default-apps: Check if app should be hidden from user during migration

Some apps, like Release Notes, are hidden from the app launcher, search,
etc. This CL ensures this setting is correctly migrated to BMO.

Fixed: 1086068
Change-Id: I47401753240da830f1f488dc6909e01912cec5e4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2215385
Commit-Queue: Giovanni Ortuño Urquidi <ortuno@chromium.org>
Reviewed-by: default avatarAlexey Baskakov <loyso@chromium.org>
Cr-Commit-Position: refs/heads/master@{#771721}
parent d3812689
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include "ash/public/cpp/shelf_model.h" #include "ash/public/cpp/shelf_model.h"
#include "chrome/browser/ui/app_list/app_list_syncable_service.h" #include "chrome/browser/ui/app_list/app_list_syncable_service.h"
#include "chrome/browser/ui/app_list/app_list_syncable_service_factory.h" #include "chrome/browser/ui/app_list/app_list_syncable_service_factory.h"
#include "chrome/browser/ui/app_list/extension_app_utils.h"
#include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h"
#endif #endif
...@@ -34,6 +35,15 @@ std::unique_ptr<WebAppUiManager> WebAppUiManager::Create(Profile* profile) { ...@@ -34,6 +35,15 @@ std::unique_ptr<WebAppUiManager> WebAppUiManager::Create(Profile* profile) {
return std::make_unique<WebAppUiManagerImpl>(profile); return std::make_unique<WebAppUiManagerImpl>(profile);
} }
// static
bool WebAppUiManager::ShouldHideAppFromUser(const AppId& app_id) {
#if defined(OS_CHROMEOS)
return app_list::HideInLauncherById(app_id);
#else
return false;
#endif
}
// static // static
WebAppUiManagerImpl* WebAppUiManagerImpl::Get(Profile* profile) { WebAppUiManagerImpl* WebAppUiManagerImpl::Get(Profile* profile) {
auto* provider = WebAppProvider::Get(profile); auto* provider = WebAppProvider::Get(profile);
......
...@@ -28,6 +28,8 @@ class WebAppUiManager { ...@@ -28,6 +28,8 @@ class WebAppUiManager {
public: public:
static std::unique_ptr<WebAppUiManager> Create(Profile* profile); static std::unique_ptr<WebAppUiManager> Create(Profile* profile);
static bool ShouldHideAppFromUser(const AppId& app_id);
virtual ~WebAppUiManager() = default; virtual ~WebAppUiManager() = default;
virtual void Start() = 0; virtual void Start() = 0;
......
...@@ -11,8 +11,11 @@ ...@@ -11,8 +11,11 @@
#include "base/logging.h" #include "base/logging.h"
#include "base/stl_util.h" #include "base/stl_util.h"
#include "base/threading/sequenced_task_runner_handle.h" #include "base/threading/sequenced_task_runner_handle.h"
#include "chrome/browser/web_applications/components/web_app_chromeos_data.h"
#include "chrome/browser/web_applications/components/web_app_constants.h" #include "chrome/browser/web_applications/components/web_app_constants.h"
#include "chrome/browser/web_applications/components/web_app_helpers.h" #include "chrome/browser/web_applications/components/web_app_helpers.h"
#include "chrome/browser/web_applications/components/web_app_ui_manager.h"
#include "chrome/browser/web_applications/components/web_app_utils.h"
#include "chrome/browser/web_applications/web_app.h" #include "chrome/browser/web_applications/web_app.h"
#include "chrome/browser/web_applications/web_app_database.h" #include "chrome/browser/web_applications/web_app_database.h"
#include "chrome/browser/web_applications/web_app_database_factory.h" #include "chrome/browser/web_applications/web_app_database_factory.h"
...@@ -207,6 +210,15 @@ std::unique_ptr<WebApp> WebAppMigrationManager::MigrateBookmarkApp( ...@@ -207,6 +210,15 @@ std::unique_ptr<WebApp> WebAppMigrationManager::MigrateBookmarkApp(
web_app->SetDownloadedIconSizes( web_app->SetDownloadedIconSizes(
bookmark_app_registrar_.GetAppDownloadedIconSizes(app_id)); bookmark_app_registrar_.GetAppDownloadedIconSizes(app_id));
if (IsChromeOs()) {
auto chromeos_data = base::make_optional<WebAppChromeOsData>();
const bool should_show = !WebAppUiManager::ShouldHideAppFromUser(app_id);
chromeos_data->show_in_launcher = should_show;
chromeos_data->show_in_search = should_show;
chromeos_data->show_in_management = should_show;
web_app->SetWebAppChromeOsData(std::move(chromeos_data));
}
WebApp::SyncData sync_data; WebApp::SyncData sync_data;
sync_data.name = bookmark_app_registrar_.GetAppShortName(app_id); sync_data.name = bookmark_app_registrar_.GetAppShortName(app_id);
sync_data.theme_color = bookmark_app_registrar_.GetAppThemeColor(app_id); sync_data.theme_color = bookmark_app_registrar_.GetAppThemeColor(app_id);
......
...@@ -21,9 +21,11 @@ ...@@ -21,9 +21,11 @@
#include "chrome/browser/web_applications/components/app_icon_manager.h" #include "chrome/browser/web_applications/components/app_icon_manager.h"
#include "chrome/browser/web_applications/components/app_registrar.h" #include "chrome/browser/web_applications/components/app_registrar.h"
#include "chrome/browser/web_applications/components/app_shortcut_manager.h" #include "chrome/browser/web_applications/components/app_shortcut_manager.h"
#include "chrome/browser/web_applications/components/web_app_chromeos_data.h"
#include "chrome/browser/web_applications/components/web_app_constants.h" #include "chrome/browser/web_applications/components/web_app_constants.h"
#include "chrome/browser/web_applications/components/web_app_helpers.h" #include "chrome/browser/web_applications/components/web_app_helpers.h"
#include "chrome/browser/web_applications/components/web_app_id.h" #include "chrome/browser/web_applications/components/web_app_id.h"
#include "chrome/browser/web_applications/components/web_app_utils.h"
#include "chrome/browser/web_applications/web_app.h" #include "chrome/browser/web_applications/web_app.h"
#include "chrome/browser/web_applications/web_app_provider.h" #include "chrome/browser/web_applications/web_app_provider.h"
#include "chrome/common/chrome_features.h" #include "chrome/common/chrome_features.h"
...@@ -45,6 +47,14 @@ constexpr char kBaseDataDir[] = "chrome/test/data/banners"; ...@@ -45,6 +47,14 @@ constexpr char kBaseDataDir[] = "chrome/test/data/banners";
// manifest_test_page.html. // manifest_test_page.html.
constexpr char kSimpleManifestStartUrl[] = constexpr char kSimpleManifestStartUrl[] =
"https://example.org/manifest_test_page.html"; "https://example.org/manifest_test_page.html";
// start_url in release_notes_manifest.json generates the id of an app that
// should be hidden from the user.
constexpr char kHiddenAppInstallUrl[] =
"https://www.google.com/manifest_test_page.html"
"?manifest=release_notes_manifest.json";
constexpr char kHiddenAppStartUrl[] =
"https://www.google.com/chromebook/whatsnew/embedded/";
// Performs blocking IO operations. // Performs blocking IO operations.
base::FilePath GetDataFilePath(const base::FilePath& relative_path, base::FilePath GetDataFilePath(const base::FilePath& relative_path,
...@@ -210,6 +220,41 @@ IN_PROC_BROWSER_TEST_F(WebAppMigrationManagerBrowserTest, ...@@ -210,6 +220,41 @@ IN_PROC_BROWSER_TEST_F(WebAppMigrationManagerBrowserTest,
run_loop.Run(); run_loop.Run();
} }
IN_PROC_BROWSER_TEST_F(WebAppMigrationManagerBrowserTest,
PRE_DatabaseMigration_HiddenFromUser) {
ui_test_utils::NavigateToURL(browser(), GURL{kHiddenAppInstallUrl});
AppId app_id = InstallWebAppAsUserViaOmnibox();
EXPECT_EQ(GenerateAppIdFromURL(GURL(kHiddenAppStartUrl)), app_id);
EXPECT_TRUE(provider().registrar().AsBookmarkAppRegistrar());
EXPECT_FALSE(provider().registrar().AsWebAppRegistrar());
EXPECT_TRUE(provider().registrar().IsInstalled(app_id));
}
IN_PROC_BROWSER_TEST_F(WebAppMigrationManagerBrowserTest,
DatabaseMigration_HiddenFromUser) {
AwaitRegistryReady();
AppId app_id = GenerateAppIdFromURL(GURL{kHiddenAppStartUrl});
EXPECT_TRUE(provider().registrar().IsInstalled(app_id));
WebAppRegistrar* registrar = provider().registrar().AsWebAppRegistrar();
ASSERT_TRUE(registrar);
EXPECT_FALSE(provider().registrar().AsBookmarkAppRegistrar());
const WebApp* web_app = registrar->GetAppById(app_id);
ASSERT_TRUE(web_app);
if (IsChromeOs()) {
EXPECT_FALSE(web_app->chromeos_data()->show_in_launcher);
EXPECT_FALSE(web_app->chromeos_data()->show_in_search);
EXPECT_FALSE(web_app->chromeos_data()->show_in_management);
} else {
EXPECT_FALSE(web_app->chromeos_data().has_value());
}
}
// TODO(crbug.com/1020037): Test policy installed bookmark apps with an external // TODO(crbug.com/1020037): Test policy installed bookmark apps with an external
// install source to cover // install source to cover
// WebAppMigrationManager::MigrateBookmarkAppInstallSource() logic. // WebAppMigrationManager::MigrateBookmarkAppInstallSource() logic.
......
{
"name": "What's New",
"short_name": "What's New",
"icons": [
{
"src": "launcher-icon-1x.png",
"sizes": "48x48",
"type": "image/png"
},
{
"src": "launcher-icon-1-5x.png",
"sizes": "72x72",
"type": "image/png"
},
{
"src": "launcher-icon-2x.png",
"sizes": "96x96",
"type": "image/png",
"purpose": "any badge"
},
{
"src": "launcher-icon-3x.png",
"sizes": "144x144",
"type": "image/png"
},
{
"src": "launcher-icon-4x.png",
"sizes": "192x192",
"type": "image/png"
},
{
"src": "image-512px.png",
"sizes": "512x512",
"type": "image/png"
}
],
"start_url": "https://www.google.com/chromebook/whatsnew/embedded/",
"scope": "/",
"display": "standalone",
"background_color": "#FFFFFF",
"theme_color": "#FFFFFF"
}
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