OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/ui/views/toolbar/wrench_menu.h" | 5 #include "chrome/browser/ui/views/toolbar/wrench_menu.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 #include <set> | 9 #include <set> |
10 | 10 |
(...skipping 709 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
720 : wrench_menu_(wrench_menu), | 720 : wrench_menu_(wrench_menu), |
721 model_(model), | 721 model_(model), |
722 menu_item_(menu_item) { | 722 menu_item_(menu_item) { |
723 model_->SetMenuModelDelegate(this); | 723 model_->SetMenuModelDelegate(this); |
724 } | 724 } |
725 | 725 |
726 virtual ~RecentTabsMenuModelDelegate() { | 726 virtual ~RecentTabsMenuModelDelegate() { |
727 model_->SetMenuModelDelegate(NULL); | 727 model_->SetMenuModelDelegate(NULL); |
728 } | 728 } |
729 | 729 |
730 // Return the specific menu width of recent tabs submenu if |menu| is the | |
731 // recent tabs submenu, else return -1. | |
732 int GetMaxWidthForMenu(views::MenuItemView* menu) { | |
733 if (!menu_item_->HasSubmenu()) | |
734 return -1; | |
735 const int kMaxMenuItemWidth = 320; | |
736 return menu->GetCommand() == menu_item_->GetCommand() ? | |
737 kMaxMenuItemWidth : -1; | |
738 } | |
739 | |
740 const gfx::FontList* GetLabelFontListAt(int index) const { | 730 const gfx::FontList* GetLabelFontListAt(int index) const { |
741 return model_->GetLabelFontListAt(index); | 731 return model_->GetLabelFontListAt(index); |
742 } | 732 } |
743 | 733 |
744 bool GetShouldUseDisabledEmphasizedForegroundColor(int index) const { | 734 bool GetShouldUseDisabledEmphasizedForegroundColor(int index) const { |
745 // The items for which we get a font list, should be shown in the bolded | 735 // The items for which we get a font list, should be shown in the bolded |
746 // color. | 736 // color. |
747 return GetLabelFontListAt(index) ? true : false; | 737 return GetLabelFontListAt(index) ? true : false; |
748 } | 738 } |
749 | 739 |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
977 | 967 |
978 int WrenchMenu::GetDragOperations(MenuItemView* sender) { | 968 int WrenchMenu::GetDragOperations(MenuItemView* sender) { |
979 return IsBookmarkCommand(sender->GetCommand()) ? | 969 return IsBookmarkCommand(sender->GetCommand()) ? |
980 bookmark_menu_delegate_->GetDragOperations(sender) : | 970 bookmark_menu_delegate_->GetDragOperations(sender) : |
981 MenuDelegate::GetDragOperations(sender); | 971 MenuDelegate::GetDragOperations(sender); |
982 } | 972 } |
983 | 973 |
984 int WrenchMenu::GetMaxWidthForMenu(MenuItemView* menu) { | 974 int WrenchMenu::GetMaxWidthForMenu(MenuItemView* menu) { |
985 if (IsBookmarkCommand(menu->GetCommand())) | 975 if (IsBookmarkCommand(menu->GetCommand())) |
986 return bookmark_menu_delegate_->GetMaxWidthForMenu(menu); | 976 return bookmark_menu_delegate_->GetMaxWidthForMenu(menu); |
987 int max_width = -1; | 977 return MenuDelegate::GetMaxWidthForMenu(menu); |
988 // If recent tabs menu is available, it will decide if |menu| is one of recent | |
989 // tabs; if yes, it would return the menu width for recent tabs. | |
990 // otherwise, it would return -1. | |
991 if (recent_tabs_menu_model_delegate_.get()) | |
992 max_width = recent_tabs_menu_model_delegate_->GetMaxWidthForMenu(menu); | |
993 if (max_width == -1) | |
994 max_width = MenuDelegate::GetMaxWidthForMenu(menu); | |
995 return max_width; | |
996 } | 978 } |
997 | 979 |
998 bool WrenchMenu::IsItemChecked(int command_id) const { | 980 bool WrenchMenu::IsItemChecked(int command_id) const { |
999 if (IsBookmarkCommand(command_id)) | 981 if (IsBookmarkCommand(command_id)) |
1000 return false; | 982 return false; |
1001 | 983 |
1002 const Entry& entry = command_id_to_entry_.find(command_id)->second; | 984 const Entry& entry = command_id_to_entry_.find(command_id)->second; |
1003 return entry.first->IsItemCheckedAt(entry.second); | 985 return entry.first->IsItemCheckedAt(entry.second); |
1004 } | 986 } |
1005 | 987 |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1261 0, | 1243 0, |
1262 BookmarkMenuDelegate::SHOW_PERMANENT_FOLDERS, | 1244 BookmarkMenuDelegate::SHOW_PERMANENT_FOLDERS, |
1263 BOOKMARK_LAUNCH_LOCATION_WRENCH_MENU); | 1245 BOOKMARK_LAUNCH_LOCATION_WRENCH_MENU); |
1264 } | 1246 } |
1265 | 1247 |
1266 int WrenchMenu::ModelIndexFromCommandId(int command_id) const { | 1248 int WrenchMenu::ModelIndexFromCommandId(int command_id) const { |
1267 CommandIDToEntry::const_iterator ix = command_id_to_entry_.find(command_id); | 1249 CommandIDToEntry::const_iterator ix = command_id_to_entry_.find(command_id); |
1268 DCHECK(ix != command_id_to_entry_.end()); | 1250 DCHECK(ix != command_id_to_entry_.end()); |
1269 return ix->second.second; | 1251 return ix->second.second; |
1270 } | 1252 } |
OLD | NEW |