// Copyright (c) 2009 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef CHROME_BROWSER_COCOA_BROWSER_WINDOW_CONTROLLER_H_ #define CHROME_BROWSER_COCOA_BROWSER_WINDOW_CONTROLLER_H_ // A class acting as the Objective-C controller for the Browser object. Handles // interactions between Cocoa and the cross-platform code. Each window has a // single set of toolbars (main toolbar, bookmark bar, etc) and, by virtue of // being a TabWindowController, a tab strip along the top. #import #include "base/scoped_nsobject.h" #include "base/scoped_ptr.h" #import "chrome/browser/cocoa/tab_window_controller.h" @class BookmarkBarController; class Browser; class BrowserWindow; class BrowserWindowCocoa; @class FindBarCocoaController; class LocationBar; class StatusBubble; class TabContents; @class TabContentsController; @class TabStripController; class TabStripModelObserverBridge; @class TabStripView; @class ToolbarController; @interface BrowserWindowController : TabWindowController { @private // The ordering of these members is important as it determines the order in // which they are destroyed. |browser_| needs to be destroyed last as most of // the other objects hold weak references to it or things it owns // (tab/toolbar/bookmark models, profiles, etc). We hold a strong ref to the // window so that it will live after the NSWindowController dealloc has run // (which happens *before* these scoped pointers are torn down). Keeping it // alive ensures that weak view or window pointers remain valid through // their destruction sequence. scoped_ptr browser_; scoped_nsobject window_; scoped_ptr tabObserver_; scoped_ptr windowShim_; scoped_nsobject toolbarController_; scoped_nsobject bookmarkController_; scoped_nsobject tabStripController_; scoped_nsobject findBarCocoaController_; scoped_ptr statusBubble_; BOOL ownsBrowser_; // Only ever NO when testing } // Load the browser window nib and do any Cocoa-specific initialization. // Takes ownership of |browser|. - (id)initWithBrowser:(Browser*)browser; // Call to make the browser go away from other places in the cross-platform // code. - (void)destroyBrowser; // Access the C++ bridge between the NSWindow and the rest of Chromium. - (BrowserWindow*)browserWindow; // Access the C++ bridge object representing the location bar. - (LocationBar*)locationBar; // Access the C++ bridge object representing the status bubble for the window. - (StatusBubble*)statusBubble; // Updates the toolbar (and transitively the location bar) with the states of // the specified |tab|. If |shouldRestore| is true, we're switching // (back?) to this tab and should restore any previous location bar state // (such as user editing) as well. - (void)updateToolbarWithContents:(TabContents*)tab shouldRestoreState:(BOOL)shouldRestore; // Sets whether or not the current page in the frontmost tab is bookmarked. - (void)setStarredState:(BOOL)isStarred; // Return the rect, in WebKit coordinates (flipped), of the window's grow box // in the coordinate system of the content area of the currently selected tab. - (NSRect)selectedTabGrowBoxRect; // Called to tell the selected tab to update its loading state. - (void)setIsLoading:(BOOL)isLoading; // Called to start/stop the loading animations. - (void)updateLoadingAnimations:(BOOL)animate; // Make the location bar the first responder, if possible. - (void)focusLocationBar; - (BOOL)isBookmarkBarVisible; - (void)toggleBookmarkBar; // Retains the given FindBarCocoaController and adds its view to this // browser window. Must only be called once per // BrowserWindowController. - (void)addFindBar:(FindBarCocoaController*)findBarCocoaController; @end @interface BrowserWindowController(TestingAPI) // Allows us to initWithBrowser withOUT taking ownership of the browser. - (id)initWithBrowser:(Browser*)browser takeOwnership:(BOOL)ownIt; @end // BrowserWindowController(TestingAPI) #endif // CHROME_BROWSER_COCOA_BROWSER_WINDOW_CONTROLLER_H_