Commit d4c9b25b authored by Timothy Loh's avatar Timothy Loh Committed by Commit Bot

Add a basic context menu to Crostini app launcher items

This patch adds a context menu for Crostini app launcher items, of which
the only entry is "Pin to shelf" (or Unpin), inherited from the default
context menu -- note that clicking pinned entries currently does nothing
and the shelf icon is missing. Eventually we'd like to support also
"App info" and "Uninstall" entries.

Bug: 824549
Change-Id: Iee3038707b67232f6d813ecca5b675df973a86e7
Reviewed-on: https://chromium-review.googlesource.com/1006564
Commit-Queue: Timothy Loh <timloh@chromium.org>
Reviewed-by: default avatarNicholas Verne <nverne@chromium.org>
Cr-Commit-Position: refs/heads/master@{#550054}
parent b1867170
......@@ -3624,6 +3624,8 @@ split_static_library("ui") {
"app_list/arc/arc_vpn_provider_manager.h",
"app_list/arc/arc_vpn_provider_manager_factory.cc",
"app_list/arc/arc_vpn_provider_manager_factory.h",
"app_list/crostini/crostini_app_context_menu.cc",
"app_list/crostini/crostini_app_context_menu.h",
"app_list/crostini/crostini_app_item.cc",
"app_list/crostini/crostini_app_item.h",
"app_list/crostini/crostini_app_model_builder.cc",
......
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/ui/app_list/crostini/crostini_app_context_menu.h"
CrostiniAppContextMenu::CrostiniAppContextMenu(
Profile* profile,
const std::string& app_id,
AppListControllerDelegate* controller)
: app_list::AppContextMenu(nullptr, profile, app_id, controller) {}
CrostiniAppContextMenu::~CrostiniAppContextMenu() = default;
// TODO(timloh): Add support for "App Info", "Uninstall", and possibly actions
// defined in .desktop files.
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_UI_APP_LIST_CROSTINI_CROSTINI_APP_CONTEXT_MENU_H_
#define CHROME_BROWSER_UI_APP_LIST_CROSTINI_CROSTINI_APP_CONTEXT_MENU_H_
#include <string>
#include "base/macros.h"
#include "chrome/browser/ui/app_list/app_context_menu.h"
class AppListControllerDelegate;
class Profile;
class CrostiniAppContextMenu : public app_list::AppContextMenu {
public:
CrostiniAppContextMenu(Profile* profile,
const std::string& app_id,
AppListControllerDelegate* controller);
~CrostiniAppContextMenu() override;
private:
DISALLOW_COPY_AND_ASSIGN(CrostiniAppContextMenu);
};
#endif // CHROME_BROWSER_UI_APP_LIST_CROSTINI_CROSTINI_APP_CONTEXT_MENU_H_
......@@ -9,6 +9,7 @@
#include "chrome/browser/chromeos/crostini/crostini_registry_service.h"
#include "chrome/browser/chromeos/crostini/crostini_registry_service_factory.h"
#include "chrome/browser/ui/app_list/app_list_controller_delegate.h"
#include "chrome/browser/ui/app_list/crostini/crostini_app_context_menu.h"
#include "chrome/browser/ui/app_list/crostini/crostini_installer_view.h"
#include "ui/gfx/image/image_skia.h"
......@@ -54,3 +55,13 @@ void CrostiniAppItem::Activate(int event_flags) {
CrostiniInstallerView::Show(this, profile());
}
ui::MenuModel* CrostiniAppItem::GetContextMenuModel() {
context_menu_.reset(
new CrostiniAppContextMenu(profile(), id(), GetController()));
return context_menu_->GetMenuModel();
}
app_list::AppContextMenu* CrostiniAppItem::GetAppContextMenu() {
return context_menu_.get();
}
......@@ -7,6 +7,8 @@
#include "chrome/browser/ui/app_list/chrome_app_list_item.h"
class CrostiniAppContextMenu;
namespace gfx {
class ImageSkia;
}
......@@ -25,6 +27,10 @@ class CrostiniAppItem : public ChromeAppListItem {
// ChromeAppListItem:
void Activate(int event_flags) override;
const char* GetItemType() const override;
ui::MenuModel* GetContextMenuModel() override;
app_list::AppContextMenu* GetAppContextMenu() override;
std::unique_ptr<CrostiniAppContextMenu> context_menu_;
DISALLOW_COPY_AND_ASSIGN(CrostiniAppItem);
};
......
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