Chromium Code Reviews| Index: chrome/browser/download/download_shelf_context_menu.h |
| diff --git a/chrome/browser/download/download_shelf_context_menu.h b/chrome/browser/download/download_shelf_context_menu.h |
| index d4f83b98ccbb3c09cdd56faf31d30ee954f38a0d..084729ed81527df25307de8e1e8b8f34281adfc3 100644 |
| --- a/chrome/browser/download/download_shelf_context_menu.h |
| +++ b/chrome/browser/download/download_shelf_context_menu.h |
| @@ -9,18 +9,20 @@ |
| #include "base/compiler_specific.h" |
| #include "base/memory/scoped_ptr.h" |
| #include "base/string16.h" |
| +#include "content/public/browser/download_item.h" |
| #include "ui/base/models/simple_menu_model.h" |
| -class DownloadItemModel; |
| - |
| namespace content { |
| -class DownloadItem; |
| class PageNavigator; |
| } |
| // This class is responsible for the download shelf context menu. Platform |
| // specific subclasses are responsible for creating and running the menu. |
| -class DownloadShelfContextMenu : public ui::SimpleMenuModel::Delegate { |
| +// |
| +// The DownloadItem corresponding to the context menu is observed for removal or |
| +// destruction. |
| +class DownloadShelfContextMenu : public ui::SimpleMenuModel::Delegate, |
| + public content::DownloadItem::Observer { |
| public: |
| enum ContextMenuCommands { |
| SHOW_IN_FOLDER = 1, // Open a folder view window with the item selected. |
| @@ -37,14 +39,13 @@ class DownloadShelfContextMenu : public ui::SimpleMenuModel::Delegate { |
| virtual ~DownloadShelfContextMenu(); |
| content::DownloadItem* download_item() const { return download_item_; } |
| - void set_download_item(content::DownloadItem* item) { download_item_ = item; } |
| protected: |
| - DownloadShelfContextMenu(DownloadItemModel* download_model, |
| + DownloadShelfContextMenu(content::DownloadItem* download_item, |
| content::PageNavigator* navigator); |
| - // Returns the correct menu model depending whether the download item is |
| - // completed or not. |
| + // Returns the correct menu model depending on the state of the download item. |
| + // Returns NULL if the download was destroyed. |
| ui::SimpleMenuModel* GetMenuModel(); |
| // ui::SimpleMenuModel::Delegate: |
| @@ -57,7 +58,14 @@ class DownloadShelfContextMenu : public ui::SimpleMenuModel::Delegate { |
| virtual bool IsItemForCommandIdDynamic(int command_id) const OVERRIDE; |
| virtual string16 GetLabelForCommandId(int command_id) const OVERRIDE; |
| + // content::DownloadItem::Observer |
| + virtual void OnDownloadDestroyed(content::DownloadItem* download) OVERRIDE; |
|
Randy Smith (Not in Mondays)
2012/12/28 19:02:46
Why protected rather than private?
asanka
2013/01/07 20:19:25
Moved to private.
|
| + |
| private: |
| + // Detaches self from |download_item_|. Called when the DownloadItem is |
| + // destroyed or when this object is being destroyed. |
| + void DetachFromDownloadItem(); |
| + |
| ui::SimpleMenuModel* GetInProgressMenuModel(); |
| ui::SimpleMenuModel* GetFinishedMenuModel(); |
| ui::SimpleMenuModel* GetInterruptedMenuModel(); |
| @@ -70,9 +78,6 @@ class DownloadShelfContextMenu : public ui::SimpleMenuModel::Delegate { |
| scoped_ptr<ui::SimpleMenuModel> interrupted_download_menu_model_; |
| scoped_ptr<ui::SimpleMenuModel> malicious_download_menu_model_; |
| - // A model to control the cancel behavior. |
| - DownloadItemModel* download_model_; |
| - |
| // Information source. |
| content::DownloadItem* download_item_; |