| 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 #include "chrome/browser/ui/views/download/download_shelf_context_menu_view.h" | 5 #include "chrome/browser/ui/views/download/download_shelf_context_menu_view.h" |
| 6 | 6 |
| 7 #include "base/i18n/rtl.h" | 7 #include "base/i18n/rtl.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "chrome/browser/download/download_item.h" | 9 #include "chrome/browser/download/download_item.h" |
| 10 #include "chrome/browser/download/download_item_model.h" | 10 #include "chrome/browser/download/download_item_model.h" |
| 11 #include "ui/gfx/point.h" | 11 #include "ui/gfx/point.h" |
| 12 #include "views/controls/menu/menu_2.h" | 12 #include "views/controls/menu/menu_2.h" |
| 13 | 13 |
| 14 DownloadShelfContextMenuView::DownloadShelfContextMenuView( | 14 DownloadShelfContextMenuView::DownloadShelfContextMenuView( |
| 15 BaseDownloadItemModel* model) | 15 BaseDownloadItemModel* model) |
| 16 : DownloadShelfContextMenu(model) { | 16 : DownloadShelfContextMenu(model) { |
| 17 DCHECK(model); | 17 DCHECK(model); |
| 18 } | 18 } |
| 19 | 19 |
| 20 DownloadShelfContextMenuView::~DownloadShelfContextMenuView() {} | 20 DownloadShelfContextMenuView::~DownloadShelfContextMenuView() {} |
| 21 | 21 |
| 22 void DownloadShelfContextMenuView::Run(const gfx::Point& point) { | 22 void DownloadShelfContextMenuView::Run(const gfx::Point& point) { |
| 23 if (download_item()->IsComplete()) | 23 menu_.reset(new views::Menu2(GetMenuModel())); |
| 24 menu_.reset(new views::Menu2(GetFinishedMenuModel())); | |
| 25 else | |
| 26 menu_.reset(new views::Menu2(GetInProgressMenuModel())); | |
| 27 | 24 |
| 28 // The menu's alignment is determined based on the UI layout. | 25 // The menu's alignment is determined based on the UI layout. |
| 29 views::Menu2::Alignment alignment; | 26 views::Menu2::Alignment alignment; |
| 30 if (base::i18n::IsRTL()) | 27 if (base::i18n::IsRTL()) |
| 31 alignment = views::Menu2::ALIGN_TOPRIGHT; | 28 alignment = views::Menu2::ALIGN_TOPRIGHT; |
| 32 else | 29 else |
| 33 alignment = views::Menu2::ALIGN_TOPLEFT; | 30 alignment = views::Menu2::ALIGN_TOPLEFT; |
| 34 menu_->RunMenuAt(point, alignment); | 31 menu_->RunMenuAt(point, alignment); |
| 35 } | 32 } |
| 36 | 33 |
| 37 void DownloadShelfContextMenuView::Stop() { | 34 void DownloadShelfContextMenuView::Stop() { |
| 38 set_download_item(NULL); | 35 set_download_item(NULL); |
| 39 } | 36 } |
| OLD | NEW |