Home | History | Annotate | Download | only in browser
      1 // Copyright (c) 2011 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 #import "base/mac/cocoa_protocols.h"
     13 #include "base/memory/scoped_nsobject.h"
     14 #include "base/memory/scoped_ptr.h"
     15 
     16 @class AboutWindowController;
     17 class BookmarkMenuBridge;
     18 class CommandUpdater;
     19 class GURL;
     20 class HistoryMenuBridge;
     21 class 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                                     NSApplicationDelegate> {
     28  @private
     29   scoped_ptr<CommandUpdater> menuState_;
     30   // Management of the bookmark menu which spans across all windows
     31   // (and Browser*s).
     32   scoped_ptr<BookmarkMenuBridge> bookmarkMenuBridge_;
     33   scoped_ptr<HistoryMenuBridge> historyMenuBridge_;
     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 // Toggles the "Confirm to Quit" preference.
     84 - (IBAction)toggleConfirmToQuit:(id)sender;
     85 
     86 // Delegate method to return the dock menu.
     87 - (NSMenu*)applicationDockMenu:(NSApplication*)sender;
     88 
     89 // Get the URLs that Launch Services expects the browser to open at startup.
     90 - (const std::vector<GURL>&)startupUrls;
     91 
     92 // Clear the list of startup URLs.
     93 - (void)clearStartupUrls;
     94 
     95 @end
     96 
     97 #endif
     98