Commit 2a539d17 authored by Manu Cornet's avatar Manu Cornet Committed by Commit Bot

CrOS: Merge |GetMenuModel| and |BuildMenu| methods in context menus.

Bug: 1011130
Change-Id: I4ac437f1e6e4bbfc831c50edb06359824b25bc62
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1935039Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Commit-Queue: Manu Cornet <manucornet@chromium.org>
Cr-Commit-Position: refs/heads/master@{#718899}
parent b5b97203
...@@ -34,12 +34,7 @@ ArcLauncherContextMenu::ArcLauncherContextMenu( ...@@ -34,12 +34,7 @@ ArcLauncherContextMenu::ArcLauncherContextMenu(
ArcLauncherContextMenu::~ArcLauncherContextMenu() = default; ArcLauncherContextMenu::~ArcLauncherContextMenu() = default;
void ArcLauncherContextMenu::GetMenuModel(GetMenuModelCallback callback) { void ArcLauncherContextMenu::GetMenuModel(GetMenuModelCallback callback) {
BuildMenu(std::make_unique<ui::SimpleMenuModel>(this), std::move(callback)); auto menu_model = std::make_unique<ui::SimpleMenuModel>(this);
}
void ArcLauncherContextMenu::BuildMenu(
std::unique_ptr<ui::SimpleMenuModel> menu_model,
GetMenuModelCallback callback) {
const ArcAppListPrefs* arc_list_prefs = const ArcAppListPrefs* arc_list_prefs =
ArcAppListPrefs::Get(controller()->profile()); ArcAppListPrefs::Get(controller()->profile());
DCHECK(arc_list_prefs); DCHECK(arc_list_prefs);
......
...@@ -24,8 +24,6 @@ class ArcLauncherContextMenu : public LauncherContextMenu { ...@@ -24,8 +24,6 @@ class ArcLauncherContextMenu : public LauncherContextMenu {
// LauncherContextMenu: // LauncherContextMenu:
void GetMenuModel(GetMenuModelCallback callback) override; void GetMenuModel(GetMenuModelCallback callback) override;
void BuildMenu(std::unique_ptr<ui::SimpleMenuModel> menu_model,
GetMenuModelCallback callback) override;
bool IsCommandIdEnabled(int command_id) const override; bool IsCommandIdEnabled(int command_id) const override;
void ExecuteCommand(int command_id, int event_flags) override; void ExecuteCommand(int command_id, int event_flags) override;
......
...@@ -54,12 +54,6 @@ CrostiniShelfContextMenu::~CrostiniShelfContextMenu() = default; ...@@ -54,12 +54,6 @@ CrostiniShelfContextMenu::~CrostiniShelfContextMenu() = default;
void CrostiniShelfContextMenu::GetMenuModel(GetMenuModelCallback callback) { void CrostiniShelfContextMenu::GetMenuModel(GetMenuModelCallback callback) {
auto menu_model = std::make_unique<ui::SimpleMenuModel>(this); auto menu_model = std::make_unique<ui::SimpleMenuModel>(this);
BuildMenu(std::move(menu_model), std::move(callback));
}
void CrostiniShelfContextMenu::BuildMenu(
std::unique_ptr<ui::SimpleMenuModel> menu_model,
GetMenuModelCallback callback) {
const crostini::CrostiniRegistryService* registry_service = const crostini::CrostiniRegistryService* registry_service =
crostini::CrostiniRegistryServiceFactory::GetForProfile( crostini::CrostiniRegistryServiceFactory::GetForProfile(
controller()->profile()); controller()->profile());
......
...@@ -18,8 +18,6 @@ class CrostiniShelfContextMenu : public LauncherContextMenu { ...@@ -18,8 +18,6 @@ class CrostiniShelfContextMenu : public LauncherContextMenu {
// LauncherContextMenu: // LauncherContextMenu:
void GetMenuModel(GetMenuModelCallback callback) override; void GetMenuModel(GetMenuModelCallback callback) override;
void BuildMenu(std::unique_ptr<ui::SimpleMenuModel> menu_model,
GetMenuModelCallback callback) override;
bool IsCommandIdEnabled(int command_id) const override; bool IsCommandIdEnabled(int command_id) const override;
void ExecuteCommand(int command_id, int event_flags) override; void ExecuteCommand(int command_id, int event_flags) override;
......
...@@ -68,12 +68,6 @@ ExtensionLauncherContextMenu::~ExtensionLauncherContextMenu() = default; ...@@ -68,12 +68,6 @@ ExtensionLauncherContextMenu::~ExtensionLauncherContextMenu() = default;
void ExtensionLauncherContextMenu::GetMenuModel(GetMenuModelCallback callback) { void ExtensionLauncherContextMenu::GetMenuModel(GetMenuModelCallback callback) {
auto menu_model = std::make_unique<ui::SimpleMenuModel>(this); auto menu_model = std::make_unique<ui::SimpleMenuModel>(this);
BuildMenu(std::move(menu_model), std::move(callback));
}
void ExtensionLauncherContextMenu::BuildMenu(
std::unique_ptr<ui::SimpleMenuModel> menu_model,
GetMenuModelCallback callback) {
Profile* profile = controller()->profile(); Profile* profile = controller()->profile();
const std::string app_id = item().id.app_id; const std::string app_id = item().id.app_id;
......
...@@ -25,8 +25,6 @@ class ExtensionLauncherContextMenu : public LauncherContextMenu { ...@@ -25,8 +25,6 @@ class ExtensionLauncherContextMenu : public LauncherContextMenu {
// LauncherContextMenu overrides: // LauncherContextMenu overrides:
void GetMenuModel(GetMenuModelCallback callback) override; void GetMenuModel(GetMenuModelCallback callback) override;
void BuildMenu(std::unique_ptr<ui::SimpleMenuModel> menu_model,
GetMenuModelCallback callback) override;
// ui::SimpleMenuModel::Delegate overrides: // ui::SimpleMenuModel::Delegate overrides:
bool IsCommandIdChecked(int command_id) const override; bool IsCommandIdChecked(int command_id) const override;
......
...@@ -24,12 +24,6 @@ InternalAppShelfContextMenu::InternalAppShelfContextMenu( ...@@ -24,12 +24,6 @@ InternalAppShelfContextMenu::InternalAppShelfContextMenu(
void InternalAppShelfContextMenu::GetMenuModel(GetMenuModelCallback callback) { void InternalAppShelfContextMenu::GetMenuModel(GetMenuModelCallback callback) {
auto menu_model = std::make_unique<ui::SimpleMenuModel>(this); auto menu_model = std::make_unique<ui::SimpleMenuModel>(this);
BuildMenu(std::move(menu_model), std::move(callback));
}
void InternalAppShelfContextMenu::BuildMenu(
std::unique_ptr<ui::SimpleMenuModel> menu_model,
GetMenuModelCallback callback) {
const bool app_is_open = controller()->IsOpen(item().id); const bool app_is_open = controller()->IsOpen(item().id);
if (!app_is_open) { if (!app_is_open) {
AddContextMenuOption(menu_model.get(), ash::MENU_OPEN_NEW, AddContextMenuOption(menu_model.get(), ash::MENU_OPEN_NEW,
......
...@@ -18,8 +18,6 @@ class InternalAppShelfContextMenu : public LauncherContextMenu { ...@@ -18,8 +18,6 @@ class InternalAppShelfContextMenu : public LauncherContextMenu {
// LauncherContextMenu: // LauncherContextMenu:
void GetMenuModel(GetMenuModelCallback callback) override; void GetMenuModel(GetMenuModelCallback callback) override;
void BuildMenu(std::unique_ptr<ui::SimpleMenuModel> menu_model,
GetMenuModelCallback callback) override;
void ExecuteCommand(int command_id, int event_flags) override; void ExecuteCommand(int command_id, int event_flags) override;
private: private:
......
...@@ -28,8 +28,6 @@ class LauncherContextMenu : public ui::SimpleMenuModel::Delegate { ...@@ -28,8 +28,6 @@ class LauncherContextMenu : public ui::SimpleMenuModel::Delegate {
using GetMenuModelCallback = using GetMenuModelCallback =
base::OnceCallback<void(std::unique_ptr<ui::SimpleMenuModel>)>; base::OnceCallback<void(std::unique_ptr<ui::SimpleMenuModel>)>;
virtual void GetMenuModel(GetMenuModelCallback callback) = 0; virtual void GetMenuModel(GetMenuModelCallback callback) = 0;
virtual void BuildMenu(std::unique_ptr<ui::SimpleMenuModel> menu_model,
GetMenuModelCallback callback) = 0;
// ui::SimpleMenuModel::Delegate overrides: // ui::SimpleMenuModel::Delegate overrides:
bool IsCommandIdChecked(int command_id) const override; bool IsCommandIdChecked(int command_id) const override;
......
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