1// Copyright 2014 The Chromium Authors. All rights reserved. 2// Use of this source code is governed by a BSD-style license that can be 3// found in the LICENSE file. 4 5#ifndef CHROME_BROWSER_UI_COCOA_PROFILES_PROFILE_MENU_CONTROLLER_H_ 6#define CHROME_BROWSER_UI_COCOA_PROFILES_PROFILE_MENU_CONTROLLER_H_ 7 8#import <Cocoa/Cocoa.h> 9 10#include "base/memory/scoped_ptr.h" 11 12class AvatarMenu; 13class Browser; 14 15namespace ProfileMenuControllerInternal { 16class Observer; 17} 18 19// This controller manages the title and submenu of the Profiles item in the 20// system menu bar. It updates the contents of the menu and the menu's title 21// whenever the active browser changes. 22@interface ProfileMenuController : NSObject { 23 @private 24 // The controller for the profile submenu. 25 scoped_ptr<AvatarMenu> menu_; 26 27 // An observer to be notified when the active browser changes and when the 28 // menu model changes. 29 scoped_ptr<ProfileMenuControllerInternal::Observer> observer_; 30 31 // The main menu item to which the profile menu is attached. 32 __weak NSMenuItem* mainMenuItem_; 33} 34 35// Designated initializer. 36- (id)initWithMainMenuItem:(NSMenuItem*)item; 37 38// Actions for the menu items. 39- (IBAction)switchToProfileFromMenu:(id)sender; 40- (IBAction)switchToProfileFromDock:(id)sender; 41- (IBAction)editProfile:(id)sender; 42- (IBAction)newProfile:(id)sender; 43 44// If profiles are enabled and there is more than one profile, this inserts 45// profile menu items into the specified menu at the specified offset and 46// returns YES. Otherwise, this returns NO and does not modify the menu. 47- (BOOL)insertItemsIntoMenu:(NSMenu*)menu 48 atOffset:(NSInteger)offset 49 fromDock:(BOOL)dock; 50 51@end 52 53@interface ProfileMenuController (PrivateExposedForTesting) 54- (NSMenu*)menu; 55- (void)rebuildMenu; 56- (NSMenuItem*)createItemWithTitle:(NSString*)title action:(SEL)sel; 57- (void)activeBrowserChangedTo:(Browser*)browser; 58@end 59 60#endif // CHROME_BROWSER_UI_COCOA_PROFILES_PROFILE_MENU_CONTROLLER_H_ 61