1ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen// Copyright (c) 2011 The Chromium Authors. All rights reserved. 2c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Use of this source code is governed by a BSD-style license that can be 3c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// found in the LICENSE file. 4c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 521d179b334e59e9a3bfcaed4c4430bef1bc5759dKristian Monsen#ifndef CHROME_BROWSER_UI_COCOA_BROWSER_WINDOW_CONTROLLER_H_ 621d179b334e59e9a3bfcaed4c4430bef1bc5759dKristian Monsen#define CHROME_BROWSER_UI_COCOA_BROWSER_WINDOW_CONTROLLER_H_ 73345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick#pragma once 8c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 9c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// A class acting as the Objective-C controller for the Browser 10c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// object. Handles interactions between Cocoa and the cross-platform 11c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// code. Each window has a single toolbar and, by virtue of being a 12c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// TabWindowController, a tab strip along the top. 13c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 14c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch#import <Cocoa/Cocoa.h> 15c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 16ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen#include "base/memory/scoped_nsobject.h" 17ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen#include "base/memory/scoped_ptr.h" 18c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch#include "chrome/browser/sync/sync_ui_util.h" 1921d179b334e59e9a3bfcaed4c4430bef1bc5759dKristian Monsen#import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.h" 2021d179b334e59e9a3bfcaed4c4430bef1bc5759dKristian Monsen#import "chrome/browser/ui/cocoa/bookmarks/bookmark_bubble_controller.h" 2121d179b334e59e9a3bfcaed4c4430bef1bc5759dKristian Monsen#import "chrome/browser/ui/cocoa/browser_command_executor.h" 2272a454cd3513ac24fbdd0e0cb9ad70b86a99b801Kristian Monsen#import "chrome/browser/ui/cocoa/tab_contents/tab_contents_controller.h" 2372a454cd3513ac24fbdd0e0cb9ad70b86a99b801Kristian Monsen#import "chrome/browser/ui/cocoa/tabs/tab_strip_controller.h" 2472a454cd3513ac24fbdd0e0cb9ad70b86a99b801Kristian Monsen#import "chrome/browser/ui/cocoa/tabs/tab_window_controller.h" 2521d179b334e59e9a3bfcaed4c4430bef1bc5759dKristian Monsen#import "chrome/browser/ui/cocoa/themed_window.h" 2621d179b334e59e9a3bfcaed4c4430bef1bc5759dKristian Monsen#import "chrome/browser/ui/cocoa/url_drop_target.h" 2721d179b334e59e9a3bfcaed4c4430bef1bc5759dKristian Monsen#import "chrome/browser/ui/cocoa/view_resizer.h" 28c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 29c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 30c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdochclass Browser; 31c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdochclass BrowserWindow; 32c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdochclass BrowserWindowCocoa; 33c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdochclass ConstrainedWindowMac; 343345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick@class DevToolsController; 35c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch@class DownloadShelfController; 36c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch@class FindBarCocoaController; 37c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch@class FullscreenController; 38c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch@class GTMWindowSheetController; 39c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch@class IncognitoImageView; 40c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch@class InfoBarContainerController; 41c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdochclass LocationBarViewMac; 42731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick@class PreviewableContentsController; 433345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick@class SidebarController; 44c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdochclass StatusBubbleMac; 45c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdochclass TabContents; 46c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch@class TabStripController; 47c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch@class TabStripView; 48c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch@class ToolbarController; 49c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 50c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 51c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch@interface BrowserWindowController : 52c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch TabWindowController<NSUserInterfaceValidations, 53c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch BookmarkBarControllerDelegate, 54c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch BrowserCommandExecutor, 553345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick ViewResizer, 564a5e2dc747d50c653511c68ccb2cfbfb740bd5a7Ben Murdoch TabContentsControllerDelegate, 573345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick TabStripControllerDelegate> { 58c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch @private 59c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch // The ordering of these members is important as it determines the order in 60c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch // which they are destroyed. |browser_| needs to be destroyed last as most of 61c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch // the other objects hold weak references to it or things it owns 62c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch // (tab/toolbar/bookmark models, profiles, etc). 63c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch scoped_ptr<Browser> browser_; 64c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch NSWindow* savedRegularWindow_; 65c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch scoped_ptr<BrowserWindowCocoa> windowShim_; 66c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch scoped_nsobject<ToolbarController> toolbarController_; 67c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch scoped_nsobject<TabStripController> tabStripController_; 68c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch scoped_nsobject<FindBarCocoaController> findBarCocoaController_; 69c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch scoped_nsobject<InfoBarContainerController> infoBarContainerController_; 70c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch scoped_nsobject<DownloadShelfController> downloadShelfController_; 71c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch scoped_nsobject<BookmarkBarController> bookmarkBarController_; 723345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick scoped_nsobject<DevToolsController> devToolsController_; 733345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick scoped_nsobject<SidebarController> sidebarController_; 74731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick scoped_nsobject<PreviewableContentsController> previewableContentsController_; 75c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch scoped_nsobject<FullscreenController> fullscreenController_; 76c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 77c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch // Strong. StatusBubble is a special case of a strong reference that 78c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch // we don't wrap in a scoped_ptr because it is acting the same 79c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch // as an NSWindowController in that it wraps a window that must 80c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch // be shut down before our destructors are called. 81c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch StatusBubbleMac* statusBubble_; 82c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 83c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch BookmarkBubbleController* bookmarkBubbleController_; // Weak. 84c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch BOOL initializing_; // YES while we are currently in initWithBrowser: 85c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch BOOL ownsBrowser_; // Only ever NO when testing 86c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 87c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch // The total amount by which we've grown the window up or down (to display a 88c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch // bookmark bar and/or download shelf), respectively; reset to 0 when moved 89c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch // away from the bottom/top or resized (or zoomed). 90c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch CGFloat windowTopGrowth_; 91c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch CGFloat windowBottomGrowth_; 92c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 93c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch // YES only if we're shrinking the window from an apparent zoomed state (which 94c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch // we'll only do if we grew it to the zoomed state); needed since we'll then 95c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch // restrict the amount of shrinking by the amounts specified above. Reset to 96c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch // NO on growth. 97c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch BOOL isShrinkingFromZoomed_; 98c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 99c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch // The raw accumulated zoom value and the actual zoom increments made for an 100c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch // an in-progress pinch gesture. 101c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch CGFloat totalMagnifyGestureAmount_; 102c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch NSInteger currentZoomStepDelta_; 103c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 104c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch // The view which shows the incognito badge (NULL if not an incognito window). 105c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch // Needed to access the view to move it to/from the fullscreen window. 106c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch scoped_nsobject<IncognitoImageView> incognitoBadge_; 107c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 108c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch // Lazily created view which draws the background for the floating set of bars 109c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch // in fullscreen mode (for window types having a floating bar; it remains nil 110c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch // for those which don't). 111c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch scoped_nsobject<NSView> floatingBarBackingView_; 112c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 113c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch // Tracks whether the floating bar is above or below the bookmark bar, in 114c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch // terms of z-order. 115c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch BOOL floatingBarAboveBookmarkBar_; 116c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 117c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch // The proportion of the floating bar which is shown (in fullscreen mode). 118c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch CGFloat floatingBarShownFraction_; 119c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 120c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch // Various UI elements/events may want to ensure that the floating bar is 121c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch // visible (in fullscreen mode), e.g., because of where the mouse is or where 122c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch // keyboard focus is. Whenever an object requires bar visibility, it has 123c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch // itself added to |barVisibilityLocks_|. When it no longer requires bar 124c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch // visibility, it has itself removed. 125c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch scoped_nsobject<NSMutableSet> barVisibilityLocks_; 126c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 127c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch // Bar visibility locks and releases only result (when appropriate) in changes 128c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch // in visible state when the following is |YES|. 129c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch BOOL barVisibilityUpdatesEnabled_; 130c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch} 131c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 132c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// A convenience class method which gets the |BrowserWindowController| for a 133c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// given window. This method returns nil if no window in the chain has a BWC. 134c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch+ (BrowserWindowController*)browserWindowControllerForWindow:(NSWindow*)window; 135c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 136c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// A convenience class method which gets the |BrowserWindowController| for a 137c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// given view. This is the controller for the window containing |view|, if it 138c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// is a BWC, or the first controller in the parent-window chain that is a 139c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// BWC. This method returns nil if no window in the chain has a BWC. 140c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch+ (BrowserWindowController*)browserWindowControllerForView:(NSView*)view; 141c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 142c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Load the browser window nib and do any Cocoa-specific initialization. 143c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Takes ownership of |browser|. 144c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch- (id)initWithBrowser:(Browser*)browser; 145c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 146c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Call to make the browser go away from other places in the cross-platform 147c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// code. 148c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch- (void)destroyBrowser; 149c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 150c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Access the C++ bridge between the NSWindow and the rest of Chromium. 151c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch- (BrowserWindow*)browserWindow; 152c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 153c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Return a weak pointer to the toolbar controller. 154c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch- (ToolbarController*)toolbarController; 155c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 156c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Return a weak pointer to the tab strip controller. 157c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch- (TabStripController*)tabStripController; 158c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 159dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen// Access the ObjC controller that contains the infobars. 160dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen- (InfoBarContainerController*)infoBarContainerController; 161dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen 162c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Access the C++ bridge object representing the status bubble for the window. 163c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch- (StatusBubbleMac*)statusBubble; 164c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 165c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Access the C++ bridge object representing the location bar. 166c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch- (LocationBarViewMac*)locationBarBridge; 167c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 168c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Updates the toolbar (and transitively the location bar) with the states of 169c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// the specified |tab|. If |shouldRestore| is true, we're switching 170c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// (back?) to this tab and should restore any previous location bar state 171c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// (such as user editing) as well. 172c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch- (void)updateToolbarWithContents:(TabContents*)tab 173c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch shouldRestoreState:(BOOL)shouldRestore; 174c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 175c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Sets whether or not the current page in the frontmost tab is bookmarked. 176c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch- (void)setStarredState:(BOOL)isStarred; 177c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 178c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Called to tell the selected tab to update its loading state. 179c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// |force| is set if the update is due to changing tabs, as opposed to 180c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// the page-load finishing. See comment in reload_button.h. 181c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch- (void)setIsLoading:(BOOL)isLoading force:(BOOL)force; 182c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 183c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Brings this controller's window to the front. 184c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch- (void)activate; 185c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 186c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Make the location bar the first responder, if possible. 187c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch- (void)focusLocationBar:(BOOL)selectAll; 188c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 189c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Make the (currently-selected) tab contents the first responder, if possible. 190c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch- (void)focusTabContents; 191c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 192c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Returns the frame of the regular (non-fullscreened) window (even if the 193c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// window is currently in fullscreen mode). The frame is returned in Cocoa 194c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// coordinates (origin in bottom-left). 195c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch- (NSRect)regularWindowFrame; 196c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 197c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch- (BOOL)isBookmarkBarVisible; 198c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 199c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Returns YES if the bookmark bar is currently animating. 200c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch- (BOOL)isBookmarkBarAnimating; 201c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 202c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Called after bookmark bar visibility changes (due to pref change or change in 203c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// tab/tab contents). 204c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch- (void)updateBookmarkBarVisibilityWithAnimation:(BOOL)animate; 205c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 206c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch- (BOOL)isDownloadShelfVisible; 207c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 208c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Lazily creates the download shelf in visible state if it doesn't exist yet. 209c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch- (DownloadShelfController*)downloadShelf; 210c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 211c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Retains the given FindBarCocoaController and adds its view to this 212c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// browser window. Must only be called once per 213c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// BrowserWindowController. 214c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch- (void)addFindBar:(FindBarCocoaController*)findBarCocoaController; 215c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 216c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// The user changed the theme. 217c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch- (void)userChangedTheme; 218c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 219c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Executes the command in the context of the current browser. 220c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// |command| is an integer value containing one of the constants defined in the 221513209b27ff55e2841eac0e4120199c23acce758Ben Murdoch// "chrome/app/chrome_command_ids.h" file. 222c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch- (void)executeCommand:(int)command; 223c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 2243345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick// Delegate method for the status bubble to query its base frame. 2253345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick- (NSRect)statusBubbleBaseFrame; 226c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 227c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Show the bookmark bubble (e.g. user just clicked on the STAR) 228c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch- (void)showBookmarkBubbleForURL:(const GURL&)url 229c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch alreadyBookmarked:(BOOL)alreadyBookmarked; 230c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 231c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Returns the (lazily created) window sheet controller of this window. Used 232c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// for the per-tab sheets. 233c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch- (GTMWindowSheetController*)sheetController; 234c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 235c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Requests that |window| is opened as a per-tab sheet to the current tab. 236c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch- (void)attachConstrainedWindow:(ConstrainedWindowMac*)window; 237c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Closes the tab sheet |window| and potentially shows the next sheet in the 238c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// tab's sheet queue. 239c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch- (void)removeConstrainedWindow:(ConstrainedWindowMac*)window; 240201ade2fbba22bfb27ae029f4d23fca6ded109a0Ben Murdoch// Returns NO if constrained windows cannot be attached to this window. 241201ade2fbba22bfb27ae029f4d23fca6ded109a0Ben Murdoch- (BOOL)canAttachConstrainedWindow; 242c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 243c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Shows or hides the docked web inspector depending on |contents|'s state. 244c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch- (void)updateDevToolsForContents:(TabContents*)contents; 245c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 2463345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick// Displays the active sidebar linked to the |contents| or hides sidebar UI, 2473345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick// if there's no such sidebar. 2483345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick- (void)updateSidebarForContents:(TabContents*)contents; 2493345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick 250c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Gets the current theme provider. 25172a454cd3513ac24fbdd0e0cb9ad70b86a99b801Kristian Monsen- (ui::ThemeProvider*)themeProvider; 252c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 253c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Gets the window style. 254c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch- (ThemedWindowStyle)themedWindowStyle; 255c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 256c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Gets the pattern phase for the window. 257c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch- (NSPoint)themePatternPhase; 258c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 259c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Return the point to which a bubble window's arrow should point. 260c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch- (NSPoint)bookmarkBubblePoint; 261c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 262c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Call when the user changes the tab strip display mode, enabling or 263c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// disabling vertical tabs for this browser. Re-flows the contents of the 264c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// browser. 265c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch- (void)toggleTabStripDisplayMode; 266c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 267731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick// Shows or hides the Instant preview contents. 268731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick- (void)showInstant:(TabContents*)previewContents; 269731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick- (void)hideInstant; 270ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen- (void)commitInstant; 271731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick 272731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick// Returns the frame, in Cocoa (unflipped) screen coordinates, of the area where 273731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick// Instant results are. If Instant is not showing, returns the frame of where 274731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick// it would be. 275731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick- (NSRect)instantFrame; 276731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick 277c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Called when the Add Search Engine dialog is closed. 278c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch- (void)sheetDidEnd:(NSWindow*)sheet 279c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch returnCode:(NSInteger)code 280c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch context:(void*)context; 281c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 282c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch@end // @interface BrowserWindowController 283c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 284c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 285c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Methods having to do with the window type (normal/popup/app, and whether the 286c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// window has various features; fullscreen methods are separate). 287c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch@interface BrowserWindowController(WindowType) 288c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 289c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Determines whether this controller's window supports a given feature (i.e., 290c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// whether a given feature is or can be shown in the window). 291c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// TODO(viettrungluu): |feature| is really should be |Browser::Feature|, but I 292c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// don't want to include browser.h (and you can't forward declare enums). 293c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch- (BOOL)supportsWindowFeature:(int)feature; 294c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 295c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Called to check whether or not this window has a normal title bar (YES if it 296c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// does, NO otherwise). (E.g., normal browser windows do not, pop-ups do.) 297c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch- (BOOL)hasTitleBar; 298c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 299c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Called to check whether or not this window has a toolbar (YES if it does, NO 300c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// otherwise). (E.g., normal browser windows do, pop-ups do not.) 301c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch- (BOOL)hasToolbar; 302c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 303c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Called to check whether or not this window has a location bar (YES if it 304c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// does, NO otherwise). (E.g., normal browser windows do, pop-ups may or may 305c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// not.) 306c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch- (BOOL)hasLocationBar; 307c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 308c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Called to check whether or not this window can have bookmark bar (YES if it 309c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// does, NO otherwise). (E.g., normal browser windows may, pop-ups may not.) 310c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch- (BOOL)supportsBookmarkBar; 311c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 312c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Called to check if this controller's window is a normal window (e.g., not a 313c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// pop-up window). Returns YES if it is, NO otherwise. 314c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Note: The |-has...| methods are usually preferred, so this method is largely 315c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// deprecated. 316c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch- (BOOL)isNormalWindow; 317c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 318c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch@end // @interface BrowserWindowController(WindowType) 319c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 320c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 321c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Methods having to do with fullscreen mode. 322c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch@interface BrowserWindowController(Fullscreen) 323c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 324ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen// Enters fullscreen mode. 325ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen- (IBAction)enterFullscreen:(id)sender; 326ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen 327c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Enters (or exits) fullscreen mode. 328c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch- (void)setFullscreen:(BOOL)fullscreen; 329c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 330c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Returns fullscreen state. 331c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch- (BOOL)isFullscreen; 332c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 333c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Resizes the fullscreen window to fit the screen it's currently on. Called by 334c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// the FullscreenController when there is a change in monitor placement or 335c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// resolution. 336c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch- (void)resizeFullscreenWindow; 337c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 338c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Gets or sets the fraction of the floating bar (fullscreen overlay) that is 339c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// shown. 0 is completely hidden, 1 is fully shown. 340c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch- (CGFloat)floatingBarShownFraction; 341c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch- (void)setFloatingBarShownFraction:(CGFloat)fraction; 342c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 343c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Query/lock/release the requirement that the tab strip/toolbar/attached 344c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// bookmark bar bar cluster is visible (e.g., when one of its elements has 345c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// focus). This is required for the floating bar in fullscreen mode, but should 346c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// also be called when not in fullscreen mode; see the comments for 347c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// |barVisibilityLocks_| for more details. Double locks/releases by the same 348c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// owner are ignored. If |animate:| is YES, then an animation may be performed, 349c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// possibly after a small delay if |delay:| is YES. If |animate:| is NO, 350c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// |delay:| will be ignored. In the case of multiple calls, later calls have 351c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// precedence with the rule that |animate:NO| has precedence over |animate:YES|, 352c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// and |delay:NO| has precedence over |delay:YES|. 353c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch- (BOOL)isBarVisibilityLockedForOwner:(id)owner; 354c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch- (void)lockBarVisibilityForOwner:(id)owner 355c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch withAnimation:(BOOL)animate 356c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch delay:(BOOL)delay; 357c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch- (void)releaseBarVisibilityForOwner:(id)owner 358c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch withAnimation:(BOOL)animate 359c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch delay:(BOOL)delay; 360c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 361c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Returns YES if any of the views in the floating bar currently has focus. 362c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch- (BOOL)floatingBarHasFocus; 363c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 3643345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick// Opens the tabpose window. 3653345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick- (void)openTabpose; 3663345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick 367c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch@end // @interface BrowserWindowController(Fullscreen) 368c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 369c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 370c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Methods which are either only for testing, or only public for testing. 371c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch@interface BrowserWindowController(TestingAPI) 372c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 373c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Put the incognito badge on the browser and adjust the tab strip 374c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// accordingly. 375c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch- (void)installIncognitoBadge; 376c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 377c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Allows us to initWithBrowser withOUT taking ownership of the browser. 378c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch- (id)initWithBrowser:(Browser*)browser takeOwnership:(BOOL)ownIt; 379c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 380c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Adjusts the window height by the given amount. If the window spans from the 381c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// top of the current workspace to the bottom of the current workspace, the 382c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// height is not adjusted. If growing the window by the requested amount would 383c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// size the window to be taller than the current workspace, the window height is 384c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// capped to be equal to the height of the current workspace. If the window is 385c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// partially offscreen, its height is not adjusted at all. This function 386c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// prefers to grow the window down, but will grow up if needed. Calls to this 387c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// function should be followed by a call to |layoutSubviews|. 388c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch- (void)adjustWindowHeightBy:(CGFloat)deltaH; 389c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 390c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Return an autoreleased NSWindow suitable for fullscreen use. 391c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch- (NSWindow*)createFullscreenWindow; 392c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 393c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Resets any saved state about window growth (due to showing the bookmark bar 394c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// or the download shelf), so that future shrinking will occur from the bottom. 395c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch- (void)resetWindowGrowthState; 396c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 3973345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick// Computes by how far in each direction, horizontal and vertical, the 3983345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick// |source| rect doesn't fit into |target|. 3993345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick- (NSSize)overflowFrom:(NSRect)source 4003345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick to:(NSRect)target; 401c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch@end // @interface BrowserWindowController(TestingAPI) 402c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 403c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 40421d179b334e59e9a3bfcaed4c4430bef1bc5759dKristian Monsen#endif // CHROME_BROWSER_UI_COCOA_BROWSER_WINDOW_CONTROLLER_H_ 405