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_model.h" | 9 #include "chrome/browser/download/download_item_model.h" |
10 #include "content/public/browser/download_item.h" | 10 #include "content/public/browser/download_item.h" |
11 #include "content/public/browser/page_navigator.h" | 11 #include "content/public/browser/page_navigator.h" |
12 #include "ui/gfx/geometry/point.h" | 12 #include "ui/gfx/geometry/point.h" |
13 #include "ui/views/controls/menu/menu_runner.h" | 13 #include "ui/views/controls/menu/menu_runner.h" |
14 | 14 |
15 DownloadShelfContextMenuView::DownloadShelfContextMenuView( | 15 DownloadShelfContextMenuView::DownloadShelfContextMenuView( |
16 content::DownloadItem* download_item) | 16 DownloadItemView* download_item_view) |
17 : DownloadShelfContextMenu(download_item) { | 17 : DownloadShelfContextMenu(download_item_view->download()), |
18 } | 18 download_item_view_(download_item_view) {} |
19 | 19 |
20 DownloadShelfContextMenuView::~DownloadShelfContextMenuView() {} | 20 DownloadShelfContextMenuView::~DownloadShelfContextMenuView() {} |
21 | 21 |
22 void DownloadShelfContextMenuView::Run( | 22 void DownloadShelfContextMenuView::Run( |
23 views::Widget* parent_widget, | 23 views::Widget* parent_widget, |
24 const gfx::Rect& rect, | 24 const gfx::Rect& rect, |
25 ui::MenuSourceType source_type, | 25 ui::MenuSourceType source_type, |
26 const base::Closure& on_menu_closed_callback) { | 26 const base::Closure& on_menu_closed_callback) { |
27 ui::MenuModel* menu_model = GetMenuModel(); | 27 ui::MenuModel* menu_model = GetMenuModel(); |
28 // Run() should not be getting called if the DownloadItem was destroyed. | 28 // Run() should not be getting called if the DownloadItem was destroyed. |
(...skipping 19 matching lines...) Expand all Loading... | |
48 void DownloadShelfContextMenuView::OnMenuClosed( | 48 void DownloadShelfContextMenuView::OnMenuClosed( |
49 const base::Closure& on_menu_closed_callback) { | 49 const base::Closure& on_menu_closed_callback) { |
50 close_time_ = base::TimeTicks::Now(); | 50 close_time_ = base::TimeTicks::Now(); |
51 | 51 |
52 // This must be run before clearing |menu_runner_| who owns the reference. | 52 // This must be run before clearing |menu_runner_| who owns the reference. |
53 if (!on_menu_closed_callback.is_null()) | 53 if (!on_menu_closed_callback.is_null()) |
54 on_menu_closed_callback.Run(); | 54 on_menu_closed_callback.Run(); |
55 | 55 |
56 menu_runner_.reset(); | 56 menu_runner_.reset(); |
57 } | 57 } |
58 | |
59 void DownloadShelfContextMenuView::ExecuteCommand(int command_id, | |
60 int event_flags) { | |
61 if (static_cast<DownloadCommands::Command>(command_id) == | |
62 DownloadCommands::KEEP) { | |
asanka
2016/11/01 20:58:58
Can you add a DCHECK here to make sure command_id
Jialiu Lin
2016/11/03 20:16:50
Done.
| |
63 download_item_view_->MaybeSubmitDownloadToFeedbackService( | |
64 DownloadCommands::KEEP); | |
65 } else { | |
66 DownloadShelfContextMenu::ExecuteCommand(command_id, event_flags); | |
67 } | |
68 } | |
OLD | NEW |