Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2249)

Unified Diff: ash/common/shelf/shelf_view.cc

Issue 2671923002: mash: Cleanup ash shelf application menu code. (Closed)
Patch Set: Add comments Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ash/common/shelf/shelf_item_delegate.h ('k') | ash/common/shelf/shelf_window_watcher_item_delegate.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/common/shelf/shelf_view.cc
diff --git a/ash/common/shelf/shelf_view.cc b/ash/common/shelf/shelf_view.cc
index 82d3498840021fb890675aa6ffbbf9a218b336b3..8ab622522b10f43fbe094d97054770879f2970a9 100644
--- a/ash/common/shelf/shelf_view.cc
+++ b/ash/common/shelf/shelf_view.cc
@@ -14,6 +14,7 @@
#include "ash/common/shelf/overflow_bubble.h"
#include "ash/common/shelf/overflow_bubble_view.h"
#include "ash/common/shelf/overflow_button.h"
+#include "ash/common/shelf/shelf_application_menu_model.h"
#include "ash/common/shelf/shelf_button.h"
#include "ash/common/shelf/shelf_constants.h"
#include "ash/common/shelf/shelf_delegate.h"
@@ -26,6 +27,7 @@
#include "ash/common/wm_shell.h"
#include "ash/common/wm_window.h"
#include "base/auto_reset.h"
+#include "base/memory/ptr_util.h"
#include "base/metrics/histogram_macros.h"
#include "grit/ash_strings.h"
#include "ui/accessibility/ax_node_data.h"
@@ -1613,18 +1615,21 @@ bool ShelfView::ShowListMenuForView(const ShelfItem& item,
const ui::Event& event,
views::InkDrop* ink_drop) {
ShelfItemDelegate* item_delegate = model_->GetShelfItemDelegate(item.id);
- std::unique_ptr<ui::MenuModel> list_menu_model(
- item_delegate->CreateApplicationMenu(event.flags()));
+ ShelfAppMenuItemList menu_items =
+ item_delegate->GetAppMenuItems(event.flags());
- // Make sure we have a menu and it has at least two items in addition to the
- // application title and the 3 spacing separators.
- if (!list_menu_model.get() || list_menu_model->GetItemCount() <= 5)
+ // The application list menu should only show for two or more items; return
+ // false here to ensure that other behavior is triggered (eg. activating or
+ // minimizing a single associated window, or launching a pinned shelf item).
+ if (menu_items.size() < 2)
return false;
ink_drop->AnimateToState(views::InkDropState::ACTIVATED);
context_menu_id_ = item.id;
- ShowMenu(std::move(list_menu_model), source, gfx::Point(), false,
- ui::GetMenuSourceTypeForEvent(event), ink_drop);
+ ShowMenu(base::MakeUnique<ShelfApplicationMenuModel>(item.title,
+ std::move(menu_items)),
+ source, gfx::Point(), false, ui::GetMenuSourceTypeForEvent(event),
+ ink_drop);
return true;
}
« no previous file with comments | « ash/common/shelf/shelf_item_delegate.h ('k') | ash/common/shelf/shelf_window_watcher_item_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698