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

AppService: Clean up ExtensionApps class. It manages kExtension apps only.

Previous cleanup CL:
https://chromium-review.googlesource.com/c/chromium/src/+/2520476

- app_type() and app_type_ is always kExtension.
- Exclude from_bookmark() extensions.

Bug: 1065748
Change-Id: I39301a2537c2e77633ef85067f6bd81f9adacecc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2522831
Commit-Queue: Alexey Baskakov <loyso@chromium.org>
Reviewed-by: default avatarNancy Wang <nancylingwang@chromium.org>
Reviewed-by: default avatarGiovanni Ortuño Urquidi <ortuno@chromium.org>
Cr-Commit-Position: refs/heads/master@{#827499}
parent 6daa281f
......@@ -175,8 +175,7 @@ void AppServiceProxy::Initialize() {
}
crostini_apps_ = std::make_unique<CrostiniApps>(app_service_, profile_);
extension_apps_ = std::make_unique<ExtensionAppsChromeOs>(
app_service_, profile_, apps::mojom::AppType::kExtension,
&instance_registry_);
app_service_, profile_, &instance_registry_);
if (!g_omit_plugin_vm_apps_for_testing_) {
plugin_vm_apps_ = std::make_unique<PluginVmApps>(app_service_, profile_);
}
......@@ -193,8 +192,7 @@ void AppServiceProxy::Initialize() {
&instance_registry_);
#else
web_apps_ = std::make_unique<WebApps>(app_service_, profile_);
extension_apps_ = std::make_unique<ExtensionApps>(
app_service_, profile_, apps::mojom::AppType::kExtension);
extension_apps_ = std::make_unique<ExtensionApps>(app_service_, profile_);
#endif
// Asynchronously add app icon source, so we don't do too much work in the
......
......@@ -443,8 +443,6 @@ class AppServiceProxy : public KeyedService,
base::UniquePtrComparator>;
UninstallDialogs uninstall_dialogs_;
#else
// TODO(crbug.com/877898): Erase extension_web_apps_ when BMO is on.
std::unique_ptr<ExtensionApps> extension_web_apps_;
std::unique_ptr<WebApps> web_apps_;
std::unique_ptr<ExtensionApps> extension_apps_;
#endif
......
......@@ -12,9 +12,8 @@ namespace apps {
ExtensionApps::ExtensionApps(
const mojo::Remote<apps::mojom::AppService>& app_service,
Profile* profile,
apps::mojom::AppType app_type)
: ExtensionAppsBase(app_service, profile, app_type) {}
Profile* profile)
: ExtensionAppsBase(app_service, profile) {}
ExtensionApps::~ExtensionApps() = default;
......@@ -34,15 +33,7 @@ bool ExtensionApps::Accepts(const extensions::Extension* extension) {
return false;
}
switch (app_type()) {
case apps::mojom::AppType::kExtension:
return !extension->from_bookmark();
case apps::mojom::AppType::kWeb:
return extension->from_bookmark();
default:
NOTREACHED();
return false;
}
return !extension->from_bookmark();
}
bool ExtensionApps::ShouldShownInLauncher(
......
......@@ -32,8 +32,7 @@ namespace apps {
class ExtensionApps : public apps::ExtensionAppsBase {
public:
ExtensionApps(const mojo::Remote<apps::mojom::AppService>& app_service,
Profile* profile,
apps::mojom::AppType app_type);
Profile* profile);
~ExtensionApps() override;
ExtensionApps(const ExtensionApps&) = delete;
......
......@@ -14,12 +14,6 @@
#include "chrome/browser/apps/app_service/app_icon_factory.h"
#include "chrome/browser/apps/app_service/app_launch_params.h"
#include "chrome/browser/apps/app_service/icon_key_util.h"
#include "chrome/browser/ui/web_applications/web_app_launch_manager.h"
#include "chrome/browser/web_applications/components/app_registrar.h"
#include "chrome/browser/web_applications/components/app_registrar_observer.h"
#include "chrome/browser/web_applications/components/web_app_id.h"
#include "components/content_settings/core/browser/content_settings_observer.h"
#include "components/content_settings/core/browser/host_content_settings_map.h"
#include "components/services/app_service/public/cpp/publisher_base.h"
#include "components/services/app_service/public/mojom/app_service.mojom.h"
#include "components/services/app_service/public/mojom/types.mojom.h"
......@@ -53,13 +47,10 @@ class ExtensionAppsEnableFlow;
// See components/services/app_service/README.md.
class ExtensionAppsBase : public apps::PublisherBase,
public extensions::ExtensionPrefsObserver,
public extensions::ExtensionRegistryObserver,
public content_settings::Observer,
public web_app::AppRegistrarObserver {
public extensions::ExtensionRegistryObserver {
public:
ExtensionAppsBase(const mojo::Remote<apps::mojom::AppService>& app_service,
Profile* profile,
apps::mojom::AppType app_type);
Profile* profile);
~ExtensionAppsBase() override;
ExtensionAppsBase(const ExtensionAppsBase&) = delete;
......@@ -103,8 +94,6 @@ class ExtensionAppsBase : public apps::PublisherBase,
Profile* profile() const { return profile_; }
apps::mojom::AppType app_type() { return app_type_; }
base::WeakPtr<ExtensionAppsBase> GetWeakPtr() {
return weak_factory_.GetWeakPtr();
}
......@@ -143,19 +132,12 @@ class ExtensionAppsBase : public apps::PublisherBase,
apps::mojom::IntentPtr intent,
apps::mojom::LaunchSource launch_source,
int64_t display_id) override;
void SetPermission(const std::string& app_id,
apps::mojom::PermissionPtr permission) override;
void Uninstall(const std::string& app_id,
apps::mojom::UninstallSource uninstall_source,
bool clear_site_data,
bool report_abuse) override;
void OpenNativeSettings(const std::string& app_id) override;
// content_settings::Observer overrides.
void OnContentSettingChanged(const ContentSettingsPattern& primary_pattern,
const ContentSettingsPattern& secondary_pattern,
ContentSettingsType content_type) override;
// extensions::ExtensionPrefsObserver overrides.
void OnExtensionLastLaunchTimeChanged(
const std::string& app_id,
......@@ -163,11 +145,6 @@ class ExtensionAppsBase : public apps::PublisherBase,
void OnExtensionPrefsWillBeDestroyed(
extensions::ExtensionPrefs* prefs) override;
// web_app::AppRegistrarObserver:
void OnAppRegistrarDestroyed() override;
void OnWebAppLocallyInstalledStateChanged(const web_app::AppId& app_id,
bool is_locally_installed) override;
// extensions::ExtensionRegistryObserver overrides.
void OnExtensionLoaded(content::BrowserContext* browser_context,
const extensions::Extension* extension) override;
......@@ -178,9 +155,6 @@ class ExtensionAppsBase : public apps::PublisherBase,
const extensions::Extension* extension,
bool is_update) override;
// Function called when SystemWebAppManager::on_apps_synchronized() runs.
void OnSystemWebAppsInstalled();
// Checks if extension is disabled and if enable flow should be started.
// Returns true if extension enable flow is started or there is already one
// running, and run |callback| to launch the app.
......@@ -194,8 +168,6 @@ class ExtensionAppsBase : public apps::PublisherBase,
static bool ShouldShow(const extensions::Extension* extension,
Profile* profile);
void PopulatePermissions(const extensions::Extension* extension,
std::vector<mojom::PermissionPtr>* target);
void PopulateIntentFilters(const base::Optional<GURL>& app_scope,
std::vector<mojom::IntentFilterPtr>* target);
virtual apps::mojom::AppPtr Convert(const extensions::Extension* extension,
......@@ -209,8 +181,6 @@ class ExtensionAppsBase : public apps::PublisherBase,
Profile* const profile_;
const apps::mojom::AppType app_type_;
apps_util::IncrementingIconKeyFactory icon_key_factory_;
ScopedObserver<extensions::ExtensionPrefs, extensions::ExtensionPrefsObserver>
......@@ -218,10 +188,6 @@ class ExtensionAppsBase : public apps::PublisherBase,
ScopedObserver<extensions::ExtensionRegistry,
extensions::ExtensionRegistryObserver>
registry_observer_{this};
ScopedObserver<HostContentSettingsMap, content_settings::Observer>
content_settings_observer_{this};
ScopedObserver<web_app::AppRegistrar, web_app::AppRegistrarObserver>
app_registrar_observer_{this};
using EnableFlowPtr = std::unique_ptr<ExtensionAppsEnableFlow>;
std::map<std::string, EnableFlowPtr> enable_flow_map_;
......@@ -229,9 +195,6 @@ class ExtensionAppsBase : public apps::PublisherBase,
// app_service_ is owned by the object that owns this object.
apps::mojom::AppService* app_service_;
// TODO(crbug.com/1061843): Remove web_app_launch_manager_ when BMO launches.
std::unique_ptr<web_app::WebAppLaunchManager> web_app_launch_manager_;
base::WeakPtrFactory<ExtensionAppsBase> weak_factory_{this};
};
......
......@@ -54,7 +54,6 @@ class ExtensionAppsChromeOs : public ExtensionAppsBase,
ExtensionAppsChromeOs(
const mojo::Remote<apps::mojom::AppService>& app_service,
Profile* profile,
apps::mojom::AppType app_type,
apps::InstanceRegistry* instance_registry);
~ExtensionAppsChromeOs() override;
......@@ -149,10 +148,6 @@ class ExtensionAppsChromeOs : public ExtensionAppsBase,
void GetMenuModelForChromeBrowserApp(apps::mojom::MenuType menu_type,
GetMenuModelCallback callback);
// web_app::AppRegistrarObserver overrides.
void OnWebAppDisabledStateChanged(const std::string& app_id,
bool is_disabled) override;
apps::InstanceRegistry* instance_registry_;
ScopedObserver<extensions::AppWindowRegistry,
extensions::AppWindowRegistry::Observer>
......
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