[M85 Dev][EFL] Fix errors to generate ninja files
[platform/framework/web/chromium-efl.git] / chrome / browser / app_controller_mac.h
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.
4
5 #ifndef CHROME_BROWSER_APP_CONTROLLER_MAC_H_
6 #define CHROME_BROWSER_APP_CONTROLLER_MAC_H_
7
8 #if defined(__OBJC__)
9
10 #import <Cocoa/Cocoa.h>
11
12 #include <memory>
13 #include <vector>
14
15 #include "base/files/file_path.h"
16 #include "base/mac/scoped_nsobject.h"
17 #include "base/time/time.h"
18 #include "components/prefs/pref_change_registrar.h"
19
20 class AppControllerProfileObserver;
21 @class AppShimMenuController;
22 class BookmarkMenuBridge;
23 class CommandUpdater;
24 class GURL;
25 class HandoffActiveURLObserverBridge;
26 @class HandoffManager;
27 class HistoryMenuBridge;
28 class Profile;
29 @class ProfileMenuController;
30 class QuitWithAppsController;
31 class ScopedKeepAlive;
32 @class ShareMenuController;
33 class TabMenuBridge;
34
35 // The application controller object, created by loading the MainMenu nib.
36 // This handles things like responding to menus when there are no windows
37 // open, etc and acts as the NSApplication delegate.
38 @interface AppController : NSObject<NSUserInterfaceValidations,
39                                     NSMenuDelegate,
40                                     NSApplicationDelegate> {
41  @private
42   // Manages the state of the command menu items.
43   std::unique_ptr<CommandUpdater> _menuState;
44
45   // The profile last used by a Browser. It is this profile that was used to
46   // build the user-data specific main menu items.
47   Profile* _lastProfile;
48
49   // The ProfileObserver observes the ProfileAttrbutesStorage and gets notified
50   // when a profile has been deleted.
51   std::unique_ptr<AppControllerProfileObserver>
52       _profileAttributesStorageObserver;
53
54   // Management of the bookmark menu which spans across all windows
55   // (and Browser*s). |profileBookmarkMenuBridgeMap_| is a cache that owns one
56   // pointer to a BookmarkMenuBridge for each profile. |bookmarkMenuBridge_| is
57   // a weak pointer that is updated to match the corresponding cache entry
58   // during a profile switch.
59   BookmarkMenuBridge* _bookmarkMenuBridge;
60   std::map<base::FilePath, std::unique_ptr<BookmarkMenuBridge>>
61       _profileBookmarkMenuBridgeMap;
62
63   std::unique_ptr<HistoryMenuBridge> _historyMenuBridge;
64
65   // Controller that manages main menu items for packaged apps.
66   base::scoped_nsobject<AppShimMenuController> _appShimMenuController;
67
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;
71
72   // Controller for the macOS system share menu.
73   base::scoped_nsobject<ShareMenuController> _shareMenuController;
74
75   std::unique_ptr<TabMenuBridge> _tabMenuBridge;
76
77   // If we're told to open URLs (in particular, via |-application:openFiles:| by
78   // Launch Services) before we've launched the browser, we queue them up in
79   // |startupUrls_| so that they can go in the first browser window/tab.
80   std::vector<GURL> _startupUrls;
81   BOOL _startupComplete;
82
83   // Outlets for the close tab/window menu items so that we can adjust the
84   // commmand-key equivalent depending on the kind of window and how many
85   // tabs it has.
86   NSMenuItem* _closeTabMenuItem;
87   NSMenuItem* _closeWindowMenuItem;
88
89   // If we are expecting a workspace change in response to a reopen
90   // event, the time we got the event. A null time otherwise.
91   base::TimeTicks _reopenTime;
92
93   std::unique_ptr<PrefChangeRegistrar> _profilePrefRegistrar;
94   PrefChangeRegistrar _localPrefRegistrar;
95
96   // Displays a notification when quitting while apps are running.
97   scoped_refptr<QuitWithAppsController> _quitWithAppsController;
98
99   // Responsible for maintaining all state related to the Handoff feature.
100   base::scoped_nsobject<HandoffManager> _handoffManager;
101
102   // Observes changes to the active URL.
103   std::unique_ptr<HandoffActiveURLObserverBridge>
104       _handoff_active_url_observer_bridge;
105
106   // This will be true after receiving a NSWorkspaceWillPowerOffNotification.
107   BOOL _isPoweringOff;
108
109   // Request to keep the browser alive during that object's lifetime.
110   std::unique_ptr<ScopedKeepAlive> _keep_alive;
111 }
112
113 @property(readonly, nonatomic) BOOL startupComplete;
114 @property(readonly, nonatomic) Profile* lastProfile;
115
116 // This method is called very early in application startup after the main menu
117 // has been created.
118 - (void)mainMenuCreated;
119
120 - (void)didEndMainMessageLoop;
121
122 // Try to close all browser windows, and if that succeeds then quit.
123 - (BOOL)tryToTerminateApplication:(NSApplication*)app;
124
125 // Stop trying to terminate the application. That is, prevent the final browser
126 // window closure from causing the application to quit.
127 - (void)stopTryingToTerminateApplication:(NSApplication*)app;
128
129 // Run the quit confirmation panel and return whether or not to continue
130 // quitting.
131 - (BOOL)runConfirmQuitPanel;
132
133 // Indicate that the system is powering off or logging out.
134 - (void)willPowerOff:(NSNotification*)inNotification;
135
136 // Returns true if there is a modal window (either window- or application-
137 // modal) blocking the active browser. Note that tab modal dialogs (HTTP auth
138 // sheets) will not count as blocking the browser. But things like open/save
139 // dialogs that are window modal will block the browser.
140 - (BOOL)keyWindowIsModal;
141
142 // Called when the user picks a menu item when there are no key windows, or when
143 // there is no foreground browser window. Calls through to the browser object to
144 // execute the command. This assumes that the command is supported and doesn't
145 // check, otherwise it should have been disabled in the UI in
146 // |-validateUserInterfaceItem:|.
147 - (void)commandDispatch:(id)sender;
148
149 // Show the preferences window, or bring it to the front if it's already
150 // visible.
151 - (IBAction)showPreferences:(id)sender;
152
153 // Redirect in the menu item from the expected target of "File's
154 // Owner" (NSApplication) for a Branded About Box
155 - (IBAction)orderFrontStandardAboutPanel:(id)sender;
156
157 // Toggles the "Confirm to Quit" preference.
158 - (IBAction)toggleConfirmToQuit:(id)sender;
159
160 // Delegate method to return the dock menu.
161 - (NSMenu*)applicationDockMenu:(NSApplication*)sender;
162
163 // Get the URLs that Launch Services expects the browser to open at startup.
164 - (const std::vector<GURL>&)startupUrls;
165
166 - (BookmarkMenuBridge*)bookmarkMenuBridge;
167 - (HistoryMenuBridge*)historyMenuBridge;
168 - (TabMenuBridge*)tabMenuBridge;
169
170 // Initializes the AppShimMenuController. This enables changing the menu bar for
171 // apps.
172 - (void)initAppShimMenuController;
173
174 // Called when the user has changed browser windows, meaning the backing profile
175 // may have changed. This can cause a rebuild of the user-data menus. This is a
176 // no-op if the new profile is the same as the current one. This will always be
177 // the original profile and never incognito.
178 - (void)windowChangedToProfile:(Profile*)profile;
179
180 // Certain NSMenuItems [Close Tab and Close Window] have different
181 // keyEquivalents depending on context. This must be invoked in two locations:
182 //   * In menuNeedsUpdate:, which is called prior to showing the NSMenu.
183 //   * In CommandDispatcher, which independently searches for a matching
184 //     keyEquivalent.
185 - (void)updateMenuItemKeyEquivalents;
186
187 @end
188
189 #endif  // __OBJC__
190
191 // Functions that may be accessed from non-Objective-C C/C++ code.
192
193 namespace app_controller_mac {
194
195 // True if we are currently handling an IDC_NEW_{TAB,WINDOW} command. Used in
196 // SessionService::Observe() to get around windows/linux and mac having
197 // different models of application lifetime.
198 bool IsOpeningNewWindow();
199
200 // Create a guest profile if one is needed. Afterwards, even if the profile
201 // already existed, notify the AppController of the profile in use.
202 void CreateGuestProfileIfNeeded();
203
204 // Called when Enterprise startup dialog is close and repost
205 // applicationDidFinished notification.
206 void EnterpriseStartupDialogClosed();
207
208 }  // namespace app_controller_mac
209
210 #endif  // CHROME_BROWSER_APP_CONTROLLER_MAC_H_