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

Add the close menu item for extension apps and the Chrome app.

TODO: Add the close item for the new Web apps publisher.

BUG=1038487

Change-Id: Ie3063c6cc5bd4bee2f51c0117b832cc8411b06db
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2032460Reviewed-by: default avatarJeevan Shikaram <jshikaram@chromium.org>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Commit-Queue: Nancy Wang <nancylingwang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#737988}
parent 02bf1430
......@@ -679,6 +679,11 @@ void ExtensionApps::GetMenuModel(const std::string& app_id,
AddCommandItem(ash::OPTIONS, IDS_NEW_TAB_APP_OPTIONS, &menu_items);
}
if (menu_type == apps::mojom::MenuType::kShelf &&
!instance_registry_->GetWindows(app_id).empty()) {
AddCommandItem(ash::MENU_CLOSE, IDS_SHELF_CONTEXT_MENU_CLOSE, &menu_items);
}
const extensions::ManagementPolicy* policy =
extensions::ExtensionSystem::Get(profile_)->management_policy();
DCHECK(policy);
......
......@@ -27,6 +27,7 @@
#include "chrome/browser/ui/app_list/app_list_controller_delegate.h"
#include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h"
#include "chrome/browser/ui/app_list/extension_app_utils.h"
#include "chrome/browser/ui/ash/launcher/browser_shortcut_launcher_item_controller.h"
#include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h"
#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/chrome_pages.h"
......@@ -260,6 +261,13 @@ void AppServiceShelfContextMenu::OnGetMenuModel(
for (size_t i = index; i < menu_items->items.size(); i++) {
DCHECK_EQ(apps::mojom::MenuItemType::kCommand, menu_items->items[i]->type);
// For Chrome browser, add the close item before the app info item.
if (item().id.app_id == extension_misc::kChromeAppId &&
menu_items->items[i]->command_id == ash::SHOW_APP_INFO) {
BuildChromeAppMenu(menu_model.get());
}
AddContextMenuOption(
menu_model.get(),
static_cast<ash::CommandId>(menu_items->items[i]->command_id),
......@@ -351,6 +359,15 @@ void AppServiceShelfContextMenu::BuildCrostiniAppMenu(
}
}
void AppServiceShelfContextMenu::BuildChromeAppMenu(
ui::SimpleMenuModel* menu_model) {
if (!BrowserShortcutLauncherItemController::IsListOfActiveBrowserEmpty() ||
item().type == ash::TYPE_DIALOG || controller()->IsOpen(item().id)) {
AddContextMenuOption(menu_model, ash::MENU_CLOSE,
IDS_SHELF_CONTEXT_MENU_CLOSE);
}
}
void AppServiceShelfContextMenu::ShowAppInfo() {
if (app_type_ == apps::mojom::AppType::kArc) {
chrome::ShowAppManagementPage(controller()->profile(), item().id.app_id);
......
......@@ -57,6 +57,9 @@ class AppServiceShelfContextMenu : public ShelfContextMenu {
// id with the prefix "crostini:".
void BuildCrostiniAppMenu(ui::SimpleMenuModel* menu_model);
// Build additional Chrome app menu items.
void BuildChromeAppMenu(ui::SimpleMenuModel* menu_model);
void ShowAppInfo();
// Helpers to set the launch type.
......
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