Commit 1bb1f3c0 authored by Nicholas Hollingum's avatar Nicholas Hollingum Committed by Chromium LUCI CQ

borealis: add a context-menu item to shut down borealis

This item is shown for the borealis app icon and currently uses
pluginvm's strings until borealis ones can be approved.

Bug: b/172006764
Change-Id: I9036b1e555d8848d7082e753f3c6ce576f508f4d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2570475Reviewed-by: default avatarNancy Wang <nancylingwang@chromium.org>
Commit-Queue: Nic Hollingum <hollingum@google.com>
Cr-Commit-Position: refs/heads/master@{#833599}
parent d703cfb6
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include "chrome/browser/apps/app_service/app_icon_factory.h" #include "chrome/browser/apps/app_service/app_icon_factory.h"
#include "chrome/browser/apps/app_service/menu_util.h" #include "chrome/browser/apps/app_service/menu_util.h"
#include "chrome/browser/chromeos/borealis/borealis_app_launcher.h" #include "chrome/browser/chromeos/borealis/borealis_app_launcher.h"
#include "chrome/browser/chromeos/borealis/borealis_context_manager.h"
#include "chrome/browser/chromeos/borealis/borealis_features.h" #include "chrome/browser/chromeos/borealis/borealis_features.h"
#include "chrome/browser/chromeos/borealis/borealis_service.h" #include "chrome/browser/chromeos/borealis/borealis_service.h"
#include "chrome/browser/chromeos/borealis/borealis_util.h" #include "chrome/browser/chromeos/borealis/borealis_util.h"
...@@ -178,6 +179,16 @@ void BorealisApps::GetMenuModel(const std::string& app_id, ...@@ -178,6 +179,16 @@ void BorealisApps::GetMenuModel(const std::string& app_id,
GetMenuModelCallback callback) { GetMenuModelCallback callback) {
apps::mojom::MenuItemsPtr menu_items = apps::mojom::MenuItems::New(); apps::mojom::MenuItemsPtr menu_items = apps::mojom::MenuItems::New();
// TODO(b/170677773): Show shutdown in another app.
if (app_id == borealis::kBorealisAppId &&
borealis::BorealisService::GetForProfile(profile_)
->ContextManager()
.IsRunning()) {
// TODO(b/174705762): Use borealis-specific strings.
AddCommandItem(ash::SHUTDOWN_GUEST_OS, IDS_PLUGIN_VM_SHUT_DOWN_MENU_ITEM,
&menu_items);
}
if (ShouldAddCloseItem(app_id, menu_type, profile_)) { if (ShouldAddCloseItem(app_id, menu_type, profile_)) {
AddCommandItem(ash::MENU_CLOSE, IDS_SHELF_CONTEXT_MENU_CLOSE, &menu_items); AddCommandItem(ash::MENU_CLOSE, IDS_SHELF_CONTEXT_MENU_CLOSE, &menu_items);
} }
......
...@@ -11,6 +11,9 @@ ...@@ -11,6 +11,9 @@
#include "chrome/browser/apps/app_service/app_service_proxy.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/apps/app_service/app_service_proxy_factory.h"
#include "chrome/browser/apps/app_service/menu_util.h" #include "chrome/browser/apps/app_service/menu_util.h"
#include "chrome/browser/chromeos/borealis/borealis_service.h"
#include "chrome/browser/chromeos/borealis/borealis_shutdown_monitor.h"
#include "chrome/browser/chromeos/borealis/borealis_util.h"
#include "chrome/browser/chromeos/crosapi/browser_manager.h" #include "chrome/browser/chromeos/crosapi/browser_manager.h"
#include "chrome/browser/chromeos/crostini/crostini_manager.h" #include "chrome/browser/chromeos/crostini/crostini_manager.h"
#include "chrome/browser/chromeos/crostini/crostini_terminal.h" #include "chrome/browser/chromeos/crostini/crostini_terminal.h"
...@@ -138,6 +141,10 @@ void AppServiceContextMenu::ExecuteCommand(int command_id, int event_flags) { ...@@ -138,6 +141,10 @@ void AppServiceContextMenu::ExecuteCommand(int command_id, int event_flags) {
} else if (app_id() == plugin_vm::kPluginVmShelfAppId) { } else if (app_id() == plugin_vm::kPluginVmShelfAppId) {
plugin_vm::PluginVmManagerFactory::GetForProfile(profile()) plugin_vm::PluginVmManagerFactory::GetForProfile(profile())
->StopPluginVm(plugin_vm::kPluginVmName, /*force=*/false); ->StopPluginVm(plugin_vm::kPluginVmName, /*force=*/false);
} else if (app_id() == borealis::kBorealisAppId) {
borealis::BorealisService::GetForProfile(profile())
->ShutdownMonitor()
.ShutdownNow();
} else { } else {
LOG(ERROR) << "App " << app_id() LOG(ERROR) << "App " << app_id()
<< " should not have a shutdown guest OS command."; << " should not have a shutdown guest OS command.";
......
...@@ -13,6 +13,9 @@ ...@@ -13,6 +13,9 @@
#include "chrome/browser/apps/app_service/app_service_proxy_factory.h" #include "chrome/browser/apps/app_service/app_service_proxy_factory.h"
#include "chrome/browser/apps/app_service/menu_util.h" #include "chrome/browser/apps/app_service/menu_util.h"
#include "chrome/browser/chromeos/arc/app_shortcuts/arc_app_shortcuts_menu_builder.h" #include "chrome/browser/chromeos/arc/app_shortcuts/arc_app_shortcuts_menu_builder.h"
#include "chrome/browser/chromeos/borealis/borealis_service.h"
#include "chrome/browser/chromeos/borealis/borealis_shutdown_monitor.h"
#include "chrome/browser/chromeos/borealis/borealis_util.h"
#include "chrome/browser/chromeos/crosapi/browser_manager.h" #include "chrome/browser/chromeos/crosapi/browser_manager.h"
#include "chrome/browser/chromeos/crostini/crostini_manager.h" #include "chrome/browser/chromeos/crostini/crostini_manager.h"
#include "chrome/browser/chromeos/crostini/crostini_shelf_utils.h" #include "chrome/browser/chromeos/crostini/crostini_shelf_utils.h"
...@@ -150,6 +153,10 @@ void AppServiceShelfContextMenu::ExecuteCommand(int command_id, ...@@ -150,6 +153,10 @@ void AppServiceShelfContextMenu::ExecuteCommand(int command_id,
plugin_vm::PluginVmManagerFactory::GetForProfile( plugin_vm::PluginVmManagerFactory::GetForProfile(
controller()->profile()) controller()->profile())
->StopPluginVm(plugin_vm::kPluginVmName, /*force=*/false); ->StopPluginVm(plugin_vm::kPluginVmName, /*force=*/false);
} else if (item().id.app_id == borealis::kBorealisAppId) {
borealis::BorealisService::GetForProfile(controller()->profile())
->ShutdownMonitor()
.ShutdownNow();
} else { } else {
LOG(ERROR) << "App " << item().id.app_id LOG(ERROR) << "App " << item().id.app_id
<< " should not have a shutdown guest OS command."; << " should not have a shutdown guest OS command.";
......
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