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

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: 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..8d80d3f439d86344c42434da4d8d9e5860f7e9b9 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,34 @@ void AppShimController::Init() {
[NSApp setDelegate:nsapp_delegate_];
}
+void AppShimController::SetUpMenu() {
+ // The title of the first item is replaced by OSX with the name of the app and
+ // bold styling. Since the title can't be replaced, it is hidden in Chrome and
+ // the app title has non-bold styling. We can match that here by adding a
+ // first element and hiding it.
+ NSString* title = base::SysUTF16ToNSString(g_info->app_mode_name);
+ base::scoped_nsobject<NSMenu> mainMenu([[NSMenu alloc] initWithTitle:title]);
tapted 2013/07/17 07:48:24 nit: mainMenu -> main_menu, since we're in a C++ c
jackhou1 2013/07/22 00:51:46 Done.
+ for (int i = 0; i < 2; ++i) {
tapted 2013/07/17 07:48:24 Not sure you need the loop.. can you explain the a
jackhou1 2013/07/22 00:51:46 Done. Yeah, when all of the app's windows are clo
+ base::scoped_nsobject<NSMenuItem> item(
+ [[NSMenuItem alloc] initWithTitle:title
+ action:nil
+ keyEquivalent:@""]);
+ base::scoped_nsobject<NSMenu> menu([[NSMenu alloc] initWithTitle:title]);
+ [item setSubmenu:menu];
+ [mainMenu addItem:item];
+ }
+ [[mainMenu itemAtIndex:0] setHidden:YES];
+
+ NSMenu* submenu = [[mainMenu itemAtIndex:1] submenu];
+ base::scoped_nsobject<NSMenuItem> item(
+ [[NSMenuItem alloc] initWithTitle:[@"Quit " stringByAppendingString:title]
tapted 2013/07/17 07:48:24 I think you need localization on the string "Quit"
jackhou1 2013/07/22 00:51:46 This turns out to be harder than I thought because
tapted 2013/07/22 02:35:09 Can you just call ResourceBundle::InitSharedIn
jackhou1 2013/07/22 11:27:04 Ah yup, this is necessary. I also needed to add an
+ action:@selector(terminate:)
+ keyEquivalent:@"q"]);
+ [submenu addItem:item];
+
+ [NSApp setMainMenu:mainMenu];
+}
+
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