Home | History | Annotate | Download | only in cocoa
      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_UI_COCOA_BROWSER_WINDOW_CONTROLLER_H_
      6 #define CHROME_BROWSER_UI_COCOA_BROWSER_WINDOW_CONTROLLER_H_
      7 
      8 // A class acting as the Objective-C controller for the Browser
      9 // object. Handles interactions between Cocoa and the cross-platform
     10 // code. Each window has a single toolbar and, by virtue of being a
     11 // TabWindowController, a tab strip along the top.
     12 
     13 #import <Cocoa/Cocoa.h>
     14 
     15 #include "base/mac/scoped_nsobject.h"
     16 #include "base/memory/scoped_ptr.h"
     17 #include "chrome/browser/translate/chrome_translate_client.h"
     18 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.h"
     19 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bubble_controller.h"
     20 #import "chrome/browser/ui/cocoa/browser_command_executor.h"
     21 #import "chrome/browser/ui/cocoa/fullscreen_exit_bubble_controller.h"
     22 #import "chrome/browser/ui/cocoa/tabs/tab_strip_controller.h"
     23 #import "chrome/browser/ui/cocoa/tabs/tab_window_controller.h"
     24 #import "chrome/browser/ui/cocoa/themed_window.h"
     25 #import "chrome/browser/ui/cocoa/url_drop_target.h"
     26 #import "chrome/browser/ui/cocoa/view_resizer.h"
     27 #include "components/translate/core/common/translate_errors.h"
     28 #include "ui/base/accelerators/accelerator_manager.h"
     29 #include "ui/gfx/rect.h"
     30 
     31 @class AvatarBaseController;
     32 class Browser;
     33 class BrowserWindow;
     34 class BrowserWindowCocoa;
     35 @class DevToolsController;
     36 @class DownloadShelfController;
     37 class ExtensionKeybindingRegistryCocoa;
     38 @class FindBarCocoaController;
     39 @class FullscreenModeController;
     40 @class FullscreenWindow;
     41 @class InfoBarContainerController;
     42 class LocationBarViewMac;
     43 @class OverlayableContentsController;
     44 class PermissionBubbleCocoa;
     45 @class PresentationModeController;
     46 class StatusBubbleMac;
     47 @class TabStripController;
     48 @class TabStripView;
     49 @class ToolbarController;
     50 @class TranslateBubbleController;
     51 
     52 namespace content {
     53 class WebContents;
     54 }
     55 
     56 namespace extensions {
     57 class Command;
     58 }
     59 
     60 @interface BrowserWindowController :
     61   TabWindowController<NSUserInterfaceValidations,
     62                       BookmarkBarControllerDelegate,
     63                       BrowserCommandExecutor,
     64                       ViewResizer,
     65                       TabStripControllerDelegate> {
     66  @private
     67   // The ordering of these members is important as it determines the order in
     68   // which they are destroyed. |browser_| needs to be destroyed last as most of
     69   // the other objects hold weak references to it or things it owns
     70   // (tab/toolbar/bookmark models, profiles, etc).
     71   scoped_ptr<Browser> browser_;
     72   NSWindow* savedRegularWindow_;
     73   scoped_ptr<BrowserWindowCocoa> windowShim_;
     74   base::scoped_nsobject<ToolbarController> toolbarController_;
     75   base::scoped_nsobject<TabStripController> tabStripController_;
     76   base::scoped_nsobject<FindBarCocoaController> findBarCocoaController_;
     77   base::scoped_nsobject<InfoBarContainerController> infoBarContainerController_;
     78   base::scoped_nsobject<DownloadShelfController> downloadShelfController_;
     79   base::scoped_nsobject<BookmarkBarController> bookmarkBarController_;
     80   base::scoped_nsobject<DevToolsController> devToolsController_;
     81   base::scoped_nsobject<OverlayableContentsController>
     82       overlayableContentsController_;
     83   base::scoped_nsobject<PresentationModeController> presentationModeController_;
     84   base::scoped_nsobject<FullscreenExitBubbleController>
     85       fullscreenExitBubbleController_;
     86 
     87   // Strong. StatusBubble is a special case of a strong reference that
     88   // we don't wrap in a scoped_ptr because it is acting the same
     89   // as an NSWindowController in that it wraps a window that must
     90   // be shut down before our destructors are called.
     91   StatusBubbleMac* statusBubble_;
     92 
     93   BookmarkBubbleController* bookmarkBubbleController_;  // Weak.
     94   BOOL initializing_;  // YES while we are currently in initWithBrowser:
     95   BOOL ownsBrowser_;  // Only ever NO when testing
     96 
     97   TranslateBubbleController* translateBubbleController_;  // Weak.
     98 
     99   // The total amount by which we've grown the window up or down (to display a
    100   // bookmark bar and/or download shelf), respectively; reset to 0 when moved
    101   // away from the bottom/top or resized (or zoomed).
    102   CGFloat windowTopGrowth_;
    103   CGFloat windowBottomGrowth_;
    104 
    105   // YES only if we're shrinking the window from an apparent zoomed state (which
    106   // we'll only do if we grew it to the zoomed state); needed since we'll then
    107   // restrict the amount of shrinking by the amounts specified above. Reset to
    108   // NO on growth.
    109   BOOL isShrinkingFromZoomed_;
    110 
    111   // The view controller that manages the incognito badge or the multi-profile
    112   // avatar button. Depending on whether the --new-profile-management flag is
    113   // used, the multi-profile button can either be the avatar's icon badge or a
    114   // button with the profile's name. If the flag is used, the button is always
    115   // shown, otherwise the view will always be in the view hierarchy but will
    116   // be hidden unless it's appropriate to show it (i.e. if there's more than
    117   // one profile).
    118   base::scoped_nsobject<AvatarBaseController> avatarButtonController_;
    119 
    120   // Lazily created view which draws the background for the floating set of bars
    121   // in presentation mode (for window types having a floating bar; it remains
    122   // nil for those which don't).
    123   base::scoped_nsobject<NSView> floatingBarBackingView_;
    124 
    125   // The borderless window used in fullscreen mode when Cocoa's System
    126   // Fullscreen API is not being used (or not available, before OS 10.7).
    127   base::scoped_nsobject<NSWindow> fullscreenWindow_;
    128 
    129   // The Cocoa implementation of the PermissionBubbleView.
    130   scoped_ptr<PermissionBubbleCocoa> permissionBubbleCocoa_;
    131 
    132   // True between |-windowWillEnterFullScreen:| and |-windowDidEnterFullScreen:|
    133   // to indicate that the window is in the process of transitioning into
    134   // AppKit fullscreen mode.
    135   BOOL enteringAppKitFullscreen_;
    136 
    137   // Only adjust the tab strip once while entering fullscreen. See the
    138   // implementation of -[BrowserWindowController updateSubviewZOrder:] for more
    139   // details.
    140   BOOL hasAdjustedTabStripWhileEnteringAppKitFullscreen_;
    141 
    142   // True between |enterImmersiveFullscreen| and |-windowDidEnterFullScreen:|
    143   // to indicate that the window is in the process of transitioning into
    144   // AppKit fullscreen mode.
    145   BOOL enteringImmersiveFullscreen_;
    146 
    147   // True between |-setPresentationMode:url:bubbleType:| and
    148   // |-windowDidEnterFullScreen:| to indicate that the window is in the process
    149   // of transitioning into fullscreen presentation mode.
    150   BOOL enteringPresentationMode_;
    151 
    152   // The size of the original (non-fullscreen) window.  This is saved just
    153   // before entering fullscreen mode and is only valid when |-isFullscreen|
    154   // returns YES.
    155   NSRect savedRegularWindowFrame_;
    156 
    157   // The proportion of the floating bar which is shown (in presentation mode).
    158   CGFloat floatingBarShownFraction_;
    159 
    160   // Various UI elements/events may want to ensure that the floating bar is
    161   // visible (in presentation mode), e.g., because of where the mouse is or
    162   // where keyboard focus is. Whenever an object requires bar visibility, it has
    163   // itself added to |barVisibilityLocks_|. When it no longer requires bar
    164   // visibility, it has itself removed.
    165   base::scoped_nsobject<NSMutableSet> barVisibilityLocks_;
    166 
    167   // Bar visibility locks and releases only result (when appropriate) in changes
    168   // in visible state when the following is |YES|.
    169   BOOL barVisibilityUpdatesEnabled_;
    170 
    171   // When going fullscreen for a tab, we need to store the URL and the
    172   // fullscreen type, since we can't show the bubble until
    173   // -windowDidEnterFullScreen: gets called.
    174   GURL fullscreenUrl_;
    175   FullscreenExitBubbleType fullscreenBubbleType_;
    176 
    177   // The Extension Command Registry used to determine which keyboard events to
    178   // handle.
    179   scoped_ptr<ExtensionKeybindingRegistryCocoa> extension_keybinding_registry_;
    180 
    181   // Whether the root view of the window is layer backed.
    182   BOOL windowViewWantsLayer_;
    183 }
    184 
    185 // A convenience class method which gets the |BrowserWindowController| for a
    186 // given window. This method returns nil if no window in the chain has a BWC.
    187 + (BrowserWindowController*)browserWindowControllerForWindow:(NSWindow*)window;
    188 
    189 // A convenience class method which gets the |BrowserWindowController| for a
    190 // given view.  This is the controller for the window containing |view|, if it
    191 // is a BWC, or the first controller in the parent-window chain that is a
    192 // BWC. This method returns nil if no window in the chain has a BWC.
    193 + (BrowserWindowController*)browserWindowControllerForView:(NSView*)view;
    194 
    195 // Helper method used to update the "Signin" menu item to reflect the current
    196 // signed in state. Class-level function as it's still required even when there
    197 // are no open browser windows.
    198 + (void)updateSigninItem:(id)signinItem
    199               shouldShow:(BOOL)showSigninMenuItem
    200           currentProfile:(Profile*)profile;
    201 
    202 // Load the browser window nib and do any Cocoa-specific initialization.
    203 // Takes ownership of |browser|.
    204 - (id)initWithBrowser:(Browser*)browser;
    205 
    206 // Call to make the browser go away from other places in the cross-platform
    207 // code.
    208 - (void)destroyBrowser;
    209 
    210 // Ensure bounds for the window abide by the minimum window size.
    211 - (gfx::Rect)enforceMinWindowSize:(gfx::Rect)bounds;
    212 
    213 // Access the C++ bridge between the NSWindow and the rest of Chromium.
    214 - (BrowserWindow*)browserWindow;
    215 
    216 // Return a weak pointer to the toolbar controller.
    217 - (ToolbarController*)toolbarController;
    218 
    219 // Return a weak pointer to the tab strip controller.
    220 - (TabStripController*)tabStripController;
    221 
    222 // Return a weak pointer to the find bar controller.
    223 - (FindBarCocoaController*)findBarCocoaController;
    224 
    225 // Access the ObjC controller that contains the infobars.
    226 - (InfoBarContainerController*)infoBarContainerController;
    227 
    228 // Access the C++ bridge object representing the status bubble for the window.
    229 - (StatusBubbleMac*)statusBubble;
    230 
    231 // Access the C++ bridge object representing the location bar.
    232 - (LocationBarViewMac*)locationBarBridge;
    233 
    234 // Returns a weak pointer to the floating bar backing view;
    235 - (NSView*)floatingBarBackingView;
    236 
    237 // Returns a weak pointer to the overlayable contents controller.
    238 - (OverlayableContentsController*)overlayableContentsController;
    239 
    240 // Access the Profile object that backs this Browser.
    241 - (Profile*)profile;
    242 
    243 // Access the avatar button controller.
    244 - (AvatarBaseController*)avatarButtonController;
    245 
    246 // Forces the toolbar (and transitively the location bar) to update its current
    247 // state.  If |tab| is non-NULL, we're switching (back?) to this tab and should
    248 // restore any previous location bar state (such as user editing) as well.
    249 - (void)updateToolbarWithContents:(content::WebContents*)tab;
    250 
    251 // Sets whether or not the current page in the frontmost tab is bookmarked.
    252 - (void)setStarredState:(BOOL)isStarred;
    253 
    254 // Sets whether or not the current page is translated.
    255 - (void)setCurrentPageIsTranslated:(BOOL)on;
    256 
    257 // Happens when the zoom level is changed in the active tab, the active tab is
    258 // changed, or a new browser window or tab is created. |canShowBubble| denotes
    259 // whether it would be appropriate to show a zoom bubble or not.
    260 - (void)zoomChangedForActiveTab:(BOOL)canShowBubble;
    261 
    262 // Return the rect, in WebKit coordinates (flipped), of the window's grow box
    263 // in the coordinate system of the content area of the currently selected tab.
    264 - (NSRect)selectedTabGrowBoxRect;
    265 
    266 // Called to tell the selected tab to update its loading state.
    267 // |force| is set if the update is due to changing tabs, as opposed to
    268 // the page-load finishing.  See comment in reload_button.h.
    269 - (void)setIsLoading:(BOOL)isLoading force:(BOOL)force;
    270 
    271 // Brings this controller's window to the front.
    272 - (void)activate;
    273 
    274 // Make the location bar the first responder, if possible.
    275 - (void)focusLocationBar:(BOOL)selectAll;
    276 
    277 // Make the (currently-selected) tab contents the first responder, if possible.
    278 - (void)focusTabContents;
    279 
    280 // Returns the frame of the regular (non-fullscreened) window (even if the
    281 // window is currently in fullscreen mode).  The frame is returned in Cocoa
    282 // coordinates (origin in bottom-left).
    283 - (NSRect)regularWindowFrame;
    284 
    285 // Whether or not to show the avatar, which is either the incognito guy or the
    286 // user's profile avatar.
    287 - (BOOL)shouldShowAvatar;
    288 
    289 // Whether or not to show the new avatar button used by --new-profile-maagement.
    290 - (BOOL)shouldUseNewAvatarButton;
    291 
    292 - (BOOL)isBookmarkBarVisible;
    293 
    294 // Returns YES if the bookmark bar is currently animating.
    295 - (BOOL)isBookmarkBarAnimating;
    296 
    297 - (BookmarkBarController*)bookmarkBarController;
    298 
    299 - (DevToolsController*)devToolsController;
    300 
    301 - (BOOL)isDownloadShelfVisible;
    302 
    303 // Lazily creates the download shelf in visible state if it doesn't exist yet.
    304 - (void)createAndAddDownloadShelf;
    305 
    306 // Returns the download shelf controller, if it exists.
    307 - (DownloadShelfController*)downloadShelf;
    308 
    309 // Retains the given FindBarCocoaController and adds its view to this
    310 // browser window.  Must only be called once per
    311 // BrowserWindowController.
    312 - (void)addFindBar:(FindBarCocoaController*)findBarCocoaController;
    313 
    314 // The user changed the theme.
    315 - (void)userChangedTheme;
    316 
    317 // Executes the command in the context of the current browser.
    318 // |command| is an integer value containing one of the constants defined in the
    319 // "chrome/app/chrome_command_ids.h" file.
    320 - (void)executeCommand:(int)command;
    321 
    322 // Consults the Command Registry to see if this |event| needs to be handled as
    323 // an extension command and returns YES if so (NO otherwise).
    324 // Only extensions with the given |priority| are considered.
    325 - (BOOL)handledByExtensionCommand:(NSEvent*)event
    326     priority:(ui::AcceleratorManager::HandlerPriority)priority;
    327 
    328 // Delegate method for the status bubble to query its base frame.
    329 - (NSRect)statusBubbleBaseFrame;
    330 
    331 // Show the bookmark bubble (e.g. user just clicked on the STAR)
    332 - (void)showBookmarkBubbleForURL:(const GURL&)url
    333                alreadyBookmarked:(BOOL)alreadyBookmarked;
    334 
    335 // Show the translate bubble.
    336 - (void)showTranslateBubbleForWebContents:(content::WebContents*)contents
    337                                      step:(translate::TranslateStep)step
    338                                 errorType:
    339                                     (translate::TranslateErrors::Type)errorType;
    340 
    341 // Shows or hides the docked web inspector depending on |contents|'s state.
    342 - (void)updateDevToolsForContents:(content::WebContents*)contents;
    343 
    344 // Gets the current theme provider.
    345 - (ui::ThemeProvider*)themeProvider;
    346 
    347 // Gets the window style.
    348 - (ThemedWindowStyle)themedWindowStyle;
    349 
    350 // Returns the position in the coordinates of the root view
    351 // ([[self contentView] superview]) that the top left of a theme image with
    352 // |alignment| should be painted at. If the window does not have a tab strip,
    353 // the offset for THEME_IMAGE_ALIGN_WITH_FRAME is always returned. The result of
    354 // this method can be used in conjunction with
    355 // [NSGraphicsContext cr_setPatternPhase:] to set the offset of pattern colors.
    356 - (NSPoint)themeImagePositionForAlignment:(ThemeImageAlignment)alignment;
    357 
    358 // Return the point to which a bubble window's arrow should point, in window
    359 // coordinates.
    360 - (NSPoint)bookmarkBubblePoint;
    361 
    362 // Called when the Add Search Engine dialog is closed.
    363 - (void)sheetDidEnd:(NSWindow*)sheet
    364          returnCode:(NSInteger)code
    365             context:(void*)context;
    366 
    367 // Executes the command registered by the extension that has the given id.
    368 - (void)executeExtensionCommand:(const std::string&)extension_id
    369                         command:(const extensions::Command&)command;
    370 
    371 @end  // @interface BrowserWindowController
    372 
    373 
    374 // Methods having to do with the window type (normal/popup/app, and whether the
    375 // window has various features; fullscreen and presentation mode methods are
    376 // separate).
    377 @interface BrowserWindowController(WindowType)
    378 
    379 // Determines whether this controller's window supports a given feature (i.e.,
    380 // whether a given feature is or can be shown in the window).
    381 // TODO(viettrungluu): |feature| is really should be |Browser::Feature|, but I
    382 // don't want to include browser.h (and you can't forward declare enums).
    383 - (BOOL)supportsWindowFeature:(int)feature;
    384 
    385 // Called to check whether or not this window has a normal title bar (YES if it
    386 // does, NO otherwise). (E.g., normal browser windows do not, pop-ups do.)
    387 - (BOOL)hasTitleBar;
    388 
    389 // Called to check whether or not this window has a toolbar (YES if it does, NO
    390 // otherwise). (E.g., normal browser windows do, pop-ups do not.)
    391 - (BOOL)hasToolbar;
    392 
    393 // Called to check whether or not this window has a location bar (YES if it
    394 // does, NO otherwise). (E.g., normal browser windows do, pop-ups may or may
    395 // not.)
    396 - (BOOL)hasLocationBar;
    397 
    398 // Called to check whether or not this window can have bookmark bar (YES if it
    399 // does, NO otherwise). (E.g., normal browser windows may, pop-ups may not.)
    400 - (BOOL)supportsBookmarkBar;
    401 
    402 // Called to check if this controller's window is a tabbed window (e.g., not a
    403 // pop-up window). Returns YES if it is, NO otherwise.
    404 // Note: The |-has...| methods are usually preferred, so this method is largely
    405 // deprecated.
    406 - (BOOL)isTabbedWindow;
    407 
    408 @end  // @interface BrowserWindowController(WindowType)
    409 
    410 // Fullscreen terminology:
    411 //
    412 // ----------------------------------------------------------------------------
    413 // There are 2 APIs that cause the window to get resized, and possibly move
    414 // spaces.
    415 //
    416 // + AppKitFullscreen API: AppKit touts a feature known as "fullscreen". This
    417 // involves moving the current window to a different space, and resizing the
    418 // window to take up the entire size of the screen.
    419 //
    420 // + Immersive fullscreen: An alternative to AppKitFullscreen API. Uses on 10.6
    421 // (before AppKitFullscreen API was available), and on certain HTML/Flash
    422 // content. This is a method defined by Chrome.
    423 //
    424 // The Immersive fullscreen API can be called after the AppKitFullscreen API.
    425 // Calling the AppKitFullscreen API while immersive fullscreen API has been
    426 // invoked causes all fullscreen modes to exit.
    427 //
    428 // ----------------------------------------------------------------------------
    429 // There are 2 "styles" of omnibox sliding.
    430 // + OMNIBOX_TABS_PRESENT: Both the omnibox and the tabstrip are present.
    431 // Moving the cursor to the top causes the menubar to appear, and everything
    432 // else to slide down.
    433 // + OMNIBOX_TABS_HIDDEN: Both tabstrip and omnibox are hidden. Moving cursor
    434 // to top shows tabstrip, omnibox, and menu bar.
    435 //
    436 // The omnibox sliding styles are used in conjunction with the fullscreen APIs.
    437 // There is exactly 1 sliding style active at a time. The sliding is mangaged
    438 // by the presentationModeController_. (poorly named).
    439 //
    440 // ----------------------------------------------------------------------------
    441 // There are several "fullscreen modes" bantered around. Technically, any
    442 // fullscreen API can be combined with any sliding style.
    443 //
    444 // + System fullscreen***deprecated***: This term is confusing. Don't use it.
    445 // It either refers to the AppKitFullscreen API, or the behavior that users
    446 // expect to see when they click the fullscreen button, or some Chrome specific
    447 // implementation that uses the AppKitFullscreen API.
    448 //
    449 // + Canonical Fullscreen: When a user clicks on the fullscreen button, they
    450 // expect a fullscreen behavior similar to other AppKit apps.
    451 //  - AppKitFullscreen API + OMNIBOX_TABS_PRESENT.
    452 //  - The button click directly invokes the AppKitFullscreen API. This class
    453 //  get a callback, and calls adjustUIForOmniboxFullscreen.
    454 //  - There is a menu item that is intended to invoke the same behavior. When
    455 //  the user clicks the menu item, or use its hotkey, this class invokes the
    456 //  AppKitFullscreen API.
    457 //
    458 // + Presentation Mode:
    459 //  - OMNIBOX_TABS_HIDDEN, typically with AppKitFullscreen API, but can
    460 //  also be with Immersive fullscreen API.
    461 //  - This class sets a flag, indicating that it wants Presentation Mode
    462 //  instead of Canonical Fullscreen. Then it invokes the AppKitFullscreen API.
    463 //
    464 // + HTML5 fullscreen. <-- Currently uses AppKitFullscreen API. This should
    465 // eventually migrate to the Immersive Fullscreen API.
    466 //
    467 // There are more fullscreen styles on OSX than other OSes. However, all OSes
    468 // share the same cross-platform code for entering fullscreen
    469 // (FullscreenController). It is important for OSX fullscreen logic to track
    470 // how the user triggered fullscreen mode.
    471 // There are currently 5 possible mechanisms:
    472 //   - User clicks the AppKit Fullscreen button.
    473 //     -- This invokes -[BrowserWindowController windowWillEnterFullscreen:]
    474 //   - User selects the menu item "Enter Full Screen".
    475 //     -- This invokes FullscreenController::ToggleFullscreenModeInternal(
    476 //        BROWSER_WITH_CHROME)
    477 //   - User selects the menu item "Enter Presentation Mode".
    478 //     -- This invokes FullscreenController::ToggleFullscreenModeInternal(
    479 //        BROWSER)
    480 //     -- The corresponding URL will be empty.
    481 //   - User requests fullscreen via an extension.
    482 //     -- This invokes FullscreenController::ToggleFullscreenModeInternal(
    483 //        BROWSER)
    484 //     -- The corresponding URL will be the url of the extension.
    485 //   - User requests fullscreen via Flash or JavaScript apis.
    486 //     -- This invokes FullscreenController::ToggleFullscreenModeInternal(
    487 //        BROWSER)
    488 //     -- browser_->fullscreen_controller()->
    489 //        IsWindowFullscreenForTabOrPending() returns true.
    490 //     -- The corresponding URL will be the url of the web page.
    491 
    492 // Methods having to do with fullscreen and presentation mode.
    493 @interface BrowserWindowController(Fullscreen)
    494 
    495 // Toggles fullscreen mode.  Meant to be called by Lion windows when they enter
    496 // or exit Lion fullscreen mode.  Must not be called on Snow Leopard or earlier.
    497 - (void)handleLionToggleFullscreen;
    498 
    499 // Enters Canonical Fullscreen.
    500 - (void)enterFullscreenWithChrome;
    501 
    502 // Updates the contents of the fullscreen exit bubble with |url| and
    503 // |bubbleType|.
    504 - (void)updateFullscreenExitBubbleURL:(const GURL&)url
    505                            bubbleType:(FullscreenExitBubbleType)bubbleType;
    506 
    507 // Returns YES if the browser window is in or entering any fullscreen mode.
    508 - (BOOL)isInAnyFullscreenMode;
    509 
    510 // Returns YES if the browser window is currently in or entering fullscreen via
    511 // the built-in immersive mechanism.
    512 - (BOOL)isInImmersiveFullscreen;
    513 
    514 // Returns YES if the browser window is currently in or entering fullscreen via
    515 // the AppKit Fullscreen API.
    516 - (BOOL)isInAppKitFullscreen;
    517 
    518 // Enters presentation mode.
    519 - (void)enterPresentationMode;
    520 
    521 // Enter fullscreen for an extension.
    522 - (void)enterExtensionFullscreenForURL:(const GURL&)url
    523                             bubbleType:(FullscreenExitBubbleType)bubbleType;
    524 
    525 // Enters Immersive Fullscreen for the given URL.
    526 - (void)enterWebContentFullscreenForURL:(const GURL&)url
    527                              bubbleType:(FullscreenExitBubbleType)bubbleType;
    528 
    529 // Exits the current fullscreen mode.
    530 - (void)exitAnyFullscreen;
    531 
    532 // Whether the system is in the very specific fullscreen mode: Presentation
    533 // Mode.
    534 - (BOOL)inPresentationMode;
    535 
    536 // Resizes the fullscreen window to fit the screen it's currently on.  Called by
    537 // the PresentationModeController when there is a change in monitor placement or
    538 // resolution.
    539 - (void)resizeFullscreenWindow;
    540 
    541 // Query/lock/release the requirement that the tab strip/toolbar/attached
    542 // bookmark bar bar cluster is visible (e.g., when one of its elements has
    543 // focus). This is required for the floating bar in presentation mode, but
    544 // should also be called when not in presentation mode; see the comments for
    545 // |barVisibilityLocks_| for more details. Double locks/releases by the same
    546 // owner are ignored. If |animate:| is YES, then an animation may be performed,
    547 // possibly after a small delay if |delay:| is YES. If |animate:| is NO,
    548 // |delay:| will be ignored. In the case of multiple calls, later calls have
    549 // precedence with the rule that |animate:NO| has precedence over |animate:YES|,
    550 // and |delay:NO| has precedence over |delay:YES|.
    551 - (BOOL)isBarVisibilityLockedForOwner:(id)owner;
    552 - (void)lockBarVisibilityForOwner:(id)owner
    553                     withAnimation:(BOOL)animate
    554                             delay:(BOOL)delay;
    555 - (void)releaseBarVisibilityForOwner:(id)owner
    556                        withAnimation:(BOOL)animate
    557                                delay:(BOOL)delay;
    558 
    559 // Returns YES if any of the views in the floating bar currently has focus.
    560 - (BOOL)floatingBarHasFocus;
    561 
    562 @end  // @interface BrowserWindowController(Fullscreen)
    563 
    564 
    565 // Methods which are either only for testing, or only public for testing.
    566 @interface BrowserWindowController (TestingAPI)
    567 
    568 // Put the incognito badge or multi-profile avatar on the browser and adjust the
    569 // tab strip accordingly.
    570 - (void)installAvatar;
    571 
    572 // Allows us to initWithBrowser withOUT taking ownership of the browser.
    573 - (id)initWithBrowser:(Browser*)browser takeOwnership:(BOOL)ownIt;
    574 
    575 // Adjusts the window height by the given amount.  If the window spans from the
    576 // top of the current workspace to the bottom of the current workspace, the
    577 // height is not adjusted.  If growing the window by the requested amount would
    578 // size the window to be taller than the current workspace, the window height is
    579 // capped to be equal to the height of the current workspace.  If the window is
    580 // partially offscreen, its height is not adjusted at all.  This function
    581 // prefers to grow the window down, but will grow up if needed.  Calls to this
    582 // function should be followed by a call to |layoutSubviews|.
    583 // Returns if the window height was changed.
    584 - (BOOL)adjustWindowHeightBy:(CGFloat)deltaH;
    585 
    586 // Return an autoreleased NSWindow suitable for fullscreen use.
    587 - (NSWindow*)createFullscreenWindow;
    588 
    589 // Resets any saved state about window growth (due to showing the bookmark bar
    590 // or the download shelf), so that future shrinking will occur from the bottom.
    591 - (void)resetWindowGrowthState;
    592 
    593 // Computes by how far in each direction, horizontal and vertical, the
    594 // |source| rect doesn't fit into |target|.
    595 - (NSSize)overflowFrom:(NSRect)source
    596                     to:(NSRect)target;
    597 
    598 // The fullscreen exit bubble controller, or nil if the bubble isn't showing.
    599 - (FullscreenExitBubbleController*)fullscreenExitBubbleController;
    600 
    601 // Gets the rect, in window base coordinates, that the omnibox popup should be
    602 // positioned relative to.
    603 - (NSRect)omniboxPopupAnchorRect;
    604 
    605 // Force a layout of info bars.
    606 - (void)layoutInfoBars;
    607 
    608 @end  // @interface BrowserWindowController (TestingAPI)
    609 
    610 
    611 #endif  // CHROME_BROWSER_UI_COCOA_BROWSER_WINDOW_CONTROLLER_H_
    612