Chromium Code Reviews| Index: ash/common/shelf/shelf_application_menu_model.cc |
| diff --git a/ash/common/shelf/shelf_application_menu_model.cc b/ash/common/shelf/shelf_application_menu_model.cc |
| index 331f0d5e3737ebaf03fe3a461473692a06f0f427..f39de8588265fd628189b5611bf59b6c603c44d8 100644 |
| --- a/ash/common/shelf/shelf_application_menu_model.cc |
| +++ b/ash/common/shelf/shelf_application_menu_model.cc |
| @@ -9,6 +9,7 @@ |
| #include <limits> |
| #include <utility> |
| +#include "ash/common/shelf/shelf_item_delegate.h" |
| #include "ash/public/cpp/shelf_application_menu_item.h" |
| #include "base/metrics/histogram_macros.h" |
| @@ -22,8 +23,9 @@ namespace ash { |
| ShelfApplicationMenuModel::ShelfApplicationMenuModel( |
| const base::string16& title, |
| - ShelfAppMenuItemList items) |
| - : ui::SimpleMenuModel(this), items_(std::move(items)) { |
| + ShelfAppMenuItemList items, |
| + ShelfItemDelegate* delegate) |
| + : ui::SimpleMenuModel(this), items_(std::move(items)), delegate_(delegate) { |
| AddSeparator(ui::SPACING_SEPARATOR); |
|
James Cook
2017/03/01 19:50:48
DCHECK(delegate_)?
Or early exit for null delegat
msw
2017/03/02 02:59:20
I added a DCHECK in ExecuteCommand; tests use null
|
| AddItem(kInvalidCommandId, title); |
| AddSeparator(ui::SPACING_SEPARATOR); |
| @@ -54,7 +56,8 @@ bool ShelfApplicationMenuModel::IsCommandIdEnabled(int command_id) const { |
| void ShelfApplicationMenuModel::ExecuteCommand(int command_id, |
| int event_flags) { |
| DCHECK(IsCommandIdEnabled(command_id)); |
| - items_[command_id]->Execute(event_flags); |
| + // Have the delegate execute its own custom command id for the given item. |
| + delegate_->ExecuteCommand(items_[command_id]->command_id(), event_flags); |
| RecordMenuItemSelectedMetrics(command_id, items_.size()); |
| } |