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#import "chrome/browser/ui/cocoa/presentation_mode_controller.h"
10
11@class BrowserWindowLayout;
12
13// Private methods for the |BrowserWindowController|. This category should
14// contain the private methods used by different parts of the BWC; private
15// methods used only by single parts should be declared in their own file.
16// TODO(viettrungluu): [crbug.com/35543] work on splitting out stuff from the
17// BWC, and figuring out which methods belong here (need to unravel
18// "dependencies").
19@interface BrowserWindowController(Private)
20
21// Create the appropriate tab strip controller based on whether or not side
22// tabs are enabled. Replaces the current controller.
23- (void)createTabStripController;
24
25// Saves the window's position in the local state preferences.
26- (void)saveWindowPositionIfNeeded;
27
28// We need to adjust where sheets come out of the window, as by default they
29// erupt from the omnibox, which is rather weird.
30- (NSRect)window:(NSWindow*)window
31    willPositionSheet:(NSWindow*)sheet
32            usingRect:(NSRect)defaultSheetRect;
33
34// Repositions the window's subviews. From the top down: toolbar, normal
35// bookmark bar (if shown), infobar, NTP detached bookmark bar (if shown),
36// content area, download shelf (if any).
37- (void)layoutSubviews;
38
39// Shows the informational "how to exit fullscreen" bubble.
40- (void)showFullscreenExitBubbleIfNecessary;
41- (void)destroyFullscreenExitBubbleIfNecessary;
42
43// Lays out the tab strip at the given maximum y-coordinate, with the given
44// width, possibly for fullscreen mode; returns the new maximum y (below the
45// tab strip). This is safe to call even when there is no tab strip.
46- (CGFloat)layoutTabStripAtMaxY:(CGFloat)maxY
47                          width:(CGFloat)width
48                     fullscreen:(BOOL)fullscreen;
49
50// Returns YES if the bookmark bar should be placed below the infobar, NO
51// otherwise.
52- (BOOL)placeBookmarkBarBelowInfoBar;
53
54
55// Lays out the tab content area in the given frame. If the height changes,
56// sends a message to the renderer to resize.
57- (void)layoutTabContentArea:(NSRect)frame;
58
59// Sets the toolbar's height to a value appropriate for the given compression.
60// Also adjusts the bookmark bar's height by the opposite amount in order to
61// keep the total height of the two views constant.
62- (void)adjustToolbarAndBookmarkBarForCompression:(CGFloat)compression;
63
64// Moves views between windows in preparation for fullscreen mode when not using
65// Cocoa's System Fullscreen API.  (System Fullscreen reuses the original window
66// for fullscreen mode, so there is no need to move views around.)  This method
67// does not position views; callers must also call |-layoutSubviews:|.
68- (void)moveViewsForImmersiveFullscreen:(BOOL)fullscreen
69                          regularWindow:(NSWindow*)regularWindow
70                       fullscreenWindow:(NSWindow*)fullscreenWindow;
71
72// Called when a permission bubble closes, and informs the presentation
73// controller that the dropdown can be hidden.  (The dropdown should never be
74// hidden while a permissions bubble is visible.)
75- (void)permissionBubbleWindowWillClose:(NSNotification*)notification;
76
77// Enter or exit fullscreen without using Cocoa's System Fullscreen API.  These
78// methods are internal implementations of |-setFullscreen:|.
79- (void)enterImmersiveFullscreen;
80- (void)exitImmersiveFullscreen;
81
82// Register or deregister for content view resize notifications.  These
83// notifications are used while transitioning into fullscreen mode using Cocoa's
84// System Fullscreen API.
85- (void)registerForContentViewResizeNotifications;
86- (void)deregisterForContentViewResizeNotifications;
87
88// Allows/prevents bar visibility locks and releases from updating the visual
89// state. Enabling makes changes instantaneously; disabling cancels any
90// timers/animation.
91- (void)enableBarVisibilityUpdates;
92- (void)disableBarVisibilityUpdates;
93
94// If there are no visibility locks and bar visibity updates are enabled, hides
95// the bar with |animation| and |delay|.  Otherwise, does nothing.
96- (void)hideOverlayIfPossibleWithAnimation:(BOOL)animation delay:(BOOL)delay;
97
98// The opacity for the toolbar divider; 0 means that it shouldn't be shown.
99- (CGFloat)toolbarDividerOpacity;
100
101// When a view does not have a layer, but it has multiple subviews with layers,
102// the ordering of the layers is not well defined. Removing a subview and
103// re-adding it to the same position has the side effect of updating the layer
104// ordering to better reflect the subview ordering.
105// This is a hack needed because NSThemeFrame is not layer backed, but it has
106// multiple direct subviews which are. http://crbug.com/413009
107- (void)updateLayerOrdering:(NSView*)view;
108
109// Update visibility of the infobar tip, depending on the state of the window.
110- (void)updateInfoBarTipVisibility;
111
112// The min Y of the bubble point in the coordinate space of the toolbar.
113- (NSInteger)pageInfoBubblePointY;
114
115// Configures the presentationModeController_ right after it is constructed.
116- (void)configurePresentationModeController;
117
118// Allows the omnibox to slide. Also prepares UI for several fullscreen modes.
119// This method gets called when entering AppKit fullscren, or when entering
120// Immersive fullscreen. Expects fullscreenStyle_ to be set.
121- (void)adjustUIForSlidingFullscreenStyle:(fullscreen_mac::SlidingStyle)style;
122
123// This method gets called when exiting AppKit fullscreen, or when exiting
124// Immersive fullscreen. It performs some common UI changes, and stops the
125// omnibox from sliding.
126- (void)adjustUIForExitingFullscreenAndStopOmniboxSliding;
127
128// Exposed for testing.
129// Creates a PresentationModeController with the given style.
130- (PresentationModeController*)newPresentationModeControllerWithStyle:
131    (fullscreen_mac::SlidingStyle)style;
132
133// Toggles the AppKit Fullscreen API. By default, doing so enters Canonical
134// Fullscreen.
135- (void)enterAppKitFullscreen;
136- (void)exitAppKitFullscreen;
137
138// Updates |layout| with the full set of parameters required to statelessly
139// determine the layout of the views managed by this controller.
140- (void)updateLayoutParameters:(BrowserWindowLayout*)layout;
141
142// Applies a layout to the views managed by this controller.
143- (void)applyLayout:(BrowserWindowLayout*)layout;
144
145// Ensures that the window's content view's subviews have the correct
146// z-ordering. Will add or remove subviews as necessary.
147- (void)updateSubviewZOrder;
148
149// Performs updateSubviewZOrder when this controller is not in fullscreen.
150- (void)updateSubviewZOrderNormal;
151
152// Performs updateSubviewZOrder when this controller is in fullscreen.
153- (void)updateSubviewZOrderFullscreen;
154
155// Sets the content view's subviews. Attempts to not touch the tabContentArea
156// to prevent redraws.
157- (void)setContentViewSubviews:(NSArray*)subviews;
158
159// A hack required to get NSThemeFrame sub layers to order correctly. See
160// implementation for more details.
161- (void)updateSubviewZOrderHack;
162
163@end  // @interface BrowserWindowController(Private)
164
165#endif  // CHROME_BROWSER_UI_COCOA_BROWSER_WINDOW_CONTROLLER_PRIVATE_H_
166