browser_non_client_frame_view_ash.h revision a1401311d1ab56c4ed0a474bd38c108f75cb0cd9
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.
4
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_
7
8#include "base/gtest_prod_util.h"
9#include "base/memory/scoped_ptr.h"
10#include "chrome/browser/ui/views/frame/browser_non_client_frame_view.h"
11#include "chrome/browser/ui/views/tab_icon_view_model.h"
12
13class TabIconView;
14
15namespace ash {
16class FrameBorderHitTestController;
17class FrameCaptionButtonContainerView;
18class HeaderPainter;
19}
20namespace views {
21class ImageButton;
22class ToggleImageButton;
23}
24
25class BrowserNonClientFrameViewAsh
26    : public BrowserNonClientFrameView,
27      public chrome::TabIconViewModel {
28 public:
29  static const char kViewClassName[];
30
31  BrowserNonClientFrameViewAsh(BrowserFrame* frame, BrowserView* browser_view);
32  virtual ~BrowserNonClientFrameViewAsh();
33
34  void Init();
35
36  // BrowserNonClientFrameView overrides:
37  virtual gfx::Rect GetBoundsForTabStrip(views::View* tabstrip) const OVERRIDE;
38  virtual int GetTopInset() const OVERRIDE;
39  virtual int GetThemeBackgroundXInset() const OVERRIDE;
40  virtual void UpdateThrobber(bool running) OVERRIDE;
41
42  // views::NonClientFrameView overrides:
43  virtual gfx::Rect GetBoundsForClientView() const OVERRIDE;
44  virtual gfx::Rect GetWindowBoundsForClientBounds(
45      const gfx::Rect& client_bounds) const OVERRIDE;
46  virtual int NonClientHitTest(const gfx::Point& point) OVERRIDE;
47  virtual void GetWindowMask(const gfx::Size& size,
48                             gfx::Path* window_mask) OVERRIDE;
49  virtual void ResetWindowControls() OVERRIDE;
50  virtual void UpdateWindowIcon() OVERRIDE;
51  virtual void UpdateWindowTitle() OVERRIDE;
52
53  // views::View overrides:
54  virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE;
55  virtual void Layout() OVERRIDE;
56  virtual const char* GetClassName() const OVERRIDE;
57  virtual bool HitTestRect(const gfx::Rect& rect) const OVERRIDE;
58  virtual void GetAccessibleState(ui::AXViewState* state) OVERRIDE;
59  virtual gfx::Size GetMinimumSize() OVERRIDE;
60
61  // Overridden from chrome::TabIconViewModel:
62  virtual bool ShouldTabIconViewAnimate() const OVERRIDE;
63  virtual gfx::ImageSkia GetFaviconForTabIconView() OVERRIDE;
64
65 private:
66  FRIEND_TEST_ALL_PREFIXES(BrowserNonClientFrameViewAshTest, WindowHeader);
67  FRIEND_TEST_ALL_PREFIXES(BrowserNonClientFrameViewAshTest,
68                           NonImmersiveFullscreen);
69  FRIEND_TEST_ALL_PREFIXES(BrowserNonClientFrameViewAshTest,
70                           ImmersiveFullscreen);
71
72  // Distance between the left edge of the NonClientFrameView and the tab strip.
73  int GetTabStripLeftInset() const;
74
75  // Distance between the right edge of the NonClientFrameView and the tab
76  // strip.
77  int GetTabStripRightInset() const;
78
79  // Returns true if we should use a super short header with light bars instead
80  // of regular tabs. This header is used in immersive fullscreen when the
81  // top-of-window views are not revealed.
82  bool UseImmersiveLightbarHeaderStyle() const;
83
84  // Returns true if the header should be painted so that it looks the same as
85  // the header used for packaged apps. Packaged apps use a different color
86  // scheme than browser windows.
87  bool UsePackagedAppHeaderStyle() const;
88
89  // Layout the incognito icon.
90  void LayoutAvatar();
91
92  // Returns true if there is anything to paint. Some fullscreen windows do not
93  // need their frames painted.
94  bool ShouldPaint() const;
95
96  // Paints the header background when the frame is in immersive fullscreen and
97  // tab light bar is visible.
98  void PaintImmersiveLightbarStyleHeader(gfx::Canvas* canvas);
99
100  void PaintToolbarBackground(gfx::Canvas* canvas);
101
102  // Draws the line under the header for windows without a toolbar and not using
103  // the packaged app header style.
104  void PaintContentEdge(gfx::Canvas* canvas);
105
106  // View which contains the window controls.
107  ash::FrameCaptionButtonContainerView* caption_button_container_;
108
109  // For popups, the window icon.
110  TabIconView* window_icon_;
111
112  // Helper class for painting the header.
113  scoped_ptr<ash::HeaderPainter> header_painter_;
114
115  // Updates the hittest bounds overrides based on the window show type.
116  scoped_ptr<ash::FrameBorderHitTestController>
117      frame_border_hit_test_controller_;
118
119  DISALLOW_COPY_AND_ASSIGN(BrowserNonClientFrameViewAsh);
120};
121
122#endif  // CHROME_BROWSER_UI_VIEWS_FRAME_BROWSER_NON_CLIENT_FRAME_VIEW_ASH_H_
123