Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / ui / views / frame / browser_non_client_frame_view_ash.h
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 "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"
15
16 class TabIconView;
17
18 namespace ash {
19 class FrameBorderHitTestController;
20 class FrameCaptionButton;
21 class FrameCaptionButtonContainerView;
22 class HeaderPainter;
23 }
24 namespace views {
25 class ImageButton;
26 class ToggleImageButton;
27 }
28
29 class BrowserNonClientFrameViewAsh : public BrowserNonClientFrameView,
30                                      public ash::ShellObserver,
31                                      public chrome::TabIconViewModel,
32                                      public CommandObserver,
33                                      public views::ButtonListener {
34  public:
35   static const char kViewClassName[];
36
37   BrowserNonClientFrameViewAsh(BrowserFrame* frame, BrowserView* browser_view);
38   virtual ~BrowserNonClientFrameViewAsh();
39
40   void Init();
41
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;
47
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;
59
60   // views::View:
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;
67
68   // ash::ShellObserver:
69   virtual void OnMaximizeModeStarted() OVERRIDE;
70   virtual void OnMaximizeModeEnded() OVERRIDE;
71
72   // chrome::TabIconViewModel:
73   virtual bool ShouldTabIconViewAnimate() const OVERRIDE;
74   virtual gfx::ImageSkia GetFaviconForTabIconView() OVERRIDE;
75
76   // CommandObserver:
77   virtual void EnabledStateChangedForCommand(int id, bool enabled) OVERRIDE;
78
79   // views::ButtonListener:
80   virtual void ButtonPressed(views::Button* sender,
81                              const ui::Event& event) OVERRIDE;
82
83  private:
84   FRIEND_TEST_ALL_PREFIXES(BrowserNonClientFrameViewAshTest, WindowHeader);
85   FRIEND_TEST_ALL_PREFIXES(BrowserNonClientFrameViewAshTest,
86                            NonImmersiveFullscreen);
87   FRIEND_TEST_ALL_PREFIXES(BrowserNonClientFrameViewAshTest,
88                            ImmersiveFullscreen);
89   FRIEND_TEST_ALL_PREFIXES(BrowserNonClientFrameViewAshTest,
90                            ToggleMaximizeModeRelayout);
91
92   // views::NonClientFrameView:
93   virtual bool DoesIntersectRect(const views::View* target,
94                                  const gfx::Rect& rect) const OVERRIDE;
95
96   // Distance between the left edge of the NonClientFrameView and the tab strip.
97   int GetTabStripLeftInset() const;
98
99   // Distance between the right edge of the NonClientFrameView and the tab
100   // strip.
101   int GetTabStripRightInset() const;
102
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;
107
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;
112
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
115   // accoutrements.
116   bool UseWebAppHeaderStyle() const;
117
118   // Layout the incognito icon.
119   void LayoutAvatar();
120
121   // Returns true if there is anything to paint. Some fullscreen windows do not
122   // need their frames painted.
123   bool ShouldPaint() const;
124
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);
128
129   void PaintToolbarBackground(gfx::Canvas* canvas);
130
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);
134
135   // Update the state of the back button.
136   void UpdateBackButtonState(bool enabled);
137
138   // View which contains the window controls.
139   ash::FrameCaptionButtonContainerView* caption_button_container_;
140
141   // The back button for web app style header.
142   ash::FrameCaptionButton* web_app_back_button_;
143
144   // For popups, the window icon.
145   TabIconView* window_icon_;
146
147   // Helper class for painting the header.
148   scoped_ptr<ash::HeaderPainter> header_painter_;
149
150   // Updates the hittest bounds overrides based on the window show type.
151   scoped_ptr<ash::FrameBorderHitTestController>
152       frame_border_hit_test_controller_;
153
154   DISALLOW_COPY_AND_ASSIGN(BrowserNonClientFrameViewAsh);
155 };
156
157 #endif  // CHROME_BROWSER_UI_VIEWS_FRAME_BROWSER_NON_CLIENT_FRAME_VIEW_ASH_H_