Chromium Code Reviews| Index: chrome/browser/app_controller_mac.mm |
| diff --git a/chrome/browser/app_controller_mac.mm b/chrome/browser/app_controller_mac.mm |
| index b826354036cccdb759e162d615228b1b7d1949fd..8c65ce21e6952ac831c200cbdfb8767f5dac8522 100644 |
| --- a/chrome/browser/app_controller_mac.mm |
| +++ b/chrome/browser/app_controller_mac.mm |
| @@ -67,6 +67,7 @@ |
| #include "chrome/common/chrome_paths_internal.h" |
| #include "chrome/common/chrome_switches.h" |
| #include "chrome/common/cloud_print/cloud_print_class_mac.h" |
| +#include "chrome/common/extensions/extension.h" |
| #include "chrome/common/extensions/extension_constants.h" |
| #include "chrome/common/mac/app_mode_common.h" |
| #include "chrome/common/pref_names.h" |
| @@ -1310,6 +1311,34 @@ void RecordLastRunAppBundlePath() { |
| WorkAreaChanged()); |
| } |
| +- (void)setMenuBarToApp:(NSString*)app_id |
| + withTitle:(NSString*)title { |
| + NSMenu* mainMenu = [NSApp mainMenu]; |
| + |
| + for (NSMenuItem* item in [mainMenu itemArray]) |
| + [item setHidden:YES]; |
| + |
| + NSMenuItem* itemForApp = [mainMenu itemWithTitle:app_id]; |
| + if (!itemForApp) { |
| + NSMenuItem* appMenuItem = [[NSMenuItem alloc] |
|
tapted
2013/06/28 04:09:43
there's a memory leak here ;) - you need
scoped_n
jackhou1
2013/07/04 01:57:55
Done.
|
| + initWithTitle:app_id |
| + action:@selector(itemSelected:) |
|
tapted
2013/06/28 04:09:43
I think the action can be `nil`, since we aren't s
jackhou1
2013/07/04 01:57:55
Done.
|
| + keyEquivalent:@""]; |
| + NSMenu* appMenu = [[NSMenu alloc] initWithTitle:title]; |
|
tapted
2013/06/28 04:09:43
scoped_nsobject<NSMenu>
jackhou1
2013/07/04 01:57:55
Done.
|
| + [appMenuItem setSubmenu:appMenu]; |
| + [mainMenu addItem:appMenuItem]; |
| + } |
| + [itemForApp setHidden:NO]; |
|
tapted
2013/06/28 04:09:43
maybe in an else {? you're not re-assigning, so it
jackhou1
2013/07/04 01:57:55
Done.
|
| +} |
| + |
| +- (void)setMenuBarToChrome { |
| + NSMenu* mainMenu = [NSApp mainMenu]; |
|
tapted
2013/06/28 04:09:43
nit: probably don't need this temporary
jackhou1
2013/07/04 01:57:55
Done.
|
| + for (NSMenuItem* item in [mainMenu itemArray]) { |
| + const std::string& title = base::SysNSStringToUTF8([item title]); |
| + [item setHidden:extensions::Extension::IdIsValid(title)]; |
|
tapted
2013/06/28 04:09:43
hm.. this feels a bit odd.. Swapping out [NSApp ma
jackhou1
2013/07/04 01:57:55
Done.
|
| + } |
| +} |
| + |
| @end // @implementation AppController |
| //--------------------------------------------------------------------------- |