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

Unified Diff: chrome/browser/ui/views/wrench_menu.cc

Issue 11410067: alternate ntp: favicons and menu width enhancements for "Recent tabs" menu (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixed typo Created 8 years, 1 month 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
« no previous file with comments | « chrome/browser/ui/toolbar/recent_tabs_sub_menu_model.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 {
« no previous file with comments | « chrome/browser/ui/toolbar/recent_tabs_sub_menu_model.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698