Commit 6e07e3bc authored by Alan Cutter's avatar Alan Cutter Committed by Commit Bot

WebApp: Create ExternalWebAppManager and WebAppPolicyManager subsystems for BMO

This CL instantiates the ExternalWebAppManager and WebAppPolicyManager
subsystems when BMO is enabled. These subsystems are generalised to work
with or without BMO and are needed for general web app operation.

This CL also reorders the subsystems to be alphabetical in the header and
ordered by their interdependencies in the initialisation code.

Bug: 916381
Change-Id: Ie0f146c41bde8355243e0b380dee5e1c642596e0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1745672
Commit-Queue: Alan Cutter <alancutter@chromium.org>
Reviewed-by: default avatarAlexey Baskakov <loyso@chromium.org>
Cr-Commit-Position: refs/heads/master@{#685459}
parent ca7ab438
...@@ -35,9 +35,7 @@ class WebAppProviderBase : public KeyedService { ...@@ -35,9 +35,7 @@ class WebAppProviderBase : public KeyedService {
virtual PendingAppManager& pending_app_manager() = 0; virtual PendingAppManager& pending_app_manager() = 0;
// Clients can use WebAppPolicyManager to request updates of policy installed // Clients can use WebAppPolicyManager to request updates of policy installed
// Web Apps. // Web Apps.
// TODO(crbug.com/916381): Make a reference once WebAppPolicyManager is always virtual WebAppPolicyManager& policy_manager() = 0;
// present. It's currently only present for Bookmark Apps.
virtual WebAppPolicyManager* policy_manager() = 0;
virtual WebAppUiManager& ui_manager() = 0; virtual WebAppUiManager& ui_manager() = 0;
......
...@@ -131,11 +131,7 @@ void WebAppTabHelperBase::ReinstallPlaceholderAppIfNecessary(const GURL& url) { ...@@ -131,11 +131,7 @@ void WebAppTabHelperBase::ReinstallPlaceholderAppIfNecessary(const GURL& url) {
Profile::FromBrowserContext(web_contents()->GetBrowserContext())); Profile::FromBrowserContext(web_contents()->GetBrowserContext()));
DCHECK(provider); DCHECK(provider);
// WebAppPolicyManager might be nullptr in the non-extensions implementation. provider->policy_manager().ReinstallPlaceholderAppIfNecessary(url);
if (!provider->policy_manager())
return;
provider->policy_manager()->ReinstallPlaceholderAppIfNecessary(url);
} }
AppId WebAppTabHelperBase::FindAppIdWithUrlInScope(const GURL& url) const { AppId WebAppTabHelperBase::FindAppIdWithUrlInScope(const GURL& url) const {
......
...@@ -91,9 +91,9 @@ PendingAppManager& WebAppProvider::pending_app_manager() { ...@@ -91,9 +91,9 @@ PendingAppManager& WebAppProvider::pending_app_manager() {
return *pending_app_manager_; return *pending_app_manager_;
} }
WebAppPolicyManager* WebAppProvider::policy_manager() { WebAppPolicyManager& WebAppProvider::policy_manager() {
CheckIsConnected(); CheckIsConnected();
return web_app_policy_manager_.get(); return *web_app_policy_manager_;
} }
WebAppUiManager& WebAppProvider::ui_manager() { WebAppUiManager& WebAppProvider::ui_manager() {
...@@ -117,45 +117,42 @@ void WebAppProvider::StartImpl() { ...@@ -117,45 +117,42 @@ void WebAppProvider::StartImpl() {
void WebAppProvider::CreateCommonSubsystems(Profile* profile) { void WebAppProvider::CreateCommonSubsystems(Profile* profile) {
audio_focus_id_map_ = std::make_unique<WebAppAudioFocusIdMap>(); audio_focus_id_map_ = std::make_unique<WebAppAudioFocusIdMap>();
ui_manager_ = WebAppUiManager::Create(profile);
install_manager_ = std::make_unique<WebAppInstallManager>(profile); install_manager_ = std::make_unique<WebAppInstallManager>(profile);
pending_app_manager_ = std::make_unique<PendingAppManagerImpl>(profile); pending_app_manager_ = std::make_unique<PendingAppManagerImpl>(profile);
external_web_app_manager_ = std::make_unique<ExternalWebAppManager>(profile);
system_web_app_manager_ = std::make_unique<SystemWebAppManager>(profile); system_web_app_manager_ = std::make_unique<SystemWebAppManager>(profile);
ui_manager_ = WebAppUiManager::Create(profile); web_app_policy_manager_ = std::make_unique<WebAppPolicyManager>(profile);
} }
void WebAppProvider::CreateWebAppsSubsystems(Profile* profile) { void WebAppProvider::CreateWebAppsSubsystems(Profile* profile) {
database_factory_ = std::make_unique<WebAppDatabaseFactory>(profile); database_factory_ = std::make_unique<WebAppDatabaseFactory>(profile);
database_ = std::make_unique<WebAppDatabase>(database_factory_.get()); database_ = std::make_unique<WebAppDatabase>(database_factory_.get());
registrar_ = std::make_unique<WebAppRegistrar>(profile, database_.get()); registrar_ = std::make_unique<WebAppRegistrar>(profile, database_.get());
sync_manager_ = std::make_unique<WebAppSyncManager>();
icon_manager_ = std::make_unique<WebAppIconManager>( icon_manager_ = std::make_unique<WebAppIconManager>(
profile, std::make_unique<FileUtilsWrapper>()); profile, std::make_unique<FileUtilsWrapper>());
install_finalizer_ = install_finalizer_ =
std::make_unique<WebAppInstallFinalizer>(icon_manager_.get()); std::make_unique<WebAppInstallFinalizer>(icon_manager_.get());
sync_manager_ = std::make_unique<WebAppSyncManager>();
} }
void WebAppProvider::CreateBookmarkAppsSubsystems(Profile* profile) { void WebAppProvider::CreateBookmarkAppsSubsystems(Profile* profile) {
registrar_ = std::make_unique<extensions::BookmarkAppRegistrar>(profile); registrar_ = std::make_unique<extensions::BookmarkAppRegistrar>(profile);
install_finalizer_ = install_finalizer_ =
std::make_unique<extensions::BookmarkAppInstallFinalizer>(profile); std::make_unique<extensions::BookmarkAppInstallFinalizer>(profile);
external_web_app_manager_ = std::make_unique<ExternalWebAppManager>(profile);
web_app_policy_manager_ = std::make_unique<WebAppPolicyManager>(profile);
} }
void WebAppProvider::ConnectSubsystems() { void WebAppProvider::ConnectSubsystems() {
DCHECK(!started_); DCHECK(!started_);
install_manager_->SetSubsystems(registrar_.get(), install_finalizer_.get());
install_finalizer_->SetSubsystems(registrar_.get(), ui_manager_.get()); install_finalizer_->SetSubsystems(registrar_.get(), ui_manager_.get());
install_manager_->SetSubsystems(registrar_.get(), install_finalizer_.get());
pending_app_manager_->SetSubsystems(registrar_.get(), ui_manager_.get(), pending_app_manager_->SetSubsystems(registrar_.get(), ui_manager_.get(),
install_finalizer_.get()); install_finalizer_.get());
external_web_app_manager_->SetSubsystems(pending_app_manager_.get());
system_web_app_manager_->SetSubsystems(pending_app_manager_.get(), system_web_app_manager_->SetSubsystems(pending_app_manager_.get(),
registrar_.get(), ui_manager_.get()); registrar_.get(), ui_manager_.get());
web_app_policy_manager_->SetSubsystems(pending_app_manager_.get());
if (!base::FeatureList::IsEnabled(features::kDesktopPWAsWithoutExtensions)) {
external_web_app_manager_->SetSubsystems(pending_app_manager_.get());
web_app_policy_manager_->SetSubsystems(pending_app_manager_.get());
}
connected_ = true; connected_ = true;
} }
......
...@@ -29,25 +29,21 @@ class PrefRegistrySyncable; ...@@ -29,25 +29,21 @@ class PrefRegistrySyncable;
namespace web_app { namespace web_app {
// Forward declarations of generalized interfaces. // Forward declarations of generalized interfaces.
class AppRegistrar;
class ExternalWebAppManager; class ExternalWebAppManager;
class InstallFinalizer; class InstallFinalizer;
class PendingAppManager;
class SystemWebAppManager; class SystemWebAppManager;
class WebAppAudioFocusIdMap; class WebAppAudioFocusIdMap;
class WebAppInstallManager; class WebAppInstallManager;
class WebAppPolicyManager;
class WebAppTabHelperBase; class WebAppTabHelperBase;
class WebAppUiManager; class WebAppUiManager;
// Forward declarations for new extension-independent subsystems. // Forward declarations for new extension-independent subsystems.
class WebAppDatabase;
class WebAppDatabaseFactory; class WebAppDatabaseFactory;
class WebAppDatabase;
class WebAppIconManager; class WebAppIconManager;
class WebAppSyncManager; class WebAppSyncManager;
// Forward declarations for legacy extension-based subsystems.
class WebAppPolicyManager;
// Connects Web App features, such as the installation of default and // Connects Web App features, such as the installation of default and
// policy-managed web apps, with Profiles (as WebAppProvider is a // policy-managed web apps, with Profiles (as WebAppProvider is a
// Profile-linked KeyedService) and their associated PrefService. // Profile-linked KeyedService) and their associated PrefService.
...@@ -73,7 +69,7 @@ class WebAppProvider : public WebAppProviderBase { ...@@ -73,7 +69,7 @@ class WebAppProvider : public WebAppProviderBase {
AppRegistrar& registrar() override; AppRegistrar& registrar() override;
InstallManager& install_manager() override; InstallManager& install_manager() override;
PendingAppManager& pending_app_manager() override; PendingAppManager& pending_app_manager() override;
WebAppPolicyManager* policy_manager() override; WebAppPolicyManager& policy_manager() override;
WebAppUiManager& ui_manager() override; WebAppUiManager& ui_manager() override;
WebAppDatabaseFactory& database_factory() { return *database_factory_; } WebAppDatabaseFactory& database_factory() { return *database_factory_; }
...@@ -112,23 +108,21 @@ class WebAppProvider : public WebAppProviderBase { ...@@ -112,23 +108,21 @@ class WebAppProvider : public WebAppProviderBase {
void CheckIsConnected() const; void CheckIsConnected() const;
// New extension-independent subsystems: // New extension-independent subsystems:
std::unique_ptr<WebAppAudioFocusIdMap> audio_focus_id_map_;
std::unique_ptr<WebAppDatabaseFactory> database_factory_; std::unique_ptr<WebAppDatabaseFactory> database_factory_;
std::unique_ptr<WebAppDatabase> database_; std::unique_ptr<WebAppDatabase> database_;
std::unique_ptr<WebAppIconManager> icon_manager_; std::unique_ptr<WebAppIconManager> icon_manager_;
std::unique_ptr<WebAppSyncManager> sync_manager_; std::unique_ptr<WebAppSyncManager> sync_manager_;
std::unique_ptr<WebAppUiManager> ui_manager_;
// New generalized subsystems: // Generalized subsystems:
std::unique_ptr<AppRegistrar> registrar_; std::unique_ptr<AppRegistrar> registrar_;
std::unique_ptr<ExternalWebAppManager> external_web_app_manager_;
std::unique_ptr<InstallFinalizer> install_finalizer_; std::unique_ptr<InstallFinalizer> install_finalizer_;
std::unique_ptr<WebAppInstallManager> install_manager_;
std::unique_ptr<PendingAppManager> pending_app_manager_; std::unique_ptr<PendingAppManager> pending_app_manager_;
std::unique_ptr<ExternalWebAppManager> external_web_app_manager_;
std::unique_ptr<SystemWebAppManager> system_web_app_manager_; std::unique_ptr<SystemWebAppManager> system_web_app_manager_;
std::unique_ptr<WebAppAudioFocusIdMap> audio_focus_id_map_;
// Legacy extension-based subsystems: std::unique_ptr<WebAppInstallManager> install_manager_;
std::unique_ptr<WebAppPolicyManager> web_app_policy_manager_; std::unique_ptr<WebAppPolicyManager> web_app_policy_manager_;
std::unique_ptr<WebAppUiManager> ui_manager_;
base::OneShotEvent on_registry_ready_; base::OneShotEvent on_registry_ready_;
......
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