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

Side by Side Diff: chrome/browser/cocoa/menu_controller.mm

Issue 2856042: [Mac] Implement the update available notification in the wrench menu. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: Observe notification Created 10 years, 5 months 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 unified diff | Download patch
« no previous file with comments | « chrome/browser/cocoa/browser_window_cocoa.mm ('k') | chrome/browser/cocoa/restart_browser.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 #import "chrome/browser/cocoa/menu_controller.h" 5 #import "chrome/browser/cocoa/menu_controller.h"
6 6
7 #include "app/l10n_util_mac.h" 7 #include "app/l10n_util_mac.h"
8 #include "app/menus/accelerator_cocoa.h" 8 #include "app/menus/accelerator_cocoa.h"
9 #include "app/menus/simple_menu_model.h" 9 #include "app/menus/simple_menu_model.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/sys_string_conversions.h" 11 #include "base/sys_string_conversions.h"
12 #include "skia/ext/skia_utils_mac.h"
12 13
13 @interface MenuController (Private) 14 @interface MenuController (Private)
14 - (NSMenu*)menuFromModel:(menus::MenuModel*)model; 15 - (NSMenu*)menuFromModel:(menus::MenuModel*)model;
15 - (void)addSeparatorToMenu:(NSMenu*)menu 16 - (void)addSeparatorToMenu:(NSMenu*)menu
16 atIndex:(int)index; 17 atIndex:(int)index;
17 @end 18 @end
18 19
19 @implementation MenuController 20 @implementation MenuController
20 21
21 @synthesize model = model_; 22 @synthesize model = model_;
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 - (void)addItemToMenu:(NSMenu*)menu 80 - (void)addItemToMenu:(NSMenu*)menu
80 atIndex:(NSInteger)index 81 atIndex:(NSInteger)index
81 fromModel:(menus::MenuModel*)model 82 fromModel:(menus::MenuModel*)model
82 modelIndex:(int)modelIndex { 83 modelIndex:(int)modelIndex {
83 NSString* label = 84 NSString* label =
84 l10n_util::FixUpWindowsStyleLabel(model->GetLabelAt(modelIndex)); 85 l10n_util::FixUpWindowsStyleLabel(model->GetLabelAt(modelIndex));
85 scoped_nsobject<NSMenuItem> item( 86 scoped_nsobject<NSMenuItem> item(
86 [[NSMenuItem alloc] initWithTitle:label 87 [[NSMenuItem alloc] initWithTitle:label
87 action:@selector(itemSelected:) 88 action:@selector(itemSelected:)
88 keyEquivalent:@""]); 89 keyEquivalent:@""]);
90
91 // If the menu item has an icon, set it.
92 SkBitmap skiaIcon;
93 if (model->GetIconAt(modelIndex, &skiaIcon) && !skiaIcon.isNull()) {
94 NSImage* icon = gfx::SkBitmapToNSImage(skiaIcon);
95 if (icon) {
96 [item setImage:icon];
97 }
98 }
99
89 menus::MenuModel::ItemType type = model->GetTypeAt(modelIndex); 100 menus::MenuModel::ItemType type = model->GetTypeAt(modelIndex);
90 if (type == menus::MenuModel::TYPE_SUBMENU) { 101 if (type == menus::MenuModel::TYPE_SUBMENU) {
91 // Recursively build a submenu from the sub-model at this index. 102 // Recursively build a submenu from the sub-model at this index.
92 [item setTarget:nil]; 103 [item setTarget:nil];
93 [item setAction:nil]; 104 [item setAction:nil];
94 menus::MenuModel* submenuModel = model->GetSubmenuModelAt(modelIndex); 105 menus::MenuModel* submenuModel = model->GetSubmenuModelAt(modelIndex);
95 NSMenu* submenu = 106 NSMenu* submenu =
96 [self menuFromModel:(menus::SimpleMenuModel*)submenuModel]; 107 [self menuFromModel:(menus::SimpleMenuModel*)submenuModel];
97 [item setSubmenu:submenu]; 108 [item setSubmenu:submenu];
98 } else { 109 } else {
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 if (useWithPopUpButtonCell_) { 174 if (useWithPopUpButtonCell_) {
164 scoped_nsobject<NSMenuItem> blankItem( 175 scoped_nsobject<NSMenuItem> blankItem(
165 [[NSMenuItem alloc] initWithTitle:@"" action:nil keyEquivalent:@""]); 176 [[NSMenuItem alloc] initWithTitle:@"" action:nil keyEquivalent:@""]);
166 [menu_ insertItem:blankItem atIndex:0]; 177 [menu_ insertItem:blankItem atIndex:0];
167 } 178 }
168 } 179 }
169 return menu_.get(); 180 return menu_.get();
170 } 181 }
171 182
172 @end 183 @end
OLDNEW
« no previous file with comments | « chrome/browser/cocoa/browser_window_cocoa.mm ('k') | chrome/browser/cocoa/restart_browser.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698