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

Unified Diff: chrome/browser/cocoa/back_forward_menu_controller.mm

Issue 501168: Make back forward menu model a MenuModel.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years 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/cocoa/back_forward_menu_controller.mm
===================================================================
--- chrome/browser/cocoa/back_forward_menu_controller.mm (revision 35347)
+++ chrome/browser/cocoa/back_forward_menu_controller.mm (working copy)
@@ -49,7 +49,7 @@
// Remove old menu items (backwards order is as good as any).
for (NSInteger i = [menu numberOfItems]; i > 0; i--)
- [menu removeItemAtIndex:(i-1)];
+ [menu removeItemAtIndex:(i - 1)];
// 0-th item must be blank. (This is because we use a pulldown list, for which
// Cocoa uses the 0-th item as "title" in the button.)
@@ -57,24 +57,22 @@
action:nil
keyEquivalent:@""
atIndex:0];
- for (int menuID = 1; menuID <= model_->GetTotalItemCount(); menuID++) {
+ for (int menuID = 0; menuID < model_->GetItemCount(); menuID++) {
if (model_->IsSeparator(menuID)) {
[menu insertItem:[NSMenuItem separatorItem]
- atIndex:menuID];
+ atIndex:(menuID + 1)];
} else {
// Create a menu item with the right label.
NSMenuItem* menuItem = [[NSMenuItem alloc]
- initWithTitle:SysUTF16ToNSString(model_->GetItemLabel(menuID))
+ initWithTitle:SysUTF16ToNSString(model_->GetLabelAt(menuID))
action:nil
keyEquivalent:@""];
[menuItem autorelease];
- // Only enable it if it's supposed to do something.
- [menuItem setEnabled:(model_->ItemHasCommand(menuID) ? YES : NO)];
-
+ SkBitmap icon;
// Icon (if it has one).
- if (model_->ItemHasIcon(menuID))
- [menuItem setImage:SkBitmapToNSImage(model_->GetItemIcon(menuID))];
+ if (model_->GetIconAt(menuID, &icon))
+ [menuItem setImage:SkBitmapToNSImage(icon)];
// This will make it call our |-executeMenuItem:| method. We store the
// |menuID| (or |menu_id|) in the tag.
@@ -84,7 +82,7 @@
// Put it in the menu!
[menu insertItem:menuItem
- atIndex:menuID];
+ atIndex:(menuID + 1)];
}
}
}
@@ -94,7 +92,7 @@
- (void)executeMenuItem:(id)sender {
DCHECK([sender isKindOfClass:[NSMenuItem class]]);
int menuID = [sender tag];
- model_->ExecuteCommandById(menuID);
+ model_->ActivatedAt(menuID);
}
@end // @implementation BackForwardMenuController

Powered by Google App Engine
This is Rietveld 408576698