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

Unified Diff: apps/app_shim/chrome_main_app_mode_mac.mm

Issue 19490002: Add a main menu to the shim that matches the one in Chrome. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments Created 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698