Commit c7d42e29 authored by nancy's avatar nancy Committed by Commit Bot

Use AppService to uninstall apps on Chrome OS.

BUG=1009248

Change-Id: I659067359fbdb5fb430f9dcb60a0dbee1fcf6184
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1864496
Commit-Queue: Nancy Wang <nancylingwang@chromium.org>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#708514}
parent 8498aaaf
......@@ -11,6 +11,8 @@
#include "base/feature_list.h"
#include "base/metrics/histogram_macros.h"
#include "build/build_config.h"
#include "chrome/browser/apps/app_service/app_service_proxy.h"
#include "chrome/browser/apps/app_service/app_service_proxy_factory.h"
#include "chrome/browser/extensions/extension_util.h"
#include "chrome/browser/extensions/install_tracker_factory.h"
#include "chrome/browser/extensions/launch_util.h"
......@@ -127,10 +129,10 @@ void AppListControllerDelegate::DoShowAppInfoFlow(
void AppListControllerDelegate::UninstallApp(Profile* profile,
const std::string& app_id) {
// ExtensionUninstall deletes itself when done or aborted.
ExtensionUninstaller* uninstaller =
new ExtensionUninstaller(profile, app_id, GetAppListWindow());
uninstaller->Run();
apps::AppServiceProxy* proxy =
apps::AppServiceProxyFactory::GetForProfile(profile);
DCHECK(proxy);
proxy->Uninstall(app_id, GetAppListWindow());
}
bool AppListControllerDelegate::IsAppFromWebStore(Profile* profile,
......
......@@ -9,6 +9,8 @@
#include "ash/public/cpp/tablet_mode.h"
#include "base/bind.h"
#include "base/feature_list.h"
#include "chrome/browser/apps/app_service/app_service_proxy.h"
#include "chrome/browser/apps/app_service/app_service_proxy_factory.h"
#include "chrome/browser/chromeos/arc/app_shortcuts/arc_app_shortcuts_menu_builder.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/app_list/app_context_menu_delegate.h"
......@@ -89,7 +91,11 @@ void ArcAppContextMenu::ExecuteCommand(int command_id, int event_flags) {
if (command_id == ash::LAUNCH_NEW) {
delegate()->ExecuteLaunchCommand(event_flags);
} else if (command_id == ash::UNINSTALL) {
arc::ShowArcAppUninstallDialog(profile(), controller(), app_id());
apps::AppServiceProxy* proxy =
apps::AppServiceProxyFactory::GetForProfile(profile());
DCHECK(proxy);
proxy->Uninstall(app_id(),
controller() ? controller()->GetAppListWindow() : nullptr);
} else if (command_id == ash::SHOW_APP_INFO) {
ShowPackageInfo();
} else if (command_id >= ash::LAUNCH_APP_SHORTCUT_FIRST &&
......
......@@ -6,6 +6,8 @@
#include "ash/public/cpp/app_menu_constants.h"
#include "base/bind_helpers.h"
#include "chrome/browser/apps/app_service/app_service_proxy.h"
#include "chrome/browser/apps/app_service/app_service_proxy_factory.h"
#include "chrome/browser/chromeos/crostini/crostini_manager.h"
#include "chrome/browser/chromeos/crostini/crostini_util.h"
#include "chrome/grit/generated_resources.h"
......@@ -31,11 +33,14 @@ bool CrostiniAppContextMenu::IsCommandIdEnabled(int command_id) const {
void CrostiniAppContextMenu::ExecuteCommand(int command_id, int event_flags) {
switch (command_id) {
case ash::UNINSTALL:
case ash::UNINSTALL: {
DCHECK_NE(app_id(), crostini::kCrostiniTerminalId);
crostini::ShowCrostiniAppUninstallerView(profile(), app_id());
apps::AppServiceProxy* proxy =
apps::AppServiceProxyFactory::GetForProfile(profile());
DCHECK(proxy);
proxy->Uninstall(app_id(), nullptr /* parent_window */);
return;
}
case ash::STOP_APP:
if (app_id() == crostini::kCrostiniTerminalId) {
crostini::CrostiniManager::GetForProfile(profile())->StopVm(
......
......@@ -67,16 +67,10 @@ void ArcLauncherContextMenu::ExecuteCommand(int command_id, int event_flags) {
return;
}
if (command_id == ash::UNINSTALL) {
if (base::FeatureList::IsEnabled(features::kAppServiceShelf)) {
apps::AppServiceProxy* proxy =
apps::AppServiceProxyFactory::GetForProfile(controller()->profile());
DCHECK(proxy);
proxy->Uninstall(item().id.app_id, nullptr /* parent_window */);
return;
}
arc::ShowArcAppUninstallDialog(controller()->profile(),
nullptr /* controller */, item().id.app_id);
apps::AppServiceProxy* proxy =
apps::AppServiceProxyFactory::GetForProfile(controller()->profile());
DCHECK(proxy);
proxy->Uninstall(item().id.app_id, nullptr /* parent_window */);
return;
}
......
......@@ -10,6 +10,8 @@
#include "ash/public/cpp/app_menu_constants.h"
#include "ash/public/cpp/shelf_item.h"
#include "base/bind_helpers.h"
#include "chrome/browser/apps/app_service/app_service_proxy.h"
#include "chrome/browser/apps/app_service/app_service_proxy_factory.h"
#include "chrome/browser/chromeos/crostini/crostini_manager.h"
#include "chrome/browser/chromeos/crostini/crostini_registry_service.h"
#include "chrome/browser/chromeos/crostini/crostini_registry_service_factory.h"
......@@ -68,11 +70,14 @@ bool CrostiniShelfContextMenu::IsCommandIdEnabled(int command_id) const {
void CrostiniShelfContextMenu::ExecuteCommand(int command_id, int event_flags) {
switch (command_id) {
case ash::UNINSTALL:
case ash::UNINSTALL: {
DCHECK_NE(item().id.app_id, crostini::kCrostiniTerminalId);
crostini::ShowCrostiniAppUninstallerView(controller()->profile(),
item().id.app_id);
apps::AppServiceProxy* proxy =
apps::AppServiceProxyFactory::GetForProfile(controller()->profile());
DCHECK(proxy);
proxy->Uninstall(item().id.app_id, nullptr /* parent_window */);
return;
}
case ash::STOP_APP:
if (item().id.app_id == crostini::kCrostiniTerminalId) {
crostini::CrostiniManager::GetForProfile(controller()->profile())
......
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