 Chromium Code Reviews
 Chromium Code Reviews Issue 2671923002:
  mash: Cleanup ash shelf application menu code.  (Closed)
    
  
    Issue 2671923002:
  mash: Cleanup ash shelf application menu code.  (Closed) 
  | 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..f44ca2d9f2effdace7c4d222dc29aa1ff425febc 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,19 @@ 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())); | 
| + ShelfApplicationMenuItems 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. | 
| 
James Cook
2017/02/06 17:30:21
Why? (I presume because clicking on a 1-item icon
 
msw
2017/02/07 09:12:01
Correct; left-clicking a shelf item with no window
 | 
| + 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; | 
| } |