blob: 350ac9dba84f8d89cd2399d87c522f048a128fdb [file] [log] [blame]
// Copyright 2013 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 <memory>
#include <string>
#include "ash/public/cpp/app_menu_constants.h"
#include "base/callback.h"
#include "base/macros.h"
#include "ui/base/models/simple_menu_model.h"
class AppListControllerDelegate;
class Profile;
namespace app_list {
class AppContextMenuDelegate;
// Base class of all context menus in app list view.
class AppContextMenu : public ui::SimpleMenuModel::Delegate {
AppContextMenu(AppContextMenuDelegate* delegate,
Profile* profile,
const std::string& app_id,
AppListControllerDelegate* controller);
~AppContextMenu() override;
using GetMenuModelCallback =
virtual void GetMenuModel(GetMenuModelCallback callback);
// ui::SimpleMenuModel::Delegate overrides:
bool IsItemForCommandIdDynamic(int command_id) const override;
base::string16 GetLabelForCommandId(int command_id) const override;
bool IsCommandIdChecked(int command_id) const override;
bool IsCommandIdEnabled(int command_id) const override;
void ExecuteCommand(int command_id, int event_flags) override;
bool GetIconForCommandId(int command_id, gfx::Image* icon) const override;
// Creates default items, derived class may override to add their specific
// items.
virtual void BuildMenu(ui::SimpleMenuModel* menu_model);
// Helper that toggles pinning state of provided app.
void TogglePin(const std::string& shelf_app_id);
// Helper method to add touchable or normal context menu options.
void AddContextMenuOption(ui::SimpleMenuModel* menu_model,
ash::CommandId command_id,
int string_id);
// Helper method to get the gfx::VectorIcon for a |command_id|. Returns an
// empty gfx::VectorIcon if there is no icon for this |command_id|.
const gfx::VectorIcon& GetMenuItemVectorIcon(int command_id,
int string_id) const;
const std::string& app_id() const { return app_id_; }
Profile* profile() const { return profile_; }
AppContextMenuDelegate* delegate() const { return delegate_; }
AppListControllerDelegate* controller() const { return controller_; }
AppContextMenuDelegate* delegate_;
Profile* profile_;
const std::string app_id_;
AppListControllerDelegate* controller_;
} // namespace app_list