app_controller_mac.h revision 3345a6884c488ff3a535c2c9acdd33d74b37e311
1// Copyright (c) 2010 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#pragma once
8
9#import <Cocoa/Cocoa.h>
10#include <vector>
11
12#include "base/scoped_nsobject.h"
13#include "base/scoped_ptr.h"
14
15@class AboutWindowController;
16class BookmarkMenuBridge;
17class CommandUpdater;
18class GURL;
19class HistoryMenuBridge;
20@class PreferencesWindowController;
21class Profile;
22
23// The application controller object, created by loading the MainMenu nib.
24// This handles things like responding to menus when there are no windows
25// open, etc and acts as the NSApplication delegate.
26@interface AppController : NSObject<NSUserInterfaceValidations> {
27 @private
28  scoped_ptr<CommandUpdater> menuState_;
29  // Management of the bookmark menu which spans across all windows
30  // (and Browser*s).
31  scoped_ptr<BookmarkMenuBridge> bookmarkMenuBridge_;
32  scoped_ptr<HistoryMenuBridge> historyMenuBridge_;
33  PreferencesWindowController* prefsController_;  // Weak.
34  AboutWindowController* aboutController_;  // Weak.
35
36  // If we're told to open URLs (in particular, via |-application:openFiles:| by
37  // Launch Services) before we've launched the browser, we queue them up in
38  // |startupUrls_| so that they can go in the first browser window/tab.
39  std::vector<GURL> startupUrls_;
40  BOOL startupComplete_;
41
42  // Outlets for the close tab/window menu items so that we can adjust the
43  // commmand-key equivalent depending on the kind of window and how many
44  // tabs it has.
45  IBOutlet NSMenuItem* closeTabMenuItem_;
46  IBOutlet NSMenuItem* closeWindowMenuItem_;
47  BOOL fileMenuUpdatePending_;  // ensure we only do this once per notificaion.
48
49  // Outlet for the help menu so we can bless it so Cocoa adds the search item
50  // to it.
51  IBOutlet NSMenu* helpMenu_;
52
53  // Outlet for the tabpose menu item so we can hide it.
54  IBOutlet NSMenuItem* tabposeMenuItem_;
55}
56
57@property(readonly, nonatomic) BOOL startupComplete;
58
59- (void)didEndMainMessageLoop;
60- (Profile*)defaultProfile;
61
62// Try to close all browser windows, and if that succeeds then quit.
63- (BOOL)tryToTerminateApplication:(NSApplication*)app;
64
65// Stop trying to terminate the application. That is, prevent the final browser
66// window closure from causing the application to quit.
67- (void)stopTryingToTerminateApplication:(NSApplication*)app;
68
69// Returns true if there is not a modal window (either window- or application-
70// modal) blocking the active browser. Note that tab modal dialogs (HTTP auth
71// sheets) will not count as blocking the browser. But things like open/save
72// dialogs that are window modal will block the browser.
73- (BOOL)keyWindowIsNotModal;
74
75// Show the preferences window, or bring it to the front if it's already
76// visible.
77- (IBAction)showPreferences:(id)sender;
78
79// Redirect in the menu item from the expected target of "File's
80// Owner" (NSAppliation) for a Branded About Box
81- (IBAction)orderFrontStandardAboutPanel:(id)sender;
82
83// Delegate method to return the dock menu.
84- (NSMenu*)applicationDockMenu:(NSApplication*)sender;
85
86// Get the URLs that Launch Services expects the browser to open at startup.
87- (const std::vector<GURL>&)startupUrls;
88
89// Clear the list of startup URLs.
90- (void)clearStartupUrls;
91
92@end
93
94#endif
95