Add new certificateProvider extension API.
[chromium-blink-merge.git] / chrome / browser / ui / views / frame / opaque_browser_frame_view_layout.h
blob30f3d97f0d97efa006d53a3cd9d7857aa9af4bd0
1 // Copyright 2013 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_VIEWS_FRAME_OPAQUE_BROWSER_FRAME_VIEW_LAYOUT_H_
6 #define CHROME_BROWSER_UI_VIEWS_FRAME_OPAQUE_BROWSER_FRAME_VIEW_LAYOUT_H_
8 #include "chrome/browser/ui/views/frame/opaque_browser_frame_view.h"
9 #include "ui/views/layout/layout_manager.h"
10 #include "ui/views/window/frame_buttons.h"
12 class AvatarMenuButton;
13 class NewAvatarButton;
14 class OpaqueBrowserFrameViewLayoutDelegate;
16 #if defined(ENABLE_SUPERVISED_USERS)
17 class SupervisedUserAvatarLabel;
18 #endif
20 namespace views {
21 class ImageButton;
22 class Label;
25 // Calculates the position of the widgets in the opaque browser frame view.
27 // This is separated out for testing reasons. OpaqueBrowserFrameView has tight
28 // dependencies with Browser and classes that depend on Browser.
29 class OpaqueBrowserFrameViewLayout : public views::LayoutManager {
30 public:
31 explicit OpaqueBrowserFrameViewLayout(
32 OpaqueBrowserFrameViewLayoutDelegate* delegate);
33 ~OpaqueBrowserFrameViewLayout() override;
35 // Whether we should add the (minimize,maximize,close) buttons. This should be
36 // true if the buttons could be shown at any time in this session (see
37 // OpaqueBrowserFrameViewLayoutDelegate::ShouldShowCaptionButtons for whether
38 // they are currently visible).
39 static bool ShouldAddDefaultCaptionButtons();
41 // Configures the button ordering in the frame.
42 void SetButtonOrdering(
43 const std::vector<views::FrameButton>& leading_buttons,
44 const std::vector<views::FrameButton>& trailing_buttons);
46 gfx::Rect GetBoundsForTabStrip(
47 const gfx::Size& tabstrip_preferred_size,
48 int available_width) const;
50 gfx::Size GetMinimumSize(int available_width) const;
52 // Returns the bounds of the window required to display the content area at
53 // the specified bounds.
54 gfx::Rect GetWindowBoundsForClientBounds(
55 const gfx::Rect& client_bounds) const;
57 // Returns the thickness of the border that makes up the window frame edges.
58 // This does not include any client edge. If |restored| is true, acts as if
59 // the window is restored regardless of the real mode.
60 int FrameBorderThickness(bool restored) const;
62 // Returns the thickness of the entire nonclient left, right, and bottom
63 // borders, including both the window frame and any client edge.
64 int NonClientBorderThickness() const;
66 // Returns the height of the entire nonclient top border, including the window
67 // frame, any title area, and any connected client edge. If |restored| is
68 // true, acts as if the window is restored regardless of the real mode.
69 int NonClientTopBorderHeight(bool restored) const;
71 int GetTabStripInsetsTop(bool restored) const;
73 // Returns the y-coordinate of the caption buttons. If |restored| is true,
74 // acts as if the window is restored regardless of the real mode.
75 int CaptionButtonY(bool restored) const;
77 // Returns the thickness of the 3D edge along the bottom of the titlebar. If
78 // |restored| is true, acts as if the window is restored regardless of the
79 // real mode.
80 int TitlebarBottomThickness(bool restored) const;
82 // Returns the bounds of the titlebar icon (or where the icon would be if
83 // there was one).
84 gfx::Rect IconBounds() const;
86 // Returns the bounds of the client area for the specified view size.
87 gfx::Rect CalculateClientAreaBounds(int width, int height) const;
89 void set_extra_caption_y(int extra_caption_y) {
90 extra_caption_y_ = extra_caption_y;
93 void set_window_caption_spacing(int window_caption_spacing) {
94 window_caption_spacing_ = window_caption_spacing;
97 const gfx::Rect& client_view_bounds() const { return client_view_bounds_; }
99 // Determines whether the title bar is condensed vertically, as when the
100 // window is maximized. If true, the title bar is just the height of a tab,
101 // rather than having extra vertical space above the tabs. This also removes
102 // the thick frame border and rounded corners.
103 bool IsTitleBarCondensed() const;
105 private:
106 // Whether a specific button should be inserted on the leading or trailing
107 // side.
108 enum ButtonAlignment {
109 ALIGN_LEADING,
110 ALIGN_TRAILING
113 // Determines whether the avatar should be shown on the right side of the tab
114 // strip (instead of the usual left).
115 bool ShouldAvatarBeOnRight() const;
117 // Determines the amount of spacing between the New Tab button and the element
118 // to its immediate right.
119 int NewTabCaptionSpacing() const;
121 // Layout various sub-components of this view.
122 void LayoutWindowControls(views::View* host);
123 void LayoutTitleBar(views::View* host);
124 void LayoutAvatar(views::View* host);
125 void LayoutNewStyleAvatar(views::View* host);
127 void ConfigureButton(views::View* host,
128 views::FrameButton button_id,
129 ButtonAlignment align,
130 int caption_y);
132 // Sets the visibility of all buttons associated with |button_id| to false.
133 void HideButton(views::FrameButton button_id);
135 // Adds a window caption button to either the leading or trailing side.
136 void SetBoundsForButton(views::View* host,
137 views::ImageButton* button,
138 ButtonAlignment align,
139 int caption_y);
141 // Internal implementation of ViewAdded() and ViewRemoved().
142 void SetView(int id, views::View* view);
144 // Overriden from views::LayoutManager:
145 void Layout(views::View* host) override;
146 gfx::Size GetPreferredSize(const views::View* host) const override;
147 void ViewAdded(views::View* host, views::View* view) override;
148 void ViewRemoved(views::View* host, views::View* view) override;
150 OpaqueBrowserFrameViewLayoutDelegate* delegate_;
152 // The layout rect of the avatar icon, if visible.
153 gfx::Rect avatar_bounds_;
155 // The bounds of the ClientView.
156 gfx::Rect client_view_bounds_;
158 // The layout of the window icon, if visible.
159 gfx::Rect window_icon_bounds_;
161 // How far from the leading/trailing edge of the view the next window control
162 // should be placed.
163 int leading_button_start_;
164 int trailing_button_start_;
166 // The size of the window buttons, and the avatar menu item (if any). This
167 // does not count labels or other elements that should be counted in a
168 // minimal frame.
169 int minimum_size_for_buttons_;
171 // Whether any of the window control buttons were packed on the leading.
172 bool has_leading_buttons_;
173 bool has_trailing_buttons_;
175 // Extra offset from the top of the frame to the top of the window control
176 // buttons. Configurable based on platform and whether we are under test.
177 int extra_caption_y_;
179 // Extra offset between the individual window caption buttons.
180 int window_caption_spacing_;
182 // Window controls.
183 views::ImageButton* minimize_button_;
184 views::ImageButton* maximize_button_;
185 views::ImageButton* restore_button_;
186 views::ImageButton* close_button_;
188 views::View* window_icon_;
189 views::Label* window_title_;
191 #if defined(ENABLE_SUPERVISED_USERS)
192 SupervisedUserAvatarLabel* supervised_user_avatar_label_;
193 #endif
194 AvatarMenuButton* avatar_button_;
195 views::View* new_avatar_button_;
197 std::vector<views::FrameButton> leading_buttons_;
198 std::vector<views::FrameButton> trailing_buttons_;
200 DISALLOW_COPY_AND_ASSIGN(OpaqueBrowserFrameViewLayout);
203 #endif // CHROME_BROWSER_UI_VIEWS_FRAME_OPAQUE_BROWSER_FRAME_VIEW_LAYOUT_H_