Commit c6867641 authored by Alexey Baskakov's avatar Alexey Baskakov Committed by Commit Bot

dpwa: Remove extensions headers from web_app_migration_manager.h.

This CL introduces no behavior changes.

chrome/browser/web_applications/web_app_migration_manager.h must not depend
on extensions, only forward declarations are visible.

This is a preparation CL to remove web_applications_on_extensions GN node.

WebAppProvider will be moved from web_applications_on_extensions to
general web_applications GN node.

Bug: 1065748
Change-Id: Ic74d8cdc9afe77472d13e27d889375add8e732d9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2517213Reviewed-by: default avatarAlan Cutter <alancutter@chromium.org>
Commit-Queue: Alexey Baskakov <loyso@chromium.org>
Cr-Commit-Position: refs/heads/master@{#823900}
parent 6e095509
...@@ -19,6 +19,10 @@ ...@@ -19,6 +19,10 @@
#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_ui_manager.h"
#include "chrome/browser/web_applications/components/web_app_utils.h" #include "chrome/browser/web_applications/components/web_app_utils.h"
#include "chrome/browser/web_applications/extensions/bookmark_app_file_handler_manager.h"
#include "chrome/browser/web_applications/extensions/bookmark_app_icon_manager.h"
#include "chrome/browser/web_applications/extensions/bookmark_app_registrar.h"
#include "chrome/browser/web_applications/extensions/bookmark_app_registry_controller.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"
...@@ -38,18 +42,25 @@ WebAppMigrationManager::WebAppMigrationManager( ...@@ -38,18 +42,25 @@ WebAppMigrationManager::WebAppMigrationManager(
AbstractWebAppDatabaseFactory* database_factory, AbstractWebAppDatabaseFactory* database_factory,
WebAppIconManager* web_app_icon_manager, WebAppIconManager* web_app_icon_manager,
OsIntegrationManager* os_integration_manager) OsIntegrationManager* os_integration_manager)
: bookmark_app_registrar_(profile), : bookmark_app_registrar_(
bookmark_app_registry_controller_(profile, &bookmark_app_registrar_), std::make_unique<extensions::BookmarkAppRegistrar>(profile)),
bookmark_app_icon_manager_(profile), bookmark_app_registry_controller_(
bookmark_app_file_handler_manager_(profile), std::make_unique<extensions::BookmarkAppRegistryController>(
profile,
bookmark_app_registrar_.get())),
bookmark_app_icon_manager_(
std::make_unique<extensions::BookmarkAppIconManager>(profile)),
bookmark_app_file_handler_manager_(
std::make_unique<extensions::BookmarkAppFileHandlerManager>(profile)),
database_factory_(database_factory), database_factory_(database_factory),
web_app_icon_manager_(web_app_icon_manager) { web_app_icon_manager_(web_app_icon_manager) {
database_ = std::make_unique<WebAppDatabase>( database_ = std::make_unique<WebAppDatabase>(
database_factory_, database_factory_,
base::BindRepeating(&WebAppMigrationManager::ReportDatabaseError, base::BindRepeating(&WebAppMigrationManager::ReportDatabaseError,
base::Unretained(this))); base::Unretained(this)));
bookmark_app_file_handler_manager_.SetSubsystems(&bookmark_app_registrar_); bookmark_app_file_handler_manager_->SetSubsystems(
bookmark_app_registrar_.SetSubsystems(os_integration_manager); bookmark_app_registrar_.get());
bookmark_app_registrar_->SetSubsystems(os_integration_manager);
} }
WebAppMigrationManager::~WebAppMigrationManager() = default; WebAppMigrationManager::~WebAppMigrationManager() = default;
...@@ -79,14 +90,14 @@ void WebAppMigrationManager::OnWebAppDatabaseOpened( ...@@ -79,14 +90,14 @@ void WebAppMigrationManager::OnWebAppDatabaseOpened(
} }
// Wait for the Extensions System to be ready. // Wait for the Extensions System to be ready.
bookmark_app_registry_controller_.Init(base::BindOnce( bookmark_app_registry_controller_->Init(base::BindOnce(
&WebAppMigrationManager::OnBookmarkAppRegistryReady, &WebAppMigrationManager::OnBookmarkAppRegistryReady,
weak_ptr_factory_.GetWeakPtr(), std::move(web_app_registry))); weak_ptr_factory_.GetWeakPtr(), std::move(web_app_registry)));
} }
void WebAppMigrationManager::OnBookmarkAppRegistryReady( void WebAppMigrationManager::OnBookmarkAppRegistryReady(
Registry web_app_registry) { Registry web_app_registry) {
bookmark_app_ids_ = bookmark_app_registrar_.GetAppIds(); bookmark_app_ids_ = bookmark_app_registrar_->GetAppIds();
// Remove bookmark app ids already listed in the web app registry. // Remove bookmark app ids already listed in the web app registry.
base::EraseIf(bookmark_app_ids_, [&web_app_registry](const AppId& app_id) { base::EraseIf(bookmark_app_ids_, [&web_app_registry](const AppId& app_id) {
...@@ -110,7 +121,7 @@ void WebAppMigrationManager::MigrateNextBookmarkAppIcons() { ...@@ -110,7 +121,7 @@ void WebAppMigrationManager::MigrateNextBookmarkAppIcons() {
++next_app_id_iterator_; ++next_app_id_iterator_;
} while (!CanMigrateBookmarkApp(app_id)); } while (!CanMigrateBookmarkApp(app_id));
bookmark_app_icon_manager_.ReadAllIcons( bookmark_app_icon_manager_->ReadAllIcons(
app_id, base::BindOnce(&WebAppMigrationManager::OnBookmarkAppIconsRead, app_id, base::BindOnce(&WebAppMigrationManager::OnBookmarkAppIconsRead,
weak_ptr_factory_.GetWeakPtr(), app_id)); weak_ptr_factory_.GetWeakPtr(), app_id));
} }
...@@ -135,7 +146,7 @@ void WebAppMigrationManager::OnWebAppIconsWritten(const AppId& app_id, ...@@ -135,7 +146,7 @@ void WebAppMigrationManager::OnWebAppIconsWritten(const AppId& app_id,
DLOG(ERROR) << "Write web app icons failed."; DLOG(ERROR) << "Write web app icons failed.";
if (base::FeatureList::IsEnabled( if (base::FeatureList::IsEnabled(
features::kDesktopPWAsAppIconShortcutsMenu)) { features::kDesktopPWAsAppIconShortcutsMenu)) {
bookmark_app_icon_manager_.ReadAllShortcutsMenuIcons( bookmark_app_icon_manager_->ReadAllShortcutsMenuIcons(
app_id, app_id,
base::BindOnce( base::BindOnce(
&WebAppMigrationManager::OnBookmarkAppShortcutsMenuIconsRead, &WebAppMigrationManager::OnBookmarkAppShortcutsMenuIconsRead,
...@@ -163,18 +174,18 @@ void WebAppMigrationManager::OnWebAppShortcutsMenuIconsWritten(bool success) { ...@@ -163,18 +174,18 @@ void WebAppMigrationManager::OnWebAppShortcutsMenuIconsWritten(bool success) {
void WebAppMigrationManager::MigrateBookmarkAppInstallSource( void WebAppMigrationManager::MigrateBookmarkAppInstallSource(
const AppId& app_id, const AppId& app_id,
WebApp* web_app) { WebApp* web_app) {
bool is_arc = bookmark_app_registrar_.HasExternalAppWithInstallSource( bool is_arc = bookmark_app_registrar_->HasExternalAppWithInstallSource(
app_id, ExternalInstallSource::kArc); app_id, ExternalInstallSource::kArc);
bool is_policy = bookmark_app_registrar_.HasExternalAppWithInstallSource( bool is_policy = bookmark_app_registrar_->HasExternalAppWithInstallSource(
app_id, ExternalInstallSource::kExternalPolicy); app_id, ExternalInstallSource::kExternalPolicy);
bool is_default = bookmark_app_registrar_.HasExternalAppWithInstallSource( bool is_default = bookmark_app_registrar_->HasExternalAppWithInstallSource(
app_id, ExternalInstallSource::kInternalDefault) || app_id, ExternalInstallSource::kInternalDefault) ||
bookmark_app_registrar_.HasExternalAppWithInstallSource( bookmark_app_registrar_->HasExternalAppWithInstallSource(
app_id, ExternalInstallSource::kExternalDefault); app_id, ExternalInstallSource::kExternalDefault);
bool is_system = bookmark_app_registrar_.HasExternalAppWithInstallSource( bool is_system = bookmark_app_registrar_->HasExternalAppWithInstallSource(
app_id, ExternalInstallSource::kSystemInstalled); app_id, ExternalInstallSource::kSystemInstalled);
if (is_default) if (is_default)
...@@ -189,23 +200,23 @@ void WebAppMigrationManager::MigrateBookmarkAppInstallSource( ...@@ -189,23 +200,23 @@ void WebAppMigrationManager::MigrateBookmarkAppInstallSource(
if (is_arc) if (is_arc)
web_app->AddSource(Source::kWebAppStore); web_app->AddSource(Source::kWebAppStore);
if (!bookmark_app_registrar_.HasExternalApp(app_id)) if (!bookmark_app_registrar_->HasExternalApp(app_id))
web_app->AddSource(Source::kSync); web_app->AddSource(Source::kSync);
DCHECK(web_app->HasAnySources()); DCHECK(web_app->HasAnySources());
} }
bool WebAppMigrationManager::CanMigrateBookmarkApp(const AppId& app_id) const { bool WebAppMigrationManager::CanMigrateBookmarkApp(const AppId& app_id) const {
if (!bookmark_app_registrar_.IsInstalled(app_id)) if (!bookmark_app_registrar_->IsInstalled(app_id))
return false; return false;
// SystemWebAppManager will re-install these. // SystemWebAppManager will re-install these.
if (bookmark_app_registrar_.HasExternalAppWithInstallSource( if (bookmark_app_registrar_->HasExternalAppWithInstallSource(
app_id, ExternalInstallSource::kSystemInstalled)) { app_id, ExternalInstallSource::kSystemInstalled)) {
return false; return false;
} }
GURL start_url = bookmark_app_registrar_.GetAppStartUrl(app_id); GURL start_url = bookmark_app_registrar_->GetAppStartUrl(app_id);
return GenerateAppIdFromURL(start_url) == app_id; return GenerateAppIdFromURL(start_url) == app_id;
} }
...@@ -215,45 +226,45 @@ std::unique_ptr<WebApp> WebAppMigrationManager::MigrateBookmarkApp( ...@@ -215,45 +226,45 @@ std::unique_ptr<WebApp> WebAppMigrationManager::MigrateBookmarkApp(
auto web_app = std::make_unique<WebApp>(app_id); auto web_app = std::make_unique<WebApp>(app_id);
web_app->SetName(bookmark_app_registrar_.GetAppShortName(app_id)); web_app->SetName(bookmark_app_registrar_->GetAppShortName(app_id));
web_app->SetDescription(bookmark_app_registrar_.GetAppDescription(app_id)); web_app->SetDescription(bookmark_app_registrar_->GetAppDescription(app_id));
web_app->SetStartUrl(bookmark_app_registrar_.GetAppStartUrl(app_id)); web_app->SetStartUrl(bookmark_app_registrar_->GetAppStartUrl(app_id));
web_app->SetLastLaunchTime( web_app->SetLastLaunchTime(
bookmark_app_registrar_.GetAppLastLaunchTime(app_id)); bookmark_app_registrar_->GetAppLastLaunchTime(app_id));
web_app->SetInstallTime(bookmark_app_registrar_.GetAppInstallTime(app_id)); web_app->SetInstallTime(bookmark_app_registrar_->GetAppInstallTime(app_id));
base::Optional<GURL> scope = bookmark_app_registrar_.GetAppScope(app_id); base::Optional<GURL> scope = bookmark_app_registrar_->GetAppScope(app_id);
if (scope) if (scope)
web_app->SetScope(*scope); web_app->SetScope(*scope);
web_app->SetThemeColor(bookmark_app_registrar_.GetAppThemeColor(app_id)); web_app->SetThemeColor(bookmark_app_registrar_->GetAppThemeColor(app_id));
web_app->SetDisplayMode(bookmark_app_registrar_.GetAppDisplayMode(app_id)); web_app->SetDisplayMode(bookmark_app_registrar_->GetAppDisplayMode(app_id));
DisplayMode user_display_mode = DisplayMode user_display_mode =
bookmark_app_registrar_.GetAppUserDisplayModeForMigration(app_id); bookmark_app_registrar_->GetAppUserDisplayModeForMigration(app_id);
if (user_display_mode != DisplayMode::kUndefined) if (user_display_mode != DisplayMode::kUndefined)
web_app->SetUserDisplayMode(user_display_mode); web_app->SetUserDisplayMode(user_display_mode);
web_app->SetIsLocallyInstalled( web_app->SetIsLocallyInstalled(
bookmark_app_registrar_.IsLocallyInstalled(app_id)); bookmark_app_registrar_->IsLocallyInstalled(app_id));
web_app->SetIconInfos(bookmark_app_registrar_.GetAppIconInfos(app_id)); web_app->SetIconInfos(bookmark_app_registrar_->GetAppIconInfos(app_id));
web_app->SetDownloadedIconSizes( web_app->SetDownloadedIconSizes(
IconPurpose::ANY, IconPurpose::ANY,
bookmark_app_registrar_.GetAppDownloadedIconSizesAny(app_id)); bookmark_app_registrar_->GetAppDownloadedIconSizesAny(app_id));
// Migrated bookmark apps will have no IconPurpose::MASKABLE icons downloaded. // Migrated bookmark apps will have no IconPurpose::MASKABLE icons downloaded.
if (base::FeatureList::IsEnabled( if (base::FeatureList::IsEnabled(
features::kDesktopPWAsAppIconShortcutsMenu)) { features::kDesktopPWAsAppIconShortcutsMenu)) {
web_app->SetShortcutsMenuItemInfos( web_app->SetShortcutsMenuItemInfos(
bookmark_app_registrar_.GetAppShortcutsMenuItemInfos(app_id)); bookmark_app_registrar_->GetAppShortcutsMenuItemInfos(app_id));
web_app->SetDownloadedShortcutsMenuIconsSizes( web_app->SetDownloadedShortcutsMenuIconsSizes(
bookmark_app_registrar_.GetAppDownloadedShortcutsMenuIconsSizes( bookmark_app_registrar_->GetAppDownloadedShortcutsMenuIconsSizes(
app_id)); app_id));
} }
web_app->SetUserPageOrdinal( web_app->SetUserPageOrdinal(
bookmark_app_registrar_.GetUserPageOrdinal(app_id)); bookmark_app_registrar_->GetUserPageOrdinal(app_id));
web_app->SetUserLaunchOrdinal( web_app->SetUserLaunchOrdinal(
bookmark_app_registrar_.GetUserLaunchOrdinal(app_id)); bookmark_app_registrar_->GetUserLaunchOrdinal(app_id));
if (IsChromeOs()) { if (IsChromeOs()) {
auto chromeos_data = base::make_optional<WebAppChromeOsData>(); auto chromeos_data = base::make_optional<WebAppChromeOsData>();
...@@ -265,18 +276,18 @@ std::unique_ptr<WebApp> WebAppMigrationManager::MigrateBookmarkApp( ...@@ -265,18 +276,18 @@ std::unique_ptr<WebApp> WebAppMigrationManager::MigrateBookmarkApp(
} }
WebApp::SyncFallbackData sync_fallback_data; WebApp::SyncFallbackData sync_fallback_data;
sync_fallback_data.name = bookmark_app_registrar_.GetAppShortName(app_id); sync_fallback_data.name = bookmark_app_registrar_->GetAppShortName(app_id);
sync_fallback_data.theme_color = sync_fallback_data.theme_color =
bookmark_app_registrar_.GetAppThemeColor(app_id); bookmark_app_registrar_->GetAppThemeColor(app_id);
// Avoid using derived scope as we are transferring raw data. // Avoid using derived scope as we are transferring raw data.
sync_fallback_data.scope = sync_fallback_data.scope =
bookmark_app_registrar_.GetAppScopeInternal(app_id).value_or(GURL()); bookmark_app_registrar_->GetAppScopeInternal(app_id).value_or(GURL());
sync_fallback_data.icon_infos = sync_fallback_data.icon_infos =
bookmark_app_registrar_.GetAppIconInfos(app_id); bookmark_app_registrar_->GetAppIconInfos(app_id);
web_app->SetSyncFallbackData(std::move(sync_fallback_data)); web_app->SetSyncFallbackData(std::move(sync_fallback_data));
const apps::FileHandlers* file_handlers = const apps::FileHandlers* file_handlers =
bookmark_app_file_handler_manager_.GetAllFileHandlers(app_id); bookmark_app_file_handler_manager_->GetAllFileHandlers(app_id);
if (file_handlers) if (file_handlers)
web_app->SetFileHandlers(*file_handlers); web_app->SetFileHandlers(*file_handlers);
......
...@@ -11,12 +11,9 @@ ...@@ -11,12 +11,9 @@
#include "base/callback_forward.h" #include "base/callback_forward.h"
#include "base/memory/weak_ptr.h" #include "base/memory/weak_ptr.h"
#include "chrome/browser/web_applications/components/app_icon_manager.h"
#include "chrome/browser/web_applications/components/os_integration_manager.h" #include "chrome/browser/web_applications/components/os_integration_manager.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/extensions/bookmark_app_file_handler_manager.h"
#include "chrome/browser/web_applications/extensions/bookmark_app_icon_manager.h"
#include "chrome/browser/web_applications/extensions/bookmark_app_registrar.h"
#include "chrome/browser/web_applications/extensions/bookmark_app_registry_controller.h"
#include "chrome/browser/web_applications/web_app_registrar.h" #include "chrome/browser/web_applications/web_app_registrar.h"
#include "chrome/common/web_application_info.h" #include "chrome/common/web_application_info.h"
...@@ -25,6 +22,13 @@ class ModelError; ...@@ -25,6 +22,13 @@ class ModelError;
class MetadataBatch; class MetadataBatch;
} // namespace syncer } // namespace syncer
namespace extensions {
class BookmarkAppRegistrar;
class BookmarkAppRegistryController;
class BookmarkAppIconManager;
class BookmarkAppFileHandlerManager;
} // namespace extensions
namespace web_app { namespace web_app {
class AbstractWebAppDatabaseFactory; class AbstractWebAppDatabaseFactory;
...@@ -77,10 +81,13 @@ class WebAppMigrationManager { ...@@ -77,10 +81,13 @@ class WebAppMigrationManager {
void ScheduleDestructDatabaseAndCallCallback(bool success); void ScheduleDestructDatabaseAndCallCallback(bool success);
void DestructDatabaseAndCallCallback(bool success); void DestructDatabaseAndCallCallback(bool success);
extensions::BookmarkAppRegistrar bookmark_app_registrar_; std::unique_ptr<extensions::BookmarkAppRegistrar> bookmark_app_registrar_;
extensions::BookmarkAppRegistryController bookmark_app_registry_controller_; std::unique_ptr<extensions::BookmarkAppRegistryController>
extensions::BookmarkAppIconManager bookmark_app_icon_manager_; bookmark_app_registry_controller_;
extensions::BookmarkAppFileHandlerManager bookmark_app_file_handler_manager_; std::unique_ptr<extensions::BookmarkAppIconManager>
bookmark_app_icon_manager_;
std::unique_ptr<extensions::BookmarkAppFileHandlerManager>
bookmark_app_file_handler_manager_;
AbstractWebAppDatabaseFactory* const database_factory_; AbstractWebAppDatabaseFactory* const database_factory_;
WebAppIconManager* const web_app_icon_manager_; WebAppIconManager* const web_app_icon_manager_;
......
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