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.
5 #ifndef CHROME_BROWSER_UI_COCOA_BROWSER_WINDOW_CONTROLLER_PRIVATE_H_
6 #define CHROME_BROWSER_UI_COCOA_BROWSER_WINDOW_CONTROLLER_PRIVATE_H_
8 #import "chrome/browser/ui/cocoa/browser_window_controller.h"
9 #import "chrome/browser/ui/cocoa/presentation_mode_controller.h"
11 // Private methods for the |BrowserWindowController|. This category should
12 // contain the private methods used by different parts of the BWC; private
13 // methods used only by single parts should be declared in their own file.
14 // TODO(viettrungluu): [crbug.com/35543] work on splitting out stuff from the
15 // BWC, and figuring out which methods belong here (need to unravel
17 @interface
BrowserWindowController(Private
)
19 // Create the appropriate tab strip controller based on whether or not side
20 // tabs are enabled. Replaces the current controller.
21 - (void)createTabStripController
;
23 // Saves the window's position in the local state preferences.
24 - (void)saveWindowPositionIfNeeded
;
26 // We need to adjust where sheets come out of the window, as by default they
27 // erupt from the omnibox, which is rather weird.
28 - (NSRect
)window
:(NSWindow
*)window
29 willPositionSheet
:(NSWindow
*)sheet
30 usingRect
:(NSRect
)defaultSheetRect
;
32 // Repositions the window's subviews. From the top down: toolbar, normal
33 // bookmark bar (if shown), infobar, NTP detached bookmark bar (if shown),
34 // content area, download shelf (if any).
35 - (void)layoutSubviews
;
37 // Find the total height of the floating bar (in presentation mode). Safe to
38 // call even when not in presentation mode.
39 - (CGFloat
)floatingBarHeight
;
41 // Shows the informational "how to exit fullscreen" bubble.
42 - (void)showFullscreenExitBubbleIfNecessary
;
43 - (void)destroyFullscreenExitBubbleIfNecessary
;
45 // Lays out the tab strip at the given maximum y-coordinate, with the given
46 // width, possibly for fullscreen mode; returns the new maximum y (below the
47 // tab strip). This is safe to call even when there is no tab strip.
48 - (CGFloat
)layoutTabStripAtMaxY
:(CGFloat
)maxY
50 fullscreen
:(BOOL
)fullscreen
;
52 // Lays out the toolbar (or just location bar for popups) at the given maximum
53 // y-coordinate, with the given width; returns the new maximum y (below the
55 - (CGFloat
)layoutToolbarAtMinX
:(CGFloat
)minX
59 // Returns YES if the bookmark bar should be placed below the infobar, NO
61 - (BOOL
)placeBookmarkBarBelowInfoBar
;
63 // Lays out the bookmark bar at the given maximum y-coordinate, with the given
64 // width; returns the new maximum y (below the bookmark bar). Note that one must
65 // call it with the appropriate |maxY| which depends on whether or not the
66 // bookmark bar is shown as the NTP bubble or not (use
67 // |-placeBookmarkBarBelowInfoBar|).
68 - (CGFloat
)layoutBookmarkBarAtMinX
:(CGFloat
)minX
72 // Lay out the view which draws the background for the floating bar when in
73 // presentation mode, with the given frame and presentation-mode-status. Should
74 // be called even when not in presentation mode to hide the backing view.
75 - (void)layoutFloatingBarBackingView
:(NSRect
)frame
76 presentationMode
:(BOOL
)presentationMode
;
78 // Lays out the infobar at the given maximum y-coordinate, with the given width;
79 // returns the new maximum y (below the infobar).
80 - (CGFloat
)layoutInfoBarAtMinX
:(CGFloat
)minX
84 // Lays out the download shelf, if there is one, at the given minimum
85 // y-coordinate, with the given width; returns the new minimum y (above the
86 // download shelf). This is safe to call even if there is no download shelf.
87 - (CGFloat
)layoutDownloadShelfAtMinX
:(CGFloat
)minX
91 // Lays out the tab content area in the given frame. If the height changes,
92 // sends a message to the renderer to resize.
93 - (void)layoutTabContentArea
:(NSRect
)frame
;
95 // Sets the toolbar's height to a value appropriate for the given compression.
96 // Also adjusts the bookmark bar's height by the opposite amount in order to
97 // keep the total height of the two views constant.
98 - (void)adjustToolbarAndBookmarkBarForCompression
:(CGFloat
)compression
;
100 // Moves views between windows in preparation for fullscreen mode when not using
101 // Cocoa's System Fullscreen API. (System Fullscreen reuses the original window
102 // for fullscreen mode, so there is no need to move views around.) This method
103 // does not position views; callers must also call |-layoutSubviews:|.
104 - (void)moveViewsForImmersiveFullscreen
:(BOOL
)fullscreen
105 regularWindow
:(NSWindow
*)regularWindow
106 fullscreenWindow
:(NSWindow
*)fullscreenWindow
;
108 // Called when a permission bubble closes, and informs the presentation
109 // controller that the dropdown can be hidden. (The dropdown should never be
110 // hidden while a permissions bubble is visible.)
111 - (void)permissionBubbleWindowWillClose
:(NSNotification
*)notification
;
113 // Enter or exit fullscreen without using Cocoa's System Fullscreen API. These
114 // methods are internal implementations of |-setFullscreen:|.
115 - (void)enterImmersiveFullscreen
;
116 - (void)exitImmersiveFullscreen
;
118 // Register or deregister for content view resize notifications. These
119 // notifications are used while transitioning into fullscreen mode using Cocoa's
120 // System Fullscreen API.
121 - (void)registerForContentViewResizeNotifications
;
122 - (void)deregisterForContentViewResizeNotifications
;
124 // Allows/prevents bar visibility locks and releases from updating the visual
125 // state. Enabling makes changes instantaneously; disabling cancels any
127 - (void)enableBarVisibilityUpdates
;
128 - (void)disableBarVisibilityUpdates
;
130 // If there are no visibility locks and bar visibity updates are enabled, hides
131 // the bar with |animation| and |delay|. Otherwise, does nothing.
132 - (void)hideOverlayIfPossibleWithAnimation
:(BOOL
)animation delay
:(BOOL
)delay
;
134 // The opacity for the toolbar divider; 0 means that it shouldn't be shown.
135 - (CGFloat
)toolbarDividerOpacity
;
137 // When a view does not have a layer, but it has multiple subviews with layers,
138 // the ordering of the layers is not well defined. Removing a subview and
139 // re-adding it to the same position has the side effect of updating the layer
140 // ordering to better reflect the subview ordering.
141 // This is a hack needed because NSThemeFrame is not layer backed, but it has
142 // multiple direct subviews which are. http://crbug.com/413009
143 - (void)updateLayerOrdering
:(NSView
*)view
;
145 // Ensures the z-order of subviews is correct.
146 - (void)updateSubviewZOrder
:(BOOL
)inPresentationMode
;
148 // Update visibility of the infobar tip, depending on the state of the window.
149 - (void)updateInfoBarTipVisibility
;
151 // Returns the max top arrow height for infobar.
152 - (NSInteger
)infoBarMaxTopArrowHeight
;
154 // Configures the presentationModeController_ right after it is constructed.
155 - (void)configurePresentationModeController
;
157 // Allows the omnibox to slide. Also prepares UI for several fullscreen modes.
158 // This method gets called when entering AppKit fullscren, or when entering
159 // Immersive fullscreen. Expects fullscreenStyle_ to be set.
160 - (void)adjustUIForSlidingFullscreenStyle
:(fullscreen_mac::SlidingStyle
)style
;
162 // This method gets called when exiting AppKit fullscreen, or when exiting
163 // Immersive fullscreen. It performs some common UI changes, and stops the
164 // omnibox from sliding.
165 - (void)adjustUIForExitingFullscreenAndStopOmniboxSliding
;
167 // Exposed for testing.
168 // Creates a PresentationModeController with the given style.
169 - (PresentationModeController
*)newPresentationModeControllerWithStyle
:
170 (fullscreen_mac::SlidingStyle
)style
;
172 // Toggles the AppKit Fullscreen API. By default, doing so enters Canonical
174 - (void)enterAppKitFullscreen
;
175 - (void)exitAppKitFullscreen
;
177 @end
// @interface BrowserWindowController(Private)
179 #endif // CHROME_BROWSER_UI_COCOA_BROWSER_WINDOW_CONTROLLER_PRIVATE_H_