Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / chrome / browser / ui / views / frame / browser_non_client_frame_view_ash.h
blobdce0c276e472a277b6743fbdf14f8dda1fb70ea9
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_BROWSER_NON_CLIENT_FRAME_VIEW_ASH_H_
6 #define CHROME_BROWSER_UI_VIEWS_FRAME_BROWSER_NON_CLIENT_FRAME_VIEW_ASH_H_
8 #include "ash/shell_observer.h"
9 #include "base/gtest_prod_util.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "chrome/browser/ui/views/frame/browser_non_client_frame_view.h"
12 #include "chrome/browser/ui/views/tab_icon_view_model.h"
13 #include "ui/views/controls/button/button.h"
15 class TabIconView;
16 class WebAppLeftHeaderView;
18 namespace ash {
19 class FrameBorderHitTestController;
20 class FrameCaptionButton;
21 class FrameCaptionButtonContainerView;
22 class HeaderPainter;
25 namespace views {
26 class ImageButton;
27 class ToggleImageButton;
30 class BrowserNonClientFrameViewAsh : public BrowserNonClientFrameView,
31 public ash::ShellObserver,
32 public chrome::TabIconViewModel,
33 public views::ButtonListener {
34 public:
35 static const char kViewClassName[];
37 BrowserNonClientFrameViewAsh(BrowserFrame* frame, BrowserView* browser_view);
38 ~BrowserNonClientFrameViewAsh() override;
40 void Init();
42 // BrowserNonClientFrameView:
43 gfx::Rect GetBoundsForTabStrip(views::View* tabstrip) const override;
44 int GetTopInset() const override;
45 int GetThemeBackgroundXInset() const override;
46 void UpdateThrobber(bool running) override;
47 void UpdateToolbar() override;
48 views::View* GetLocationIconView() const override;
50 // views::NonClientFrameView:
51 gfx::Rect GetBoundsForClientView() const override;
52 gfx::Rect GetWindowBoundsForClientBounds(
53 const gfx::Rect& client_bounds) const override;
54 int NonClientHitTest(const gfx::Point& point) override;
55 void GetWindowMask(const gfx::Size& size, gfx::Path* window_mask) override;
56 void ResetWindowControls() override;
57 void UpdateWindowIcon() override;
58 void UpdateWindowTitle() override;
59 void SizeConstraintsChanged() override;
61 // views::View:
62 void OnPaint(gfx::Canvas* canvas) override;
63 void Layout() override;
64 const char* GetClassName() const override;
65 void GetAccessibleState(ui::AXViewState* state) override;
66 gfx::Size GetMinimumSize() const override;
67 void ChildPreferredSizeChanged(views::View* child) override;
69 // ash::ShellObserver:
70 void OnMaximizeModeStarted() override;
71 void OnMaximizeModeEnded() override;
73 // chrome::TabIconViewModel:
74 bool ShouldTabIconViewAnimate() const override;
75 gfx::ImageSkia GetFaviconForTabIconView() override;
77 // views::ButtonListener:
78 void ButtonPressed(views::Button* sender, const ui::Event& event) override;
80 protected:
81 // BrowserNonClientFrameView:
82 void UpdateNewAvatarButtonImpl() override;
84 private:
85 FRIEND_TEST_ALL_PREFIXES(BrowserNonClientFrameViewAshTest, WindowHeader);
86 FRIEND_TEST_ALL_PREFIXES(BrowserNonClientFrameViewAshTest,
87 NonImmersiveFullscreen);
88 FRIEND_TEST_ALL_PREFIXES(BrowserNonClientFrameViewAshTest,
89 ImmersiveFullscreen);
90 FRIEND_TEST_ALL_PREFIXES(BrowserNonClientFrameViewAshTest,
91 ToggleMaximizeModeRelayout);
92 FRIEND_TEST_ALL_PREFIXES(WebAppLeftHeaderViewTest, BackButton);
93 FRIEND_TEST_ALL_PREFIXES(WebAppLeftHeaderViewTest, LocationIcon);
95 // views::NonClientFrameView:
96 bool DoesIntersectRect(const views::View* target,
97 const gfx::Rect& rect) const override;
99 // Distance between the left edge of the NonClientFrameView and the tab strip.
100 int GetTabStripLeftInset() const;
102 // Distance between the right edge of the NonClientFrameView and the tab
103 // strip.
104 int GetTabStripRightInset() const;
106 // Returns true if we should use a super short header with light bars instead
107 // of regular tabs. This header is used in immersive fullscreen when the
108 // top-of-window views are not revealed.
109 bool UseImmersiveLightbarHeaderStyle() const;
111 // Returns true if the header should be painted so that it looks the same as
112 // the header used for packaged apps. Packaged apps use a different color
113 // scheme than browser windows.
114 bool UsePackagedAppHeaderStyle() const;
116 // Returns true if the header should be painted with a WebApp header style.
117 // The WebApp header style has a back button and title along with the usual
118 // accoutrements.
119 bool UseWebAppHeaderStyle() const;
121 // Layout the avatar button.
122 void LayoutAvatar();
123 #if defined(FRAME_AVATAR_BUTTON)
124 void LayoutNewStyleAvatar();
125 #endif
127 // Returns true if there is anything to paint. Some fullscreen windows do not
128 // need their frames painted.
129 bool ShouldPaint() const;
131 // Paints the header background when the frame is in immersive fullscreen and
132 // tab light bar is visible.
133 void PaintImmersiveLightbarStyleHeader(gfx::Canvas* canvas);
135 void PaintToolbarBackground(gfx::Canvas* canvas);
137 // Draws the line under the header for windows without a toolbar and not using
138 // the packaged app header style.
139 void PaintContentEdge(gfx::Canvas* canvas);
141 // View which contains the window controls.
142 ash::FrameCaptionButtonContainerView* caption_button_container_;
144 // The holder for the buttons on the left side of the header. This is included
145 // for web app style frames, and includes a back button and location icon.
146 WebAppLeftHeaderView* web_app_left_header_view_;
148 // For popups, the window icon.
149 TabIconView* window_icon_;
151 // Helper class for painting the header.
152 scoped_ptr<ash::HeaderPainter> header_painter_;
154 // Updates the hittest bounds overrides based on the window show type.
155 scoped_ptr<ash::FrameBorderHitTestController>
156 frame_border_hit_test_controller_;
158 DISALLOW_COPY_AND_ASSIGN(BrowserNonClientFrameViewAsh);
161 #endif // CHROME_BROWSER_UI_VIEWS_FRAME_BROWSER_NON_CLIENT_FRAME_VIEW_ASH_H_