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

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

Issue 2716403005: mash: Remove shelf app menu item objects. (Closed)
Patch Set: Address 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
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..7bf323c12a0339ab022042ad67fa87ca8154c64f 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);
AddItem(kInvalidCommandId, title);
AddSeparator(ui::SPACING_SEPARATOR);
@@ -53,8 +55,10 @@ bool ShelfApplicationMenuModel::IsCommandIdEnabled(int command_id) const {
void ShelfApplicationMenuModel::ExecuteCommand(int command_id,
int event_flags) {
+ DCHECK(delegate_);
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());
}
« no previous file with comments | « ash/common/shelf/shelf_application_menu_model.h ('k') | ash/common/shelf/shelf_application_menu_model_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698