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