Add new certificateProvider extension API.
[chromium-blink-merge.git] / chrome / browser / ui / cocoa / browser_window_layout.h
blob82cf1f9cfe6cf6148d50e30600a44477aa9e3379
1 // Copyright 2014 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_LAYOUT_H_
6 #define CHROME_BROWSER_UI_COCOA_BROWSER_WINDOW_CONTROLLER_LAYOUT_H_
8 #import <Cocoa/Cocoa.h>
10 #import "chrome/browser/ui/cocoa/presentation_mode_controller.h"
12 namespace chrome {
14 // The height of the tab strip.
15 extern const CGFloat kTabStripHeight;
17 // The parameters used to calculate the layout of the views managed by the
18 // BrowserWindowController.
19 struct LayoutParameters {
20 // The size of the content view of the window.
21 NSSize contentViewSize;
22 // The size of the window.
23 NSSize windowSize;
25 // Whether the controller is in any fullscreen mode. This parameter should be
26 // NO if the controller is in the process of entering fullscreen.
27 BOOL inAnyFullscreen;
28 // The fullscreen sliding style. See presentation_mode_controller.h for more
29 // details.
30 fullscreen_mac::SlidingStyle slidingStyle;
31 // The minY of the AppKit Menu Bar, relative to the top of the screen. Ranges
32 // from 0 to -22. Only relevant in fullscreen mode.
33 CGFloat menubarOffset;
34 // The fraction of the sliding toolbar that is visible in fullscreenm mode.
35 // Ranges from 0 to 1. Only relevant in fullscreen mode.
36 CGFloat toolbarFraction;
38 BOOL hasTabStrip;
39 // The frame of the fullscreen button. May be NSZeroRect if the fullscreen
40 // button doesn't exist. Only needs to be set when hasTabStrip is YES.
41 NSRect fullscreenButtonFrame;
42 // Whether the avatar button should be shown. Only needs to be set when
43 // hasTabStrip is YES.
44 BOOL shouldShowAvatar;
45 // Whether to use the new avatar button. Only needs to be set when
46 // shouldShowAvatar is YES.
47 BOOL shouldUseNewAvatar;
48 // The size of the avatar button. Only needs to be set when shouldShowAvatar
49 // is YES.
50 NSSize avatarSize;
51 // The line width that will generate a 1 pixel wide line for the avatar's
52 // superview. Only needs to be set when shouldShowAvatar is YES.
53 CGFloat avatarLineWidth;
55 BOOL hasToolbar;
56 BOOL hasLocationBar;
57 CGFloat toolbarHeight;
59 BOOL bookmarkBarHidden;
60 // If the bookmark bar is not hidden, then the bookmark bar should either be
61 // directly below the omnibox, or directly below the info bar. This parameter
62 // selects between those 2 cases.
63 BOOL placeBookmarkBarBelowInfoBar;
64 CGFloat bookmarkBarHeight;
66 // The height of the info bar, not including the top arrow.
67 CGFloat infoBarHeight;
68 // The distance from the bottom of the location icon to the bottom of the
69 // toolbar. Only needs to be set if infoBarHeight is not 0 and hasToolbar is
70 // YES.
71 CGFloat pageInfoBubblePointY;
73 BOOL hasDownloadShelf;
74 CGFloat downloadShelfHeight;
76 // This parameter exists so that unit tests can configure the OS version.
77 BOOL isOSYosemiteOrLater;
80 // The parameters required to lay out the tab strip and its components.
81 struct TabStripLayout {
82 // The frame of the tab strip in window coordinates.
83 NSRect frame;
84 // The left indent for the controls of the TabStripController.
85 CGFloat leftIndent;
86 // The right indent for the controls of the TabStripController.
87 CGFloat rightIndent;
88 // Whether the TabStripController needs to add custom traffic light buttons.
89 BOOL addCustomWindowControls;
90 // The frame of the avatar in window coordinates.
91 NSRect avatarFrame;
94 // The output frames of the views managed by the BrowserWindowController. All
95 // frames are in the coordinate system of the window. The lower-left corner of
96 // the contentView coincides with the lower-left corner of the window, so these
97 // frames are also in the coordinate system of the contentView.
98 struct LayoutOutput {
99 TabStripLayout tabStripLayout;
100 NSRect toolbarFrame;
101 NSRect bookmarkFrame;
102 NSRect fullscreenBackingBarFrame;
103 CGFloat findBarMaxY;
104 CGFloat fullscreenExitButtonMaxY;
105 NSRect infoBarFrame;
106 CGFloat infoBarMaxTopArrowHeight;
107 NSRect downloadShelfFrame;
108 NSRect contentAreaFrame;
111 } // namespace chrome
113 // This class is the sole entity responsible for calculating the layout of the
114 // views managed by the BrowserWindowController. The parameters used to
115 // calculate the layout are the fields of |parameters_|. These fields should be
116 // filled by calling the appropriate setters on this class. Once the parameters
117 // have been set, calling -computeLayout will return a LayoutOutput that
118 // includes sufficient information to lay out all views managed by
119 // BrowserWindowController.
121 // This is a lightweight class. It should be created on demand.
122 @interface BrowserWindowLayout : NSObject {
123 @private
124 // Stores the parameters used to compute layout.
125 chrome::LayoutParameters parameters_;
127 // Stores the layout output as it's being computed.
128 chrome::LayoutOutput output_;
130 // The offset of the maxY of the tab strip during fullscreen mode.
131 CGFloat fullscreenYOffset_;
133 // The views are laid out from highest Y to lowest Y. This variable holds the
134 // current highest Y that the next view is expected to be laid under.
135 CGFloat maxY_;
138 // Designated initializer.
139 - (instancetype)init;
141 // Performs the layout computation and returns the results. This method is fast
142 // and does not perform any caching.
143 - (chrome::LayoutOutput)computeLayout;
145 - (void)setContentViewSize:(NSSize)size;
146 - (void)setWindowSize:(NSSize)size;
148 // Whether the controller is in any fullscreen mode. |inAnyFullscreen| should
149 // be NO if the controller is in the process of entering fullscreen.
150 - (void)setInAnyFullscreen:(BOOL)inAnyFullscreen;
151 - (void)setFullscreenSlidingStyle:(fullscreen_mac::SlidingStyle)slidingStyle;
152 - (void)setFullscreenMenubarOffset:(CGFloat)menubarOffset;
153 - (void)setFullscreenToolbarFraction:(CGFloat)toolbarFraction;
155 - (void)setHasTabStrip:(BOOL)hasTabStrip;
156 - (void)setFullscreenButtonFrame:(NSRect)frame;
157 - (void)setShouldShowAvatar:(BOOL)shouldShowAvatar;
158 - (void)setShouldUseNewAvatar:(BOOL)shouldUseNewAvatar;
159 - (void)setAvatarSize:(NSSize)avatarSize;
160 - (void)setAvatarLineWidth:(CGFloat)avatarLineWidth;
162 - (void)setHasToolbar:(BOOL)hasToolbar;
163 - (void)setHasLocationBar:(BOOL)hasLocationBar;
164 - (void)setToolbarHeight:(CGFloat)toolbarHeight;
166 - (void)setBookmarkBarHidden:(BOOL)bookmarkBarHidden;
167 - (void)setPlaceBookmarkBarBelowInfoBar:(BOOL)placeBookmarkBarBelowInfoBar;
168 - (void)setBookmarkBarHeight:(CGFloat)bookmarkBarHeight;
170 // The height of the info bar, not including the top arrow.
171 - (void)setInfoBarHeight:(CGFloat)infoBarHeight;
172 // The min Y of the bubble point, relative to the toolbar.
173 - (void)setPageInfoBubblePointY:(CGFloat)pageInfoBubblePointY;
175 - (void)setHasDownloadShelf:(BOOL)hasDownloadShelf;
176 - (void)setDownloadShelfHeight:(CGFloat)downloadShelfHeight;
177 @end
179 @interface BrowserWindowLayout (ExposedForTesting)
180 - (void)setOSYosemiteOrLater:(BOOL)osYosemiteOrLater;
181 @end
183 #endif // CHROME_BROWSER_UI_COCOA_BROWSER_WINDOW_CONTROLLER_LAYOUT_H_