summaryrefslogtreecommitdiffstats
path: root/chrome/browser/app_controller_mac.mm
diff options
context:
space:
mode:
authorrsesek@chromium.org <rsesek@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-07-19 19:52:46 +0000
committerrsesek@chromium.org <rsesek@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-07-19 19:52:46 +0000
commit961a693913f9effd9b7eae0ab3d17dd899306188 (patch)
tree209b9783167d4f7d453a452b5c017d3d17eb4f3e /chrome/browser/app_controller_mac.mm
parent2e9c23f5c7049beead982ee0834b7e91395debee (diff)
downloadchromium_src-961a693913f9effd9b7eae0ab3d17dd899306188.zip
chromium_src-961a693913f9effd9b7eae0ab3d17dd899306188.tar.gz
chromium_src-961a693913f9effd9b7eae0ab3d17dd899306188.tar.bz2
[Mac] Add the Profile menu to the main menubar.
This creates a ProfileMenuController that is owned by the AppController. It is responsible for managing the menu and menu item title. XIB changes: * Add a new menu item with no submenu called Profile with tag IDC_PROFILE_MAIN_MENU. BUG=86179 TEST=With --multi-profiles, a Profile menu is displayed in the menubar. Review URL: http://codereview.chromium.org/7331029 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@93080 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/app_controller_mac.mm')
-rw-r--r--chrome/browser/app_controller_mac.mm19
1 files changed, 19 insertions, 0 deletions
diff --git a/chrome/browser/app_controller_mac.mm b/chrome/browser/app_controller_mac.mm
index d0abfce..4eb186f 100644
--- a/chrome/browser/app_controller_mac.mm
+++ b/chrome/browser/app_controller_mac.mm
@@ -41,6 +41,7 @@
#import "chrome/browser/ui/cocoa/confirm_quit_panel_controller.h"
#import "chrome/browser/ui/cocoa/encoding_menu_controller_delegate_mac.h"
#import "chrome/browser/ui/cocoa/history_menu_bridge.h"
+#import "chrome/browser/ui/cocoa/profile_menu_controller.h"
#import "chrome/browser/ui/cocoa/tabs/tab_strip_controller.h"
#import "chrome/browser/ui/cocoa/tabs/tab_window_controller.h"
#include "chrome/browser/ui/cocoa/task_manager_mac.h"
@@ -154,6 +155,7 @@ void RecordLastRunAppBundlePath() {
@interface AppController (Private)
- (void)initMenuState;
+- (void)initProfileMenu;
- (void)updateConfirmToQuitPrefMenuItem:(NSMenuItem*)item;
- (void)registerServicesMenuTypesTo:(NSApplication*)app;
- (void)openUrls:(const std::vector<GURL>&)urls;
@@ -214,6 +216,9 @@ void RecordLastRunAppBundlePath() {
// Set up the command updater for when there are no windows open
[self initMenuState];
+
+ // Initialize the Profile menu.
+ [self initProfileMenu];
}
// (NSApplicationDelegate protocol) This is the Apple-approved place to override
@@ -971,6 +976,20 @@ void RecordLastRunAppBundlePath() {
menuState_->UpdateCommandEnabled(IDC_TASK_MANAGER, true);
}
+// Conditionally adds the Profile menu to the main menu bar.
+- (void)initProfileMenu {
+ bool enableMenu = ProfileManager::IsMultipleProfilesEnabled();
+
+ NSMenu* mainMenu = [NSApp mainMenu];
+ NSMenuItem* profileMenu = [mainMenu itemWithTag:IDC_PROFILE_MAIN_MENU];
+ [profileMenu setHidden:!enableMenu];
+
+ if (enableMenu) {
+ profileMenuController_.reset(
+ [[ProfileMenuController alloc] initWithMainMenuItem:profileMenu]);
+ }
+}
+
// The Confirm to Quit preference is atypical in that the preference lives in
// the app menu right above the Quit menu item. This method will refresh the
// display of that item depending on the preference state.