Index: chrome/browser/ui/views/action_box_menu.cc |
diff --git a/chrome/browser/ui/views/action_box_menu.cc b/chrome/browser/ui/views/action_box_menu.cc |
index 776235c52abc9edcfcf4f049d46e6ad69bac66a9..36291ace953adc1bcdfd5ea2bc669e380e37038f 100644 |
--- a/chrome/browser/ui/views/action_box_menu.cc |
+++ b/chrome/browser/ui/views/action_box_menu.cc |
@@ -21,6 +21,21 @@ |
#include "ui/base/native_theme/native_theme_win.h" |
#endif |
+namespace { |
+// Converts from the index of a menu item to the id of this item. Indices are |
msw
2012/08/23 22:04:40
nit: add a blank line above.
beaudoin
2012/08/24 19:34:38
Done.
|
+// 0-based but IDs cannot be 0. |
+inline int MenuIndexToItemId(int menu_index) { |
+ return menu_index + 1; |
+} |
+ |
+// Converts from the id of a menu item to its index. Indices are 0-based but |
+// IDs cannot be 0. |
+inline int MenuItemIdToIndex(int menu_item_id) { |
+ return menu_item_id - 1; |
+} |
+ |
+} // namespace |
+ |
//////////////////////////////////////////////////////////////////////////////// |
// ActionBoxMenu |
@@ -54,6 +69,7 @@ void ActionBoxMenu::RunMenu(views::MenuButton* menu_button) { |
} |
void ActionBoxMenu::ExecuteCommand(int id) { |
+ model_->ActivatedAt(MenuItemIdToIndex(id)); |
} |
views::Border* ActionBoxMenu::CreateMenuBorder() { |
@@ -127,7 +143,7 @@ void ActionBoxMenu::PopulateMenu() { |
for (int model_index = 0; model_index < model_->GetItemCount(); |
++model_index) { |
views::MenuItemView* menu_item = root_->AppendMenuItemFromModel( |
- model_, model_index, model_index + 1); |
+ model_, model_index, MenuIndexToItemId(model_index)); |
if (model_->GetTypeAt(model_index) == ui::MenuModel::TYPE_COMMAND) { |
menu_item->SetMargins(0, 0); |
if (model_->IsItemExtension(model_index)) { |