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

Unified Diff: chrome/browser/ui/cocoa/menu_controller.mm

Issue 5697005: Change SimpleMenuModel on OSX to support dynamic icons (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Moved background page badge fix to another CL. Created 10 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/ui/cocoa/menu_controller.mm
diff --git a/chrome/browser/ui/cocoa/menu_controller.mm b/chrome/browser/ui/cocoa/menu_controller.mm
index 47f0c348081994998f065d8afea639f58f71f040..3b0a3adb988028d3eacdbbddcbb4358a6a1e4dae 100644
--- a/chrome/browser/ui/cocoa/menu_controller.mm
+++ b/chrome/browser/ui/cocoa/menu_controller.mm
@@ -144,10 +144,22 @@
DCHECK([(id)item isKindOfClass:[NSMenuItem class]]);
[(id)item setState:(checked ? NSOnState : NSOffState)];
[(id)item setHidden:(!model->IsVisibleAt(modelIndex))];
- if (model->IsLabelDynamicAt(modelIndex)) {
+ if (model->IsItemDynamicAt(modelIndex)) {
+ // Update the label and the icon.
NSString* label =
l10n_util::FixUpWindowsStyleLabel(model->GetLabelAt(modelIndex));
[(id)item setTitle:label];
+ SkBitmap skiaIcon;
+ if (model->GetIconAt(modelIndex, &skiaIcon) && !skiaIcon.isNull()) {
+ // We have an icon.
+ NSImage* icon = gfx::SkBitmapToNSImage(skiaIcon);
+ if (icon) {
Evan Stade 2010/12/14 01:20:13 no {}
Andrew T Wilson (Slow) 2010/12/14 18:23:27 Done.
+ [(id)item setImage:icon];
Evan Stade 2010/12/14 01:20:13 it strikes me that you'll either want to setImage
Andrew T Wilson (Slow) 2010/12/14 18:23:27 Good point - my previous code was just leaving the
+ }
+ } else {
+ // No icon.
+ [(id)item setImage:nil];
+ }
}
return model->IsEnabledAt(modelIndex);
}

Powered by Google App Engine
This is Rietveld 408576698