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

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: removed unused include 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
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..44862520f469dbcb8c1ff325d0541a3596c56765 100644
--- a/chrome/browser/ui/views/wrench_menu.cc
+++ b/chrome/browser/ui/views/wrench_menu.cc
@@ -736,6 +736,20 @@ class WrenchMenu::RecentTabsMenuModelDelegate : public ui::MenuModelDelegate {
item->SetIcon(*icon.ToImageSkia());
}
+ // Return the specific menu width of recent tab menu item if |comamnd_id|
+ // refers to one of recent tabs menu items, else return -1.
+ int GetMaxWidthForMenu(int command_id) {
+ views::SubmenuView* submenu = menu_item_->GetSubmenu();
sky 2012/11/13 17:41:50 Instead of checking the command make this take the
kuan 2012/11/13 18:52:52 Done.
+ if (!submenu)
+ return -1;
+ if (command_id < menu_item_->GetCommand() ||
+ command_id > menu_item_->GetCommand() + submenu->GetMenuItemCount()) {
+ return -1;
+ }
+ const int kMaxMenuItemWidth = 320;
+ return kMaxMenuItemWidth;
+ }
+
private:
ui::MenuModel* model_;
views::MenuItemView* menu_item_;
@@ -893,9 +907,19 @@ 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->GetCommand());
+ }
+ if (max_width == -1)
+ max_width = MenuDelegate::GetMaxWidthForMenu(menu);
+ return max_width;
}
bool WrenchMenu::IsItemChecked(int id) const {

Powered by Google App Engine
This is Rietveld 408576698