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_PRIVATE_H_ 6 #define CHROME_BROWSER_UI_COCOA_BROWSER_WINDOW_CONTROLLER_PRIVATE_H_ 7 8 #import "chrome/browser/ui/cocoa/browser_window_controller.h" 9 10 namespace browser_window_controller { 11 12 enum CoreAnimationStatus { 13 kCoreAnimationDisabled, 14 kCoreAnimationEnabledLazy, 15 kCoreAnimationEnabledAlways, 16 }; 17 18 } // namespace browser_window_controller 19 20 // Private methods for the |BrowserWindowController|. This category should 21 // contain the private methods used by different parts of the BWC; private 22 // methods used only by single parts should be declared in their own file. 23 // TODO(viettrungluu): [crbug.com/35543] work on splitting out stuff from the 24 // BWC, and figuring out which methods belong here (need to unravel 25 // "dependencies"). 26 @interface BrowserWindowController(Private) 27 28 // Create the appropriate tab strip controller based on whether or not side 29 // tabs are enabled. Replaces the current controller. 30 - (void)createTabStripController; 31 32 // Saves the window's position in the local state preferences. 33 - (void)saveWindowPositionIfNeeded; 34 35 // We need to adjust where sheets come out of the window, as by default they 36 // erupt from the omnibox, which is rather weird. 37 - (NSRect)window:(NSWindow*)window 38 willPositionSheet:(NSWindow*)sheet 39 usingRect:(NSRect)defaultSheetRect; 40 41 // Repositions the window's subviews. From the top down: toolbar, normal 42 // bookmark bar (if shown), infobar, NTP detached bookmark bar (if shown), 43 // content area, download shelf (if any). 44 - (void)layoutSubviews; 45 46 // Find the total height of the floating bar (in presentation mode). Safe to 47 // call even when not in presentation mode. 48 - (CGFloat)floatingBarHeight; 49 50 // Shows the informational "how to exit fullscreen" bubble. 51 - (void)showFullscreenExitBubbleIfNecessary; 52 - (void)destroyFullscreenExitBubbleIfNecessary; 53 54 // Lays out the tab strip at the given maximum y-coordinate, with the given 55 // width, possibly for fullscreen mode; returns the new maximum y (below the 56 // tab strip). This is safe to call even when there is no tab strip. 57 - (CGFloat)layoutTabStripAtMaxY:(CGFloat)maxY 58 width:(CGFloat)width 59 fullscreen:(BOOL)fullscreen; 60 61 // Lays out the toolbar (or just location bar for popups) at the given maximum 62 // y-coordinate, with the given width; returns the new maximum y (below the 63 // toolbar). 64 - (CGFloat)layoutToolbarAtMinX:(CGFloat)minX 65 maxY:(CGFloat)maxY 66 width:(CGFloat)width; 67 68 // Returns YES if the bookmark bar should be placed below the infobar, NO 69 // otherwise. 70 - (BOOL)placeBookmarkBarBelowInfoBar; 71 72 // Lays out the bookmark bar at the given maximum y-coordinate, with the given 73 // width; returns the new maximum y (below the bookmark bar). Note that one must 74 // call it with the appropriate |maxY| which depends on whether or not the 75 // bookmark bar is shown as the NTP bubble or not (use 76 // |-placeBookmarkBarBelowInfoBar|). 77 - (CGFloat)layoutBookmarkBarAtMinX:(CGFloat)minX 78 maxY:(CGFloat)maxY 79 width:(CGFloat)width; 80 81 // Lay out the view which draws the background for the floating bar when in 82 // presentation mode, with the given frame and presentation-mode-status. Should 83 // be called even when not in presentation mode to hide the backing view. 84 - (void)layoutFloatingBarBackingView:(NSRect)frame 85 presentationMode:(BOOL)presentationMode; 86 87 // Lays out the infobar at the given maximum y-coordinate, with the given width; 88 // returns the new maximum y (below the infobar). 89 - (CGFloat)layoutInfoBarAtMinX:(CGFloat)minX 90 maxY:(CGFloat)maxY 91 width:(CGFloat)width; 92 93 // Lays out the download shelf, if there is one, at the given minimum 94 // y-coordinate, with the given width; returns the new minimum y (above the 95 // download shelf). This is safe to call even if there is no download shelf. 96 - (CGFloat)layoutDownloadShelfAtMinX:(CGFloat)minX 97 minY:(CGFloat)minY 98 width:(CGFloat)width; 99 100 // Lays out the tab content area in the given frame. If the height changes, 101 // sends a message to the renderer to resize. 102 - (void)layoutTabContentArea:(NSRect)frame; 103 104 // Sets the toolbar's height to a value appropriate for the given compression. 105 // Also adjusts the bookmark bar's height by the opposite amount in order to 106 // keep the total height of the two views constant. 107 - (void)adjustToolbarAndBookmarkBarForCompression:(CGFloat)compression; 108 109 // Whether to show the presentation mode toggle button in the UI. Returns YES 110 // if in fullscreen mode on Lion or later. This method is safe to call on all 111 // OS versions. 112 - (BOOL)shouldShowPresentationModeToggle; 113 114 // Moves views between windows in preparation for fullscreen mode on Snow 115 // Leopard. (Lion and later reuses the original window for 116 // fullscreen mode, so there is no need to move views around.) This method does 117 // not position views; callers must also call |-layoutSubviews|. This method 118 // must not be called on Lion or later. 119 - (void)moveViewsForFullscreenForSnowLeopard:(BOOL)fullscreen 120 regularWindow:(NSWindow*)regularWindow 121 fullscreenWindow:(NSWindow*)fullscreenWindow; 122 123 // Sets presentation mode, creating the PresentationModeController if needed and 124 // forcing a relayout. If |forceDropdown| is YES, this method will always 125 // initially show the floating bar when entering presentation mode, even if the 126 // floating bar does not have focus. This method is safe to call on all OS 127 // versions. 128 - (void)setPresentationModeInternal:(BOOL)presentationMode 129 forceDropdown:(BOOL)forceDropdown; 130 131 // Called on Snow Leopard or earlier to enter or exit fullscreen. These methods 132 // are internal implementations of |-setFullscreen:|. These methods must not be 133 // called on Lion or later. 134 - (void)enterFullscreenForSnowLeopard; 135 - (void)exitFullscreenForSnowLeopard; 136 137 // Register or deregister for content view resize notifications. These 138 // notifications are used while transitioning to fullscreen mode in Lion or 139 // later. This method is safe to call on all OS versions. 140 - (void)registerForContentViewResizeNotifications; 141 - (void)deregisterForContentViewResizeNotifications; 142 143 // Adjust the UI when entering or leaving presentation mode. This method is 144 // safe to call on all OS versions. 145 - (void)adjustUIForPresentationMode:(BOOL)fullscreen; 146 147 // Allows/prevents bar visibility locks and releases from updating the visual 148 // state. Enabling makes changes instantaneously; disabling cancels any 149 // timers/animation. 150 - (void)enableBarVisibilityUpdates; 151 - (void)disableBarVisibilityUpdates; 152 153 // The opacity for the toolbar divider; 0 means that it shouldn't be shown. 154 - (CGFloat)toolbarDividerOpacity; 155 156 // Ensures the z-order of subviews is correct. 157 - (void)updateSubviewZOrder:(BOOL)inPresentationMode; 158 159 - (void)updateAllowOverlappingViews:(BOOL)inPresentationMode; 160 161 // Update visibility of the infobar tip, depending on the state of the window. 162 - (void)updateInfoBarTipVisibility; 163 164 // Checks if core animation should be enabled or not. 165 - (browser_window_controller::CoreAnimationStatus)coreAnimationStatus; 166 167 @end // @interface BrowserWindowController(Private) 168 169 #endif // CHROME_BROWSER_UI_COCOA_BROWSER_WINDOW_CONTROLLER_PRIVATE_H_ 170