Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(403)

Unified Diff: chrome/browser/ui/app_list/arc/arc_app_context_menu.cc

Issue 1756193008: Support uninstalling ARC app from Chrome launcher (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/app_list/arc/arc_app_context_menu.cc
diff --git a/chrome/browser/ui/app_list/arc/arc_app_context_menu.cc b/chrome/browser/ui/app_list/arc/arc_app_context_menu.cc
index 08fdea000bf872f3d495f98640cb37f4b7221df5..e63c9af2b5148a84aed5efec8f8d02b7269570a0 100644
--- a/chrome/browser/ui/app_list/arc/arc_app_context_menu.cc
+++ b/chrome/browser/ui/app_list/arc/arc_app_context_menu.cc
@@ -7,6 +7,7 @@
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/app_list/app_context_menu_delegate.h"
#include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h"
+#include "chrome/browser/ui/app_list/arc/arc_app_utils.h"
#include "chrome/grit/generated_resources.h"
ArcAppContextMenu::ArcAppContextMenu(
@@ -26,6 +27,10 @@ void ArcAppContextMenu::BuildMenu(ui::SimpleMenuModel* menu_model) {
menu_model->AddSeparator(ui::NORMAL_SEPARATOR);
// Create default items.
AppContextMenu::BuildMenu(menu_model);
+ if (CanBeUninstalled()) {
+ menu_model->AddSeparator(ui::NORMAL_SEPARATOR);
+ menu_model->AddItemWithStringId(UNINSTALL, IDS_APP_LIST_UNINSTALL_ITEM);
+ }
}
bool ArcAppContextMenu::IsCommandIdEnabled(int command_id) const {
@@ -38,8 +43,31 @@ bool ArcAppContextMenu::IsCommandIdEnabled(int command_id) const {
}
void ArcAppContextMenu::ExecuteCommand(int command_id, int event_flags) {
- if (command_id == LAUNCH_NEW)
- delegate()->ExecuteLaunchCommand(event_flags);
- else
- AppContextMenu::ExecuteCommand(command_id, event_flags);
+ switch (command_id) {
+ case LAUNCH_NEW:
+ delegate()->ExecuteLaunchCommand(event_flags);
+ break;
+ case UNINSTALL:
+ UninstallApp();
+ break;
+ default:
+ AppContextMenu::ExecuteCommand(command_id, event_flags);
+ }
+}
+
+void ArcAppContextMenu::UninstallApp() {
+ ArcAppListPrefs* arc_prefs = ArcAppListPrefs::Get(profile());
+ scoped_ptr<ArcAppListPrefs::AppInfo> app_info = arc_prefs->GetApp(app_id());
+ if (!app_info) {
+ LOG(ERROR) << "App being uninstalling does not exist";
+ return;
+ }
+ arc::UninstallApp(app_info->package_name,
+ base::Bind(&arc::OnUninstallAppResponse));
+}
+
+bool ArcAppContextMenu::CanBeUninstalled() const {
+ ArcAppListPrefs* arc_prefs = ArcAppListPrefs::Get(profile());
+ scoped_ptr<ArcAppListPrefs::AppInfo> app_info = arc_prefs->GetApp(app_id());
+ return app_info && app_info->ready && !app_info->sticky;
}

Powered by Google App Engine
This is Rietveld 408576698