OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_DOWNLOAD_DOWNLOAD_SHELF_CONTEXT_MENU_H_ | 5 #ifndef CHROME_BROWSER_DOWNLOAD_DOWNLOAD_SHELF_CONTEXT_MENU_H_ |
6 #define CHROME_BROWSER_DOWNLOAD_DOWNLOAD_SHELF_CONTEXT_MENU_H_ | 6 #define CHROME_BROWSER_DOWNLOAD_DOWNLOAD_SHELF_CONTEXT_MENU_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "base/string16.h" | 12 #include "base/string16.h" |
13 #include "ui/base/models/simple_menu_model.h" | 13 #include "ui/base/models/simple_menu_model.h" |
14 | 14 |
15 class BaseDownloadItemModel; | 15 class BaseDownloadItemModel; |
16 | 16 |
17 namespace content { | 17 namespace content { |
18 class DownloadItem; | 18 class DownloadItem; |
| 19 class PageNavigator; |
19 } | 20 } |
20 | 21 |
21 // This class is responsible for the download shelf context menu. Platform | 22 // This class is responsible for the download shelf context menu. Platform |
22 // specific subclasses are responsible for creating and running the menu. | 23 // specific subclasses are responsible for creating and running the menu. |
23 class DownloadShelfContextMenu : public ui::SimpleMenuModel::Delegate { | 24 class DownloadShelfContextMenu : public ui::SimpleMenuModel::Delegate { |
24 public: | 25 public: |
25 enum ContextMenuCommands { | 26 enum ContextMenuCommands { |
26 SHOW_IN_FOLDER = 1, // Open a file explorer window with the item selected. | 27 SHOW_IN_FOLDER = 1, // Open a file explorer window with the item selected. |
27 OPEN_WHEN_COMPLETE, // Open the download when it's finished. | 28 OPEN_WHEN_COMPLETE, // Open the download when it's finished. |
28 ALWAYS_OPEN_TYPE, // Default this file extension to always open. | 29 ALWAYS_OPEN_TYPE, // Default this file extension to always open. |
29 CANCEL, // Cancel the download. | 30 CANCEL, // Cancel the download. |
30 TOGGLE_PAUSE, // Temporarily pause a download. | 31 TOGGLE_PAUSE, // Temporarily pause a download. |
31 DISCARD, // Discard the malicious download. | 32 DISCARD, // Discard the malicious download. |
32 KEEP, // Keep the malicious download. | 33 KEEP, // Keep the malicious download. |
33 LEARN_MORE, // Show information about download scanning. | 34 LEARN_MORE, // Show information about download scanning. |
34 MENU_LAST | 35 MENU_LAST |
35 }; | 36 }; |
36 | 37 |
37 virtual ~DownloadShelfContextMenu(); | 38 virtual ~DownloadShelfContextMenu(); |
38 | 39 |
39 content::DownloadItem* download_item() const { return download_item_; } | 40 content::DownloadItem* download_item() const { return download_item_; } |
40 void set_download_item(content::DownloadItem* item) { download_item_ = item; } | 41 void set_download_item(content::DownloadItem* item) { download_item_ = item; } |
41 | 42 |
42 protected: | 43 protected: |
43 explicit DownloadShelfContextMenu(BaseDownloadItemModel* download_model); | 44 DownloadShelfContextMenu(BaseDownloadItemModel* download_model, |
| 45 content::PageNavigator* navigator); |
44 | 46 |
45 // Returns the correct menu model depending whether the download item is | 47 // Returns the correct menu model depending whether the download item is |
46 // completed or not. | 48 // completed or not. |
47 ui::SimpleMenuModel* GetMenuModel(); | 49 ui::SimpleMenuModel* GetMenuModel(); |
48 | 50 |
49 // ui::SimpleMenuModel::Delegate: | 51 // ui::SimpleMenuModel::Delegate: |
50 virtual bool IsCommandIdEnabled(int command_id) const OVERRIDE; | 52 virtual bool IsCommandIdEnabled(int command_id) const OVERRIDE; |
51 virtual bool IsCommandIdChecked(int command_id) const OVERRIDE; | 53 virtual bool IsCommandIdChecked(int command_id) const OVERRIDE; |
52 virtual void ExecuteCommand(int command_id) OVERRIDE; | 54 virtual void ExecuteCommand(int command_id) OVERRIDE; |
53 virtual bool GetAcceleratorForCommandId( | 55 virtual bool GetAcceleratorForCommandId( |
(...skipping 12 matching lines...) Expand all Loading... |
66 scoped_ptr<ui::SimpleMenuModel> in_progress_download_menu_model_; | 68 scoped_ptr<ui::SimpleMenuModel> in_progress_download_menu_model_; |
67 scoped_ptr<ui::SimpleMenuModel> finished_download_menu_model_; | 69 scoped_ptr<ui::SimpleMenuModel> finished_download_menu_model_; |
68 scoped_ptr<ui::SimpleMenuModel> malicious_download_menu_model_; | 70 scoped_ptr<ui::SimpleMenuModel> malicious_download_menu_model_; |
69 | 71 |
70 // A model to control the cancel behavior. | 72 // A model to control the cancel behavior. |
71 BaseDownloadItemModel* download_model_; | 73 BaseDownloadItemModel* download_model_; |
72 | 74 |
73 // Information source. | 75 // Information source. |
74 content::DownloadItem* download_item_; | 76 content::DownloadItem* download_item_; |
75 | 77 |
| 78 // Used to open tabs. |
| 79 content::PageNavigator* navigator_; |
| 80 |
76 DISALLOW_COPY_AND_ASSIGN(DownloadShelfContextMenu); | 81 DISALLOW_COPY_AND_ASSIGN(DownloadShelfContextMenu); |
77 }; | 82 }; |
78 | 83 |
79 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_SHELF_CONTEXT_MENU_H_ | 84 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_SHELF_CONTEXT_MENU_H_ |
OLD | NEW |