Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / chrome / browser / ui / views / frame / opaque_browser_frame_view.h
blob4e3ef3891c2f1739deb25c692e746f60d6e45932
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_VIEWS_FRAME_OPAQUE_BROWSER_FRAME_VIEW_H_
6 #define CHROME_BROWSER_UI_VIEWS_FRAME_OPAQUE_BROWSER_FRAME_VIEW_H_
8 #include "base/memory/scoped_ptr.h"
9 #include "chrome/browser/ui/view_ids.h"
10 #include "chrome/browser/ui/views/frame/browser_frame.h"
11 #include "chrome/browser/ui/views/frame/browser_non_client_frame_view.h"
12 #include "chrome/browser/ui/views/frame/opaque_browser_frame_view_layout_delegate.h"
13 #include "chrome/browser/ui/views/tab_icon_view_model.h"
14 #include "ui/views/controls/button/button.h"
15 #include "ui/views/controls/button/menu_button_listener.h"
16 #include "ui/views/window/non_client_view.h"
18 class BrowserView;
19 class OpaqueBrowserFrameViewLayout;
20 class OpaqueBrowserFrameViewPlatformSpecific;
21 class TabIconView;
22 class NewAvatarButton;
24 namespace views {
25 class ImageButton;
26 class FrameBackground;
27 class Label;
30 class OpaqueBrowserFrameView : public BrowserNonClientFrameView,
31 public views::ButtonListener,
32 public views::MenuButtonListener,
33 public chrome::TabIconViewModel,
34 public OpaqueBrowserFrameViewLayoutDelegate {
35 public:
36 // Constructs a non-client view for an BrowserFrame.
37 OpaqueBrowserFrameView(BrowserFrame* frame, BrowserView* browser_view);
38 ~OpaqueBrowserFrameView() override;
40 // BrowserNonClientFrameView:
41 gfx::Rect GetBoundsForTabStrip(views::View* tabstrip) const override;
42 int GetTopInset() const override;
43 int GetThemeBackgroundXInset() const override;
44 void UpdateThrobber(bool running) override;
45 gfx::Size GetMinimumSize() const override;
47 // views::NonClientFrameView:
48 gfx::Rect GetBoundsForClientView() const override;
49 gfx::Rect GetWindowBoundsForClientBounds(
50 const gfx::Rect& client_bounds) const override;
51 int NonClientHitTest(const gfx::Point& point) override;
52 void GetWindowMask(const gfx::Size& size, gfx::Path* window_mask) override;
53 void ResetWindowControls() override;
54 void UpdateWindowIcon() override;
55 void UpdateWindowTitle() override;
56 void SizeConstraintsChanged() override;
58 // views::View:
59 void GetAccessibleState(ui::AXViewState* state) override;
61 // views::ButtonListener:
62 void ButtonPressed(views::Button* sender, const ui::Event& event) override;
64 // views::MenuButtonListener:
65 void OnMenuButtonClicked(views::View* source,
66 const gfx::Point& point) override;
68 // chrome::TabIconViewModel:
69 bool ShouldTabIconViewAnimate() const override;
70 gfx::ImageSkia GetFaviconForTabIconView() override;
72 // OpaqueBrowserFrameViewLayoutDelegate implementation:
73 bool ShouldShowWindowIcon() const override;
74 bool ShouldShowWindowTitle() const override;
75 base::string16 GetWindowTitle() const override;
76 int GetIconSize() const override;
77 bool ShouldLeaveOffsetNearTopBorder() const override;
78 gfx::Size GetBrowserViewMinimumSize() const override;
79 bool ShouldShowCaptionButtons() const override;
80 bool ShouldShowAvatar() const override;
81 bool IsRegularOrGuestSession() const override;
82 gfx::ImageSkia GetOTRAvatarIcon() const override;
83 bool IsMaximized() const override;
84 bool IsMinimized() const override;
85 bool IsFullscreen() const override;
86 bool IsTabStripVisible() const override;
87 int GetTabStripHeight() const override;
88 gfx::Size GetTabstripPreferredSize() const override;
90 protected:
91 views::ImageButton* minimize_button() const { return minimize_button_; }
92 views::ImageButton* maximize_button() const { return maximize_button_; }
93 views::ImageButton* restore_button() const { return restore_button_; }
94 views::ImageButton* close_button() const { return close_button_; }
96 // views::View:
97 void OnPaint(gfx::Canvas* canvas) override;
99 // BrowserNonClientFrameView:
100 bool ShouldPaintAsThemed() const override;
101 void UpdateNewAvatarButtonImpl() override;
103 private:
104 // views::NonClientFrameView:
105 bool DoesIntersectRect(const views::View* target,
106 const gfx::Rect& rect) const override;
108 // Creates, adds and returns a new image button with |this| as its listener.
109 // Memory is owned by the caller.
110 views::ImageButton* InitWindowCaptionButton(int normal_image_id,
111 int hot_image_id,
112 int pushed_image_id,
113 int mask_image_id,
114 int accessibility_string_id,
115 ViewID view_id);
117 // Returns the thickness of the border that makes up the window frame edges.
118 // This does not include any client edge. If |restored| is true, acts as if
119 // the window is restored regardless of the real mode.
120 int FrameBorderThickness(bool restored) const;
122 // Returns the height of the top resize area. This is smaller than the frame
123 // border height in order to increase the window draggable area.
124 int TopResizeHeight() const;
126 // Returns true if the specified point is within the avatar menu buttons.
127 bool IsWithinAvatarMenuButtons(const gfx::Point& point) const;
129 // Returns the thickness of the entire nonclient left, right, and bottom
130 // borders, including both the window frame and any client edge.
131 int NonClientBorderThickness() const;
133 // Returns the bounds of the titlebar icon (or where the icon would be if
134 // there was one).
135 gfx::Rect IconBounds() const;
137 // Returns true if the view should draw its own custom title bar.
138 bool ShouldShowWindowTitleBar() const;
140 // Paint various sub-components of this view. The *FrameBorder() functions
141 // also paint the background of the titlebar area, since the top frame border
142 // and titlebar background are a contiguous component.
143 void PaintRestoredFrameBorder(gfx::Canvas* canvas);
144 void PaintMaximizedFrameBorder(gfx::Canvas* canvas);
145 void PaintToolbarBackground(gfx::Canvas* canvas);
146 void PaintRestoredClientEdge(gfx::Canvas* canvas);
148 // Returns the bounds of the client area for the specified view size.
149 gfx::Rect CalculateClientAreaBounds(int width, int height) const;
151 // Our layout manager also calculates various bounds.
152 OpaqueBrowserFrameViewLayout* layout_;
154 // Window controls.
155 views::ImageButton* minimize_button_;
156 views::ImageButton* maximize_button_;
157 views::ImageButton* restore_button_;
158 views::ImageButton* close_button_;
160 // The window icon and title.
161 TabIconView* window_icon_;
162 views::Label* window_title_;
164 // Background painter for the window frame.
165 scoped_ptr<views::FrameBackground> frame_background_;
167 // Observer that handles platform dependent configuration.
168 scoped_ptr<OpaqueBrowserFrameViewPlatformSpecific> platform_observer_;
170 DISALLOW_COPY_AND_ASSIGN(OpaqueBrowserFrameView);
173 #endif // CHROME_BROWSER_UI_VIEWS_FRAME_OPAQUE_BROWSER_FRAME_VIEW_H_