NaCl docs: add sanitizers to GSoC ideas
[chromium-blink-merge.git] / chrome / browser / app_controller_mac.h
blob4b2dc8984d6fa463780c1249d09a7ba993a6344c
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 // Indicates wheter an NSPopover is currently being shown.
89 BOOL hasPopover_;
91 // If we are expecting a workspace change in response to a reopen
92 // event, the time we got the event. A null time otherwise.
93 base::TimeTicks reopenTime_;
95 // Observers that listen to the work area changes.
96 ObserverList<ui::WorkAreaWatcherObserver> workAreaChangeObservers_;
98 scoped_ptr<PrefChangeRegistrar> profilePrefRegistrar_;
99 PrefChangeRegistrar localPrefRegistrar_;
101 // Displays a notification when quitting while apps are running.
102 scoped_refptr<QuitWithAppsController> quitWithAppsController_;
104 // Responsible for maintaining all state related to the Handoff feature.
105 base::scoped_nsobject<HandoffManager> handoffManager_;
107 // Observes changes to the active URL.
108 scoped_ptr<HandoffActiveURLObserverBridge>
109 handoff_active_url_observer_bridge_;
111 // This will be true after receiving a NSWorkspaceWillPowerOffNotification.
112 BOOL isPoweringOff_;
115 @property(readonly, nonatomic) BOOL startupComplete;
116 @property(readonly, nonatomic) Profile* lastProfile;
118 - (void)didEndMainMessageLoop;
120 // Try to close all browser windows, and if that succeeds then quit.
121 - (BOOL)tryToTerminateApplication:(NSApplication*)app;
123 // Stop trying to terminate the application. That is, prevent the final browser
124 // window closure from causing the application to quit.
125 - (void)stopTryingToTerminateApplication:(NSApplication*)app;
127 // Indicate that the system is powering off or logging out.
128 - (void)willPowerOff:(NSNotification*)inNotification;
130 // Returns true if there is a modal window (either window- or application-
131 // modal) blocking the active browser. Note that tab modal dialogs (HTTP auth
132 // sheets) will not count as blocking the browser. But things like open/save
133 // dialogs that are window modal will block the browser.
134 - (BOOL)keyWindowIsModal;
136 // Show the preferences window, or bring it to the front if it's already
137 // visible.
138 - (IBAction)showPreferences:(id)sender;
140 // Redirect in the menu item from the expected target of "File's
141 // Owner" (NSApplication) for a Branded About Box
142 - (IBAction)orderFrontStandardAboutPanel:(id)sender;
144 // Toggles the "Confirm to Quit" preference.
145 - (IBAction)toggleConfirmToQuit:(id)sender;
147 // Toggles the "Hide Notifications Icon" preference.
148 - (IBAction)toggleDisplayMessageCenter:(id)sender;
150 // Delegate method to return the dock menu.
151 - (NSMenu*)applicationDockMenu:(NSApplication*)sender;
153 // Get the URLs that Launch Services expects the browser to open at startup.
154 - (const std::vector<GURL>&)startupUrls;
156 - (BookmarkMenuBridge*)bookmarkMenuBridge;
158 // Subscribes/unsubscribes from the work area change notification.
159 - (void)addObserverForWorkAreaChange:(ui::WorkAreaWatcherObserver*)observer;
160 - (void)removeObserverForWorkAreaChange:(ui::WorkAreaWatcherObserver*)observer;
162 // Initializes the AppShimMenuController. This enables changing the menu bar for
163 // apps.
164 - (void)initAppShimMenuController;
166 // Called when the user has changed browser windows, meaning the backing profile
167 // may have changed. This can cause a rebuild of the user-data menus. This is a
168 // no-op if the new profile is the same as the current one. This will always be
169 // the original profile and never incognito.
170 - (void)windowChangedToProfile:(Profile*)profile;
172 @end
174 #endif // __OBJC__
176 // Functions that may be accessed from non-Objective-C C/C++ code.
178 namespace app_controller_mac {
180 // True if we are currently handling an IDC_NEW_{TAB,WINDOW} command. Used in
181 // SessionService::Observe() to get around windows/linux and mac having
182 // different models of application lifetime.
183 bool IsOpeningNewWindow();
185 } // namespace app_controller_mac
187 #endif