#ifndef CHROME_BROWSER_DOWNLOAD_DOWNLOAD_UI_CONTEXT_MENU_H_
#define CHROME_BROWSER_DOWNLOAD_DOWNLOAD_UI_CONTEXT_MENU_H_
#include <memory>
#include <string>
#include "base/gtest_prod_util.h"
#include "base/memory/weak_ptr.h"
#include "build/build_config.h"
#include "chrome/browser/download/download_commands.h"
#include "chrome/browser/download/download_ui_model.h"
#include "components/download/public/common/download_item.h"
#include "ui/menus/simple_menu_model.h"
class DownloadUiContextMenu : public ui::SimpleMenuModel::Delegate {
public:
DownloadUiContextMenu(const DownloadUiContextMenu&) = delete;
DownloadUiContextMenu& operator=(const DownloadUiContextMenu&) = delete;
~DownloadUiContextMenu() override;
void OnDownloadDestroyed();
protected:
explicit DownloadUiContextMenu(base::WeakPtr<DownloadUIModel> download);
ui::SimpleMenuModel* GetMenuModel();
bool IsCommandIdEnabled(int command_id) const override;
bool IsCommandIdChecked(int command_id) const override;
bool IsCommandIdVisible(int command_id) const override;
void ExecuteCommand(int command_id, int event_flags) override;
bool IsItemForCommandIdDynamic(int command_id) const override;
std::u16string GetLabelForCommandId(int command_id) const override;
DownloadUIModel* GetDownload() { return download_.get(); }
private:
friend class DownloadUiContextMenuTest;
FRIEND_TEST_ALL_PREFIXES(DownloadUiContextMenuTest,
InvalidDownloadWontCrashContextMenu);
FRIEND_TEST_ALL_PREFIXES(DownloadUiContextMenuTest, RecordCommandsEnabled);
void DetachFromDownloadItem();
ui::SimpleMenuModel* GetInProgressMenuModel(bool is_download);
ui::SimpleMenuModel* GetInProgressPausedMenuModel(bool is_download);
ui::SimpleMenuModel* GetFinishedMenuModel(bool is_download);
ui::SimpleMenuModel* GetInterruptedMenuModel(bool is_download);
ui::SimpleMenuModel* GetMaybeMaliciousMenuModel(bool is_download);
ui::SimpleMenuModel* GetMaliciousMenuModel(bool is_download);
ui::SimpleMenuModel* GetDeepScanningMenuModel(bool is_download);
ui::SimpleMenuModel* GetInsecureDownloadMenuModel();
void AddAutoOpenToMenu(ui::SimpleMenuModel* model);
void RecordCommandsEnabled(ui::SimpleMenuModel* model);
std::unique_ptr<ui::SimpleMenuModel> in_progress_download_menu_model_;
std::unique_ptr<ui::SimpleMenuModel> in_progress_download_paused_menu_model_;
std::unique_ptr<ui::SimpleMenuModel> finished_download_menu_model_;
std::unique_ptr<ui::SimpleMenuModel> interrupted_download_menu_model_;
std::unique_ptr<ui::SimpleMenuModel> maybe_malicious_download_menu_model_;
std::unique_ptr<ui::SimpleMenuModel> malicious_download_menu_model_;
std::unique_ptr<ui::SimpleMenuModel> deep_scanning_menu_model_;
std::unique_ptr<ui::SimpleMenuModel> insecure_download_menu_model_;
bool download_commands_enabled_recorded_ = false;
base::WeakPtr<DownloadUIModel> download_;
std::unique_ptr<DownloadCommands> download_commands_;
};
#endif