Chromium Code Reviews| Index: apps/app_shim/chrome_main_app_mode_mac.mm |
| diff --git a/apps/app_shim/chrome_main_app_mode_mac.mm b/apps/app_shim/chrome_main_app_mode_mac.mm |
| index 2302b047b7e464779dc016a6d668ed2fa6e9de36..81394557a5df0ac90239e5578038ce7f95e6bb7d 100644 |
| --- a/apps/app_shim/chrome_main_app_mode_mac.mm |
| +++ b/apps/app_shim/chrome_main_app_mode_mac.mm |
| @@ -64,6 +64,9 @@ class AppShimController : public IPC::Listener { |
| // Connects to Chrome and sends a LaunchApp message. |
| void Init(); |
| + // Builds main menu bar items. |
| + void SetUpMenu(); |
| + |
| void SendSetAppHidden(bool hidden); |
| void SendQuitApp(); |
| @@ -97,6 +100,10 @@ AppShimController::AppShimController() : channel_(NULL), |
| void AppShimController::Init() { |
| DCHECK(g_io_thread); |
| + |
| + SetUpMenu(); |
| + |
| + // Open an IPC channel to Chrome and send the initial app launch message. |
| NSString* chrome_bundle_path = |
| base::SysUTF8ToNSString(g_info->chrome_outer_bundle_path.value()); |
| NSBundle* chrome_bundle = [NSBundle bundleWithPath:chrome_bundle_path]; |
| @@ -123,6 +130,38 @@ void AppShimController::Init() { |
| [NSApp setDelegate:nsapp_delegate_]; |
| } |
| +void AppShimController::SetUpMenu() { |
| + NSString* title = base::SysUTF16ToNSString(g_info->app_mode_name); |
| + |
| + // Create a main menu since [NSApp mainMenu] is nil. |
| + base::scoped_nsobject<NSMenu> main_menu([[NSMenu alloc] initWithTitle:title]); |
| + |
| + // The title of the first item is replaced by OSX with the name of the app and |
| + // bold styling. Create a dummy item for this and make it hidden. |
| + NSMenuItem* dummy_item = [main_menu addItemWithTitle:title |
| + action:nil |
| + keyEquivalent:@""]; |
| + base::scoped_nsobject<NSMenu> dummy_submenu( |
| + [[NSMenu alloc] initWithTitle:title]); |
| + [dummy_item setSubmenu:dummy_submenu]; |
|
tapted
2013/07/22 02:35:09
just checking - what happens if you delete this li
jackhou1
2013/07/22 11:27:04
The first item is still replaced, but it doesn't g
|
| + [dummy_item setHidden:YES]; |
| + |
| + // Construct an unbolded app menu, to match how it appears in the Chrome menu |
| + // bar when the app is focused. |
| + NSMenuItem* item = [main_menu addItemWithTitle:title |
| + action:nil |
| + keyEquivalent:@""]; |
| + base::scoped_nsobject<NSMenu> submenu([[NSMenu alloc] initWithTitle:title]); |
| + [item setSubmenu:submenu]; |
| + |
| + // Add a quit entry. |
| + [submenu addItemWithTitle:[@"Quit " stringByAppendingString:title] |
| + action:@selector(terminate:) |
| + keyEquivalent:@"q"]; |
| + |
| + [NSApp setMainMenu:main_menu]; |
| +} |
| + |
| void AppShimController::SendQuitApp() { |
| channel_->Send(new AppShimHostMsg_QuitApp); |
| } |