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/command_observer.h"
12 #include "chrome/browser/ui/views/frame/browser_non_client_frame_view.h"
13 #include "chrome/browser/ui/views/tab_icon_view_model.h"
14 #include "ui/views/controls/button/button.h"
19 class FrameBorderHitTestController;
20 class FrameCaptionButton;
21 class FrameCaptionButtonContainerView;
26 class ToggleImageButton;
29 class BrowserNonClientFrameViewAsh : public BrowserNonClientFrameView,
30 public ash::ShellObserver,
31 public chrome::TabIconViewModel,
32 public CommandObserver,
33 public views::ButtonListener {
35 static const char kViewClassName[];
37 BrowserNonClientFrameViewAsh(BrowserFrame* frame, BrowserView* browser_view);
38 virtual ~BrowserNonClientFrameViewAsh();
42 // BrowserNonClientFrameView:
43 virtual gfx::Rect GetBoundsForTabStrip(views::View* tabstrip) const OVERRIDE;
44 virtual int GetTopInset() const OVERRIDE;
45 virtual int GetThemeBackgroundXInset() const OVERRIDE;
46 virtual void UpdateThrobber(bool running) OVERRIDE;
48 // views::NonClientFrameView:
49 virtual gfx::Rect GetBoundsForClientView() const OVERRIDE;
50 virtual gfx::Rect GetWindowBoundsForClientBounds(
51 const gfx::Rect& client_bounds) const OVERRIDE;
52 virtual int NonClientHitTest(const gfx::Point& point) OVERRIDE;
53 virtual void GetWindowMask(const gfx::Size& size,
54 gfx::Path* window_mask) OVERRIDE;
55 virtual void ResetWindowControls() OVERRIDE;
56 virtual void UpdateWindowIcon() OVERRIDE;
57 virtual void UpdateWindowTitle() OVERRIDE;
58 virtual void SizeConstraintsChanged() OVERRIDE;
61 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE;
62 virtual void Layout() OVERRIDE;
63 virtual const char* GetClassName() const OVERRIDE;
64 virtual void GetAccessibleState(ui::AXViewState* state) OVERRIDE;
65 virtual gfx::Size GetMinimumSize() const OVERRIDE;
66 virtual void ChildPreferredSizeChanged(views::View* child) OVERRIDE;
68 // ash::ShellObserver:
69 virtual void OnMaximizeModeStarted() OVERRIDE;
70 virtual void OnMaximizeModeEnded() OVERRIDE;
72 // chrome::TabIconViewModel:
73 virtual bool ShouldTabIconViewAnimate() const OVERRIDE;
74 virtual gfx::ImageSkia GetFaviconForTabIconView() OVERRIDE;
77 virtual void EnabledStateChangedForCommand(int id, bool enabled) OVERRIDE;
79 // views::ButtonListener:
80 virtual void ButtonPressed(views::Button* sender,
81 const ui::Event& event) OVERRIDE;
84 FRIEND_TEST_ALL_PREFIXES(BrowserNonClientFrameViewAshTest, WindowHeader);
85 FRIEND_TEST_ALL_PREFIXES(BrowserNonClientFrameViewAshTest,
86 NonImmersiveFullscreen);
87 FRIEND_TEST_ALL_PREFIXES(BrowserNonClientFrameViewAshTest,
89 FRIEND_TEST_ALL_PREFIXES(BrowserNonClientFrameViewAshTest,
90 ToggleMaximizeModeRelayout);
92 // views::NonClientFrameView:
93 virtual bool DoesIntersectRect(const views::View* target,
94 const gfx::Rect& rect) const OVERRIDE;
96 // Distance between the left edge of the NonClientFrameView and the tab strip.
97 int GetTabStripLeftInset() const;
99 // Distance between the right edge of the NonClientFrameView and the tab
101 int GetTabStripRightInset() const;
103 // Returns true if we should use a super short header with light bars instead
104 // of regular tabs. This header is used in immersive fullscreen when the
105 // top-of-window views are not revealed.
106 bool UseImmersiveLightbarHeaderStyle() const;
108 // Returns true if the header should be painted so that it looks the same as
109 // the header used for packaged apps. Packaged apps use a different color
110 // scheme than browser windows.
111 bool UsePackagedAppHeaderStyle() const;
113 // Returns true if the header should be painted with a WebApp header style.
114 // The WebApp header style has a back button and title along with the usual
116 bool UseWebAppHeaderStyle() const;
118 // Layout the incognito icon.
121 // Returns true if there is anything to paint. Some fullscreen windows do not
122 // need their frames painted.
123 bool ShouldPaint() const;
125 // Paints the header background when the frame is in immersive fullscreen and
126 // tab light bar is visible.
127 void PaintImmersiveLightbarStyleHeader(gfx::Canvas* canvas);
129 void PaintToolbarBackground(gfx::Canvas* canvas);
131 // Draws the line under the header for windows without a toolbar and not using
132 // the packaged app header style.
133 void PaintContentEdge(gfx::Canvas* canvas);
135 // Update the state of the back button.
136 void UpdateBackButtonState(bool enabled);
138 // View which contains the window controls.
139 ash::FrameCaptionButtonContainerView* caption_button_container_;
141 // The back button for web app style header.
142 ash::FrameCaptionButton* web_app_back_button_;
144 // For popups, the window icon.
145 TabIconView* window_icon_;
147 // Helper class for painting the header.
148 scoped_ptr<ash::HeaderPainter> header_painter_;
150 // Updates the hittest bounds overrides based on the window show type.
151 scoped_ptr<ash::FrameBorderHitTestController>
152 frame_border_hit_test_controller_;
154 DISALLOW_COPY_AND_ASSIGN(BrowserNonClientFrameViewAsh);
157 #endif // CHROME_BROWSER_UI_VIEWS_FRAME_BROWSER_NON_CLIENT_FRAME_VIEW_ASH_H_