Update broken references to image assets
[chromium-blink-merge.git] / chrome / browser / app_controller_mac.h
blob421e998fc96233483475839480df3dec78e8b6d8
1 // Copyright (c) 2012 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.
5 #ifndef CHROME_BROWSER_APP_CONTROLLER_MAC_H_
6 #define CHROME_BROWSER_APP_CONTROLLER_MAC_H_
8 #if defined(__OBJC__)
10 #import <Cocoa/Cocoa.h>
11 #include <vector>
13 #include "base/files/file_path.h"
14 #include "base/mac/scoped_nsobject.h"
15 #include "base/memory/scoped_ptr.h"
16 #include "base/observer_list.h"
17 #include "base/prefs/pref_change_registrar.h"
18 #include "base/time/time.h"
19 #include "ui/base/work_area_watcher_observer.h"
21 class AppControllerProfileObserver;
22 @class AppShimMenuController;
23 class BookmarkMenuBridge;
24 class CommandUpdater;
25 class GURL;
26 class HandoffActiveURLObserverBridge;
27 @class HandoffManager;
28 class HistoryMenuBridge;
29 class Profile;
30 @class ProfileMenuController;
31 class QuitWithAppsController;
33 namespace ui {
34 class WorkAreaWatcherObserver;
37 // The application controller object, created by loading the MainMenu nib.
38 // This handles things like responding to menus when there are no windows
39 // open, etc and acts as the NSApplication delegate.
40 @interface AppController : NSObject<NSUserInterfaceValidations,
41 NSMenuDelegate,
42 NSApplicationDelegate> {
43 @private
44 // Manages the state of the command menu items.
45 scoped_ptr<CommandUpdater> menuState_;
47 // The profile last used by a Browser. It is this profile that was used to
48 // build the user-data specific main menu items.
49 Profile* lastProfile_;
51 // The ProfileObserver observes the ProfileInfoCache and gets notified
52 // when a profile has been deleted.
53 scoped_ptr<AppControllerProfileObserver> profileInfoCacheObserver_;
55 // Management of the bookmark menu which spans across all windows
56 // (and Browser*s). |profileBookmarkMenuBridgeMap_| is a cache that owns one
57 // pointer to a BookmarkMenuBridge for each profile. |bookmarkMenuBridge_| is
58 // a weak pointer that is updated to match the corresponding cache entry
59 // during a profile switch.
60 BookmarkMenuBridge* bookmarkMenuBridge_;
61 std::map<base::FilePath, BookmarkMenuBridge*> profileBookmarkMenuBridgeMap_;
63 scoped_ptr<HistoryMenuBridge> historyMenuBridge_;
65 // Controller that manages main menu items for packaged apps.
66 base::scoped_nsobject<AppShimMenuController> appShimMenuController_;
68 // The profile menu, which appears right before the Help menu. It is only
69 // available when multiple profiles is enabled.
70 base::scoped_nsobject<ProfileMenuController> profileMenuController_;
72 // If we're told to open URLs (in particular, via |-application:openFiles:| by
73 // Launch Services) before we've launched the browser, we queue them up in
74 // |startupUrls_| so that they can go in the first browser window/tab.
75 std::vector<GURL> startupUrls_;
76 BOOL startupComplete_;
78 // Outlets for the close tab/window menu items so that we can adjust the
79 // commmand-key equivalent depending on the kind of window and how many
80 // tabs it has.
81 IBOutlet NSMenuItem* closeTabMenuItem_;
82 IBOutlet NSMenuItem* closeWindowMenuItem_;
84 // Outlet for the help menu so we can bless it so Cocoa adds the search item
85 // to it.
86 IBOutlet NSMenu* helpMenu_;
88 // If we are expecting a workspace change in response to a reopen
89 // event, the time we got the event. A null time otherwise.
90 base::TimeTicks reopenTime_;
92 // Observers that listen to the work area changes.
93 base::ObserverList<ui::WorkAreaWatcherObserver> workAreaChangeObservers_;
95 scoped_ptr<PrefChangeRegistrar> profilePrefRegistrar_;
96 PrefChangeRegistrar localPrefRegistrar_;
98 // Displays a notification when quitting while apps are running.
99 scoped_refptr<QuitWithAppsController> quitWithAppsController_;
101 // Responsible for maintaining all state related to the Handoff feature.
102 base::scoped_nsobject<HandoffManager> handoffManager_;
104 // Observes changes to the active URL.
105 scoped_ptr<HandoffActiveURLObserverBridge>
106 handoff_active_url_observer_bridge_;
108 // This will be true after receiving a NSWorkspaceWillPowerOffNotification.
109 BOOL isPoweringOff_;
112 @property(readonly, nonatomic) BOOL startupComplete;
113 @property(readonly, nonatomic) Profile* lastProfile;
115 - (void)didEndMainMessageLoop;
117 // Try to close all browser windows, and if that succeeds then quit.
118 - (BOOL)tryToTerminateApplication:(NSApplication*)app;
120 // Stop trying to terminate the application. That is, prevent the final browser
121 // window closure from causing the application to quit.
122 - (void)stopTryingToTerminateApplication:(NSApplication*)app;
124 // Indicate that the system is powering off or logging out.
125 - (void)willPowerOff:(NSNotification*)inNotification;
127 // Returns true if there is a modal window (either window- or application-
128 // modal) blocking the active browser. Note that tab modal dialogs (HTTP auth
129 // sheets) will not count as blocking the browser. But things like open/save
130 // dialogs that are window modal will block the browser.
131 - (BOOL)keyWindowIsModal;
133 // Show the preferences window, or bring it to the front if it's already
134 // visible.
135 - (IBAction)showPreferences:(id)sender;
137 // Redirect in the menu item from the expected target of "File's
138 // Owner" (NSApplication) for a Branded About Box
139 - (IBAction)orderFrontStandardAboutPanel:(id)sender;
141 // Toggles the "Confirm to Quit" preference.
142 - (IBAction)toggleConfirmToQuit:(id)sender;
144 // Toggles the "Hide Notifications Icon" preference.
145 - (IBAction)toggleDisplayMessageCenter:(id)sender;
147 // Delegate method to return the dock menu.
148 - (NSMenu*)applicationDockMenu:(NSApplication*)sender;
150 // Get the URLs that Launch Services expects the browser to open at startup.
151 - (const std::vector<GURL>&)startupUrls;
153 - (BookmarkMenuBridge*)bookmarkMenuBridge;
154 - (HistoryMenuBridge*)historyMenuBridge;
156 // Subscribes/unsubscribes from the work area change notification.
157 - (void)addObserverForWorkAreaChange:(ui::WorkAreaWatcherObserver*)observer;
158 - (void)removeObserverForWorkAreaChange:(ui::WorkAreaWatcherObserver*)observer;
160 // Initializes the AppShimMenuController. This enables changing the menu bar for
161 // apps.
162 - (void)initAppShimMenuController;
164 // Called when the user has changed browser windows, meaning the backing profile
165 // may have changed. This can cause a rebuild of the user-data menus. This is a
166 // no-op if the new profile is the same as the current one. This will always be
167 // the original profile and never incognito.
168 - (void)windowChangedToProfile:(Profile*)profile;
170 @end
172 #endif // __OBJC__
174 // Functions that may be accessed from non-Objective-C C/C++ code.
176 namespace app_controller_mac {
178 // True if we are currently handling an IDC_NEW_{TAB,WINDOW} command. Used in
179 // SessionService::Observe() to get around windows/linux and mac having
180 // different models of application lifetime.
181 bool IsOpeningNewWindow();
183 } // namespace app_controller_mac
185 #endif