Skip to content

Commit

Permalink
Implement the non mojom Uninstall for some publishers.
Browse files Browse the repository at this point in the history
BUG=1253250

Change-Id: If08e3b84465ebce369cf51207ced82b95342782f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3812331
Commit-Queue: Nancy Wang <nancylingwang@chromium.org>
Reviewed-by: Dominick Ng <dominickn@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1032425}
  • Loading branch information
Nancy Wang authored and Chromium LUCI CQ committed Aug 8, 2022
1 parent 741ecd0 commit f593e03
Show file tree
Hide file tree
Showing 9 changed files with 67 additions and 3 deletions.
8 changes: 7 additions & 1 deletion chrome/browser/apps/app_service/publishers/arc_apps.cc
Expand Up @@ -49,7 +49,6 @@
#include "components/app_restore/full_restore_save_handler.h"
#include "components/app_restore/full_restore_utils.h"
#include "components/arc/common/intent_helper/arc_intent_helper_package.h"
#include "components/services/app_service/public/cpp/app_types.h"
#include "components/services/app_service/public/cpp/icon_types.h"
#include "components/services/app_service/public/cpp/intent.h"
#include "components/services/app_service/public/cpp/intent_filter.h"
Expand Down Expand Up @@ -1016,6 +1015,13 @@ void ArcApps::SetPermission(const std::string& app_id,
}
}

void ArcApps::Uninstall(const std::string& app_id,
UninstallSource uninstall_source,
bool clear_site_data,
bool report_abuse) {
arc::UninstallArcApp(app_id, profile_);
}

void ArcApps::OnPreferredAppSet(
const std::string& app_id,
IntentFilterPtr intent_filter,
Expand Down
5 changes: 5 additions & 0 deletions chrome/browser/apps/app_service/publishers/arc_apps.h
Expand Up @@ -37,6 +37,7 @@
#include "components/arc/intent_helper/arc_intent_helper_observer.h"
#include "components/keyed_service/core/keyed_service.h"
#include "components/services/app_service/public/cpp/app_launch_util.h"
#include "components/services/app_service/public/cpp/app_types.h"
#include "components/services/app_service/public/cpp/instance_registry.h"
#include "components/services/app_service/public/cpp/intent.h"
#include "components/services/app_service/public/cpp/permission.h"
Expand Down Expand Up @@ -124,6 +125,10 @@ class ArcApps : public KeyedService,
int64_t display_id) override;
void SetPermission(const std::string& app_id,
PermissionPtr permission) override;
void Uninstall(const std::string& app_id,
UninstallSource uninstall_source,
bool clear_site_data,
bool report_abuse);
void OnPreferredAppSet(
const std::string& app_id,
IntentFilterPtr intent_filter,
Expand Down
10 changes: 9 additions & 1 deletion chrome/browser/apps/app_service/publishers/borealis_apps.cc
Expand Up @@ -24,7 +24,6 @@
#include "chrome/grit/chrome_unscaled_resources.h"
#include "chrome/grit/generated_resources.h"
#include "components/prefs/pref_service.h"
#include "components/services/app_service/public/cpp/app_types.h"
#include "components/services/app_service/public/cpp/permission_utils.h"
#include "components/services/app_service/public/cpp/publisher_base.h"
#include "ui/base/l10n/l10n_util.h"
Expand Down Expand Up @@ -343,6 +342,15 @@ void BorealisApps::SetPermission(const std::string& app_id,
permission_ptr->IsPermissionEnabled());
}

void BorealisApps::Uninstall(const std::string& app_id,
UninstallSource uninstall_source,
bool clear_site_data,
bool report_abuse) {
borealis::BorealisService::GetForProfile(profile_)
->AppUninstaller()
.Uninstall(app_id, base::DoNothing());
}

void BorealisApps::Connect(
mojo::PendingRemote<apps::mojom::Subscriber> subscriber_remote,
apps::mojom::ConnectOptionsPtr opts) {
Expand Down
5 changes: 5 additions & 0 deletions chrome/browser/apps/app_service/publishers/borealis_apps.h
Expand Up @@ -17,6 +17,7 @@
#include "chrome/browser/ash/guest_os/guest_os_registry_service.h"
#include "components/prefs/pref_change_registrar.h"
#include "components/services/app_service/public/cpp/app_launch_util.h"
#include "components/services/app_service/public/cpp/app_types.h"
#include "components/services/app_service/public/cpp/permission.h"
#include "components/services/app_service/public/cpp/publisher_base.h"
#include "components/services/app_service/public/mojom/app_service.mojom.h"
Expand Down Expand Up @@ -86,6 +87,10 @@ class BorealisApps
LaunchCallback callback) override;
void SetPermission(const std::string& app_id,
PermissionPtr permission) override;
void Uninstall(const std::string& app_id,
UninstallSource uninstall_source,
bool clear_site_data,
bool report_abuse);

// apps::PublisherBase overrides.
void Connect(mojo::PendingRemote<apps::mojom::Subscriber> subscriber_remote,
Expand Down
9 changes: 8 additions & 1 deletion chrome/browser/apps/app_service/publishers/crostini_apps.cc
Expand Up @@ -26,7 +26,6 @@
#include "chrome/grit/chrome_unscaled_resources.h"
#include "chrome/grit/generated_resources.h"
#include "components/prefs/pref_service.h"
#include "components/services/app_service/public/cpp/app_types.h"
#include "components/services/app_service/public/cpp/intent.h"
#include "components/services/app_service/public/cpp/intent_filter.h"
#include "components/services/app_service/public/cpp/intent_util.h"
Expand Down Expand Up @@ -176,6 +175,14 @@ void CrostiniApps::LaunchAppWithParams(AppLaunchParams&& params,
std::move(callback).Run(LaunchResult());
}

void CrostiniApps::Uninstall(const std::string& app_id,
UninstallSource uninstall_source,
bool clear_site_data,
bool report_abuse) {
crostini::CrostiniPackageService::GetForProfile(profile_)
->QueueUninstallApplication(app_id);
}

void CrostiniApps::Connect(
mojo::PendingRemote<apps::mojom::Subscriber> subscriber_remote,
apps::mojom::ConnectOptionsPtr opts) {
Expand Down
5 changes: 5 additions & 0 deletions chrome/browser/apps/app_service/publishers/crostini_apps.h
Expand Up @@ -18,6 +18,7 @@
#include "chrome/browser/ash/guest_os/guest_os_registry_service.h"
#include "components/keyed_service/core/keyed_service.h"
#include "components/services/app_service/public/cpp/app_launch_util.h"
#include "components/services/app_service/public/cpp/app_types.h"
#include "components/services/app_service/public/cpp/publisher_base.h"
#include "components/services/app_service/public/mojom/app_service.mojom.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
Expand Down Expand Up @@ -74,6 +75,10 @@ class CrostiniApps : public KeyedService,
base::OnceCallback<void(bool)> callback) override;
void LaunchAppWithParams(AppLaunchParams&& params,
LaunchCallback callback) override;
void Uninstall(const std::string& app_id,
UninstallSource uninstall_source,
bool clear_site_data,
bool report_abuse);

// apps::mojom::Publisher overrides.
void Connect(mojo::PendingRemote<apps::mojom::Subscriber> subscriber_remote,
Expand Down
11 changes: 11 additions & 0 deletions chrome/browser/apps/app_service/publishers/plugin_vm_apps.cc
Expand Up @@ -290,6 +290,17 @@ void PluginVmApps::SetPermission(const std::string& app_id,
permission_ptr->IsPermissionEnabled());
}

void PluginVmApps::Uninstall(const std::string& app_id,
UninstallSource uninstall_source,
bool clear_site_data,
bool report_abuse) {
guest_os::GuestOsRegistryServiceFactory::GetForProfile(profile_)
->ClearApplicationList(guest_os::VmType::PLUGIN_VM,
plugin_vm::kPluginVmName, "");
plugin_vm::PluginVmManagerFactory::GetForProfile(profile_)
->UninstallPluginVm();
}

void PluginVmApps::Launch(const std::string& app_id,
int32_t event_flags,
apps::mojom::LaunchSource launch_source,
Expand Down
5 changes: 5 additions & 0 deletions chrome/browser/apps/app_service/publishers/plugin_vm_apps.h
Expand Up @@ -16,6 +16,7 @@
#include "chrome/browser/ash/plugin_vm/plugin_vm_util.h"
#include "components/prefs/pref_change_registrar.h"
#include "components/services/app_service/public/cpp/app_launch_util.h"
#include "components/services/app_service/public/cpp/app_types.h"
#include "components/services/app_service/public/cpp/permission.h"
#include "components/services/app_service/public/cpp/publisher_base.h"
#include "components/services/app_service/public/mojom/app_service.mojom.h"
Expand Down Expand Up @@ -69,6 +70,10 @@ class PluginVmApps : public apps::PublisherBase,
LaunchCallback callback) override;
void SetPermission(const std::string& app_id,
PermissionPtr permission) override;
void Uninstall(const std::string& app_id,
UninstallSource uninstall_source,
bool clear_site_data,
bool report_abuse);

// apps::PublisherBase overrides.
void Connect(mojo::PendingRemote<apps::mojom::Subscriber> subscriber_remote,
Expand Down
12 changes: 12 additions & 0 deletions components/services/app_service/public/cpp/app_types.h
Expand Up @@ -91,6 +91,18 @@ ENUM(InstallSource,
kBrowser // Installed from browser.
)

// What caused the app to be uninstalled.
// This should be kept in sync with UninstallSource in enums.xml, so entries
// should not be re-ordered or removed. New entries should be added at the
// bottom.
ENUM(UninstallSource,
kUnknown,
kAppList, // Uninstall by the user from the App List (Launcher)
kAppManagement, // Uninstall by the user from the App Management page
kShelf, // Uninstall by the user from the Shelf
kMigration // Uninstall by app migration.
)

// The window mode that each app will open in.
ENUM(WindowMode,
kUnknown,
Expand Down

0 comments on commit f593e03

Please sign in to comment.