Switch global error menu icon to vectorized MD asset
[chromium-blink-merge.git] / chrome / browser / download / download_shelf_context_menu.h
blob51193596d2e488002f42df534595aa09b15a9b8d
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_DOWNLOAD_DOWNLOAD_SHELF_CONTEXT_MENU_H_
6 #define CHROME_BROWSER_DOWNLOAD_DOWNLOAD_SHELF_CONTEXT_MENU_H_
8 #include "base/basictypes.h"
9 #include "base/compiler_specific.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "base/strings/string16.h"
12 #include "chrome/browser/download/download_commands.h"
13 #include "content/public/browser/download_item.h"
14 #include "ui/base/models/simple_menu_model.h"
16 namespace content {
17 class PageNavigator;
20 // This class is responsible for the download shelf context menu. Platform
21 // specific subclasses are responsible for creating and running the menu.
23 // The DownloadItem corresponding to the context menu is observed for removal or
24 // destruction.
25 class DownloadShelfContextMenu : public ui::SimpleMenuModel::Delegate,
26 public content::DownloadItem::Observer {
27 public:
28 ~DownloadShelfContextMenu() override;
30 content::DownloadItem* download_item() const { return download_item_; }
32 protected:
33 explicit DownloadShelfContextMenu(content::DownloadItem* download_item);
35 // Returns the correct menu model depending on the state of the download item.
36 // Returns NULL if the download was destroyed.
37 ui::SimpleMenuModel* GetMenuModel();
39 // ui::SimpleMenuModel::Delegate:
40 bool IsCommandIdEnabled(int command_id) const override;
41 bool IsCommandIdChecked(int command_id) const override;
42 bool IsCommandIdVisible(int command_id) const override;
43 void ExecuteCommand(int command_id, int event_flags) override;
44 bool GetAcceleratorForCommandId(int command_id,
45 ui::Accelerator* accelerator) override;
46 bool IsItemForCommandIdDynamic(int command_id) const override;
47 base::string16 GetLabelForCommandId(int command_id) const override;
49 private:
50 // Detaches self from |download_item_|. Called when the DownloadItem is
51 // destroyed or when this object is being destroyed.
52 void DetachFromDownloadItem();
54 // content::DownloadItem::Observer
55 void OnDownloadDestroyed(content::DownloadItem* download) override;
57 ui::SimpleMenuModel* GetInProgressMenuModel();
58 ui::SimpleMenuModel* GetInProgressPausedMenuModel();
59 ui::SimpleMenuModel* GetFinishedMenuModel();
60 ui::SimpleMenuModel* GetInterruptedMenuModel();
61 ui::SimpleMenuModel* GetMaybeMaliciousMenuModel();
62 ui::SimpleMenuModel* GetMaliciousMenuModel();
64 // We show slightly different menus if the download is in progress vs. if the
65 // download has finished.
66 scoped_ptr<ui::SimpleMenuModel> in_progress_download_menu_model_;
67 scoped_ptr<ui::SimpleMenuModel> in_progress_download_paused_menu_model_;
68 scoped_ptr<ui::SimpleMenuModel> finished_download_menu_model_;
69 scoped_ptr<ui::SimpleMenuModel> interrupted_download_menu_model_;
70 scoped_ptr<ui::SimpleMenuModel> maybe_malicious_download_menu_model_;
71 scoped_ptr<ui::SimpleMenuModel> malicious_download_menu_model_;
73 // Information source.
74 content::DownloadItem* download_item_;
75 scoped_ptr<DownloadCommands> download_commands_;
77 #if defined(OS_WIN)
78 bool is_adobe_pdf_reader_up_to_date_;
79 #endif
81 DISALLOW_COPY_AND_ASSIGN(DownloadShelfContextMenu);
84 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_SHELF_CONTEXT_MENU_H_