Change WebAppSettingsUI to use WebAppInstallManagerObserver.
WebAppSettingsUI used the old AppRegistrarObserver and will now move
WebAppInstallManagerObserver. This is part of phase 2 of the refactoring
described in the attached design doc.
Bug: 1275945
Change-Id: I2333d71738c03a6e2e41f0dda999ab51f2111d8a
Doc: https://docs.google.com/document/d/1C3Dt4ypS07KOtyYsYZct23JzJ1BRBkWKqiIbhjF5bBQ/edit?usp=sharing
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3461651
Reviewed-by: Daniel Murphy <dmurph@chromium.org>
Commit-Queue: Simon Hangl <simonha@google.com>
Cr-Commit-Position: refs/heads/main@{#970845}
diff --git a/chrome/browser/ui/webui/app_settings/web_app_settings_ui.cc b/chrome/browser/ui/webui/app_settings/web_app_settings_ui.cc
index 1d7c187..77ec0588 100644
--- a/chrome/browser/ui/webui/app_settings/web_app_settings_ui.cc
+++ b/chrome/browser/ui/webui/app_settings/web_app_settings_ui.cc
@@ -85,7 +85,7 @@
content::WebUIDataSource::Add(profile, html_source);
auto* provider = web_app::WebAppProvider::GetForWebApps(profile);
- registrar_observation_.Observe(&provider->registrar());
+ install_manager_observation_.Observe(&provider->install_manager());
}
void WebAppSettingsUI::BindInterface(
@@ -110,6 +110,10 @@
web_contents->ClosePage();
}
+void WebAppSettingsUI::OnWebAppInstallManagerDestroyed() {
+ install_manager_observation_.Reset();
+}
+
WebAppSettingsUI::~WebAppSettingsUI() = default;
WEB_UI_CONTROLLER_TYPE_IMPL(WebAppSettingsUI)
diff --git a/chrome/browser/ui/webui/app_settings/web_app_settings_ui.h b/chrome/browser/ui/webui/app_settings/web_app_settings_ui.h
index c7c9063..5c06ab3 100644
--- a/chrome/browser/ui/webui/app_settings/web_app_settings_ui.h
+++ b/chrome/browser/ui/webui/app_settings/web_app_settings_ui.h
@@ -10,13 +10,14 @@
#include "chrome/browser/ui/webui/app_management/app_management_page_handler_factory.h"
#include "chrome/browser/web_applications/app_registrar_observer.h"
#include "chrome/browser/web_applications/web_app_id.h"
-#include "chrome/browser/web_applications/web_app_registrar.h"
+#include "chrome/browser/web_applications/web_app_install_manager.h"
+#include "chrome/browser/web_applications/web_app_install_manager_observer.h"
#include "ui/webui/mojo_web_ui_controller.h"
#include "ui/webui/resources/cr_components/app_management/app_management.mojom-forward.h"
// The WebUI for chrome://app-settings
class WebAppSettingsUI : public ui::MojoWebUIController,
- public web_app::AppRegistrarObserver {
+ public web_app::WebAppInstallManagerObserver {
public:
explicit WebAppSettingsUI(content::WebUI* web_ui);
@@ -34,15 +35,16 @@
mojo::PendingReceiver<app_management::mojom::PageHandlerFactory>
receiver);
- // AppRegistrarObserver:
+ // WebAppInstallManagerObserver:
void OnWebAppUninstalled(const web_app::AppId& app_id) override;
+ void OnWebAppInstallManagerDestroyed() override;
private:
std::unique_ptr<AppManagementPageHandlerFactory>
app_management_page_handler_factory_;
- base::ScopedObservation<web_app::WebAppRegistrar,
- web_app::AppRegistrarObserver>
- registrar_observation_{this};
+ base::ScopedObservation<web_app::WebAppInstallManager,
+ web_app::WebAppInstallManagerObserver>
+ install_manager_observation_{this};
WEB_UI_CONTROLLER_TYPE_DECL();
};