Index: chrome/browser/ui/views/wrench_menu.cc |
diff --git a/chrome/browser/ui/views/wrench_menu.cc b/chrome/browser/ui/views/wrench_menu.cc |
index 3b83b0007c9ae0278afb6e96bec0a142481a0dc4..1f5353d9c68f0108c09e611fa4f0a9d0580faca3 100644 |
--- a/chrome/browser/ui/views/wrench_menu.cc |
+++ b/chrome/browser/ui/views/wrench_menu.cc |
@@ -736,6 +736,19 @@ class WrenchMenu::RecentTabsMenuModelDelegate : public ui::MenuModelDelegate { |
item->SetIcon(*icon.ToImageSkia()); |
} |
+ // Return the specific menu width of recent tab menu item if |command_id| |
+ // refers to one of recent tabs menu items, else return -1. |
+ int GetMaxWidthForMenu(MenuItemView* menu) { |
+ views::SubmenuView* submenu = menu_item_->GetSubmenu(); |
+ if (!submenu) |
+ return -1; |
+ const int kMaxMenuItemWidth = 320; |
+ return menu->GetCommand() >= menu_item_->GetCommand() && |
+ menu->GetCommand() <= |
+ menu_item_->GetCommand() + submenu->GetMenuItemCount() ? |
+ kMaxMenuItemWidth : -1; |
+ } |
+ |
private: |
ui::MenuModel* model_; |
views::MenuItemView* menu_item_; |
@@ -893,9 +906,17 @@ int WrenchMenu::GetDragOperations(MenuItemView* sender) { |
} |
int WrenchMenu::GetMaxWidthForMenu(MenuItemView* menu) { |
- return is_bookmark_command(menu->GetCommand()) ? |
- bookmark_menu_delegate_->GetMaxWidthForMenu(menu) : |
- MenuDelegate::GetMaxWidthForMenu(menu); |
+ if (is_bookmark_command(menu->GetCommand())) |
+ return bookmark_menu_delegate_->GetMaxWidthForMenu(menu); |
+ int max_width = -1; |
+ // If recent tabs menu is available, it will decide if |menu| is one of recent |
+ // tabs; if yes, it would return the menu width for recent tabs. |
+ // otherwise, it would return -1. |
+ if (recent_tabs_menu_model_delegate_.get()) |
+ max_width = recent_tabs_menu_model_delegate_->GetMaxWidthForMenu(menu); |
+ if (max_width == -1) |
+ max_width = MenuDelegate::GetMaxWidthForMenu(menu); |
+ return max_width; |
} |
bool WrenchMenu::IsItemChecked(int id) const { |