OLD | NEW |
| (Empty) |
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_ASH_BROWSER_NON_CLIENT_FRAME_VIEW_ASH_H_ | |
6 #define CHROME_BROWSER_UI_VIEWS_ASH_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/search/search_types.h" | |
11 #include "chrome/browser/ui/search/toolbar_search_animator_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" // ButtonListener | |
15 | |
16 class TabIconView; | |
17 | |
18 namespace ash { | |
19 class FramePainter; | |
20 } | |
21 namespace views { | |
22 class ImageButton; | |
23 } | |
24 | |
25 class BrowserNonClientFrameViewAsh | |
26 : public BrowserNonClientFrameView, | |
27 public views::ButtonListener, | |
28 public chrome::TabIconViewModel, | |
29 public chrome::search::ToolbarSearchAnimatorObserver { | |
30 public: | |
31 static const char kViewClassName[]; | |
32 | |
33 BrowserNonClientFrameViewAsh(BrowserFrame* frame, BrowserView* browser_view); | |
34 virtual ~BrowserNonClientFrameViewAsh(); | |
35 | |
36 void Init(); | |
37 | |
38 // BrowserNonClientFrameView overrides: | |
39 virtual gfx::Rect GetBoundsForTabStrip(views::View* tabstrip) const OVERRIDE; | |
40 virtual TabStripInsets GetTabStripInsets(bool force_restored) const OVERRIDE; | |
41 virtual int GetThemeBackgroundXInset() const OVERRIDE; | |
42 virtual void UpdateThrobber(bool running) OVERRIDE; | |
43 | |
44 // views::NonClientFrameView overrides: | |
45 virtual gfx::Rect GetBoundsForClientView() const OVERRIDE; | |
46 virtual gfx::Rect GetWindowBoundsForClientBounds( | |
47 const gfx::Rect& client_bounds) const OVERRIDE; | |
48 virtual int NonClientHitTest(const gfx::Point& point) OVERRIDE; | |
49 virtual void GetWindowMask(const gfx::Size& size, | |
50 gfx::Path* window_mask) OVERRIDE; | |
51 virtual void ResetWindowControls() OVERRIDE; | |
52 virtual void UpdateWindowIcon() OVERRIDE; | |
53 virtual void UpdateWindowTitle() OVERRIDE; | |
54 | |
55 // views::View overrides: | |
56 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; | |
57 virtual void Layout() OVERRIDE; | |
58 virtual std::string GetClassName() const OVERRIDE; | |
59 virtual bool HitTestRect(const gfx::Rect& rect) const OVERRIDE; | |
60 virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; | |
61 virtual gfx::Size GetMinimumSize() OVERRIDE; | |
62 | |
63 // views::ButtonListener overrides: | |
64 virtual void ButtonPressed(views::Button* sender, | |
65 const ui::Event& event) OVERRIDE; | |
66 | |
67 // Overridden from chrome::TabIconViewModel: | |
68 virtual bool ShouldTabIconViewAnimate() const OVERRIDE; | |
69 virtual gfx::ImageSkia GetFaviconForTabIconView() OVERRIDE; | |
70 | |
71 // Overridden from chrome::search::ToolbarSearchAnimatorObserver: | |
72 virtual void OnToolbarBackgroundAnimatorProgressed() OVERRIDE; | |
73 virtual void OnToolbarBackgroundAnimatorCanceled( | |
74 content::WebContents* web_contents) OVERRIDE; | |
75 virtual void OnToolbarSeparatorChanged() OVERRIDE; | |
76 | |
77 private: | |
78 FRIEND_TEST_ALL_PREFIXES(BrowserNonClientFrameViewAshTest, UseShortHeader); | |
79 | |
80 // Distance between top of window and client area. | |
81 int NonClientTopBorderHeight(bool force_restored) const; | |
82 | |
83 // Returns true if we should use a short header, such as for popup windows. | |
84 bool UseShortHeader() const; | |
85 | |
86 // Layout the incognito icon. | |
87 void LayoutAvatar(); | |
88 | |
89 void PaintTitleBar(gfx::Canvas* canvas); | |
90 void PaintToolbarBackground(gfx::Canvas* canvas, | |
91 chrome::search::Mode::Type mode); | |
92 | |
93 // Windows without a toolbar need to draw their own line under the header, | |
94 // above the content area. | |
95 void PaintContentEdge(gfx::Canvas* canvas); | |
96 | |
97 // Returns the correct image id for the frame header based on activation | |
98 // state and incognito mode. | |
99 int GetThemeFrameImageId() const; | |
100 const gfx::ImageSkia* GetThemeFrameOverlayImage() const; | |
101 | |
102 // Window controls. The |size_button_| either toggles maximized or toggles | |
103 // minimized. The exact behavior is determined by |size_button_minimizes_|. | |
104 views::ImageButton* size_button_; | |
105 views::ImageButton* close_button_; | |
106 | |
107 // For popups, the window icon. | |
108 TabIconView* window_icon_; | |
109 | |
110 // Painter for the frame header. | |
111 scoped_ptr<ash::FramePainter> frame_painter_; | |
112 | |
113 // If true the |size_button_| minimizes, otherwise it toggles between | |
114 // maximized and restored. | |
115 bool size_button_minimizes_; | |
116 | |
117 DISALLOW_COPY_AND_ASSIGN(BrowserNonClientFrameViewAsh); | |
118 }; | |
119 | |
120 #endif // CHROME_BROWSER_UI_VIEWS_ASH_BROWSER_NON_CLIENT_FRAME_VIEW_ASH_H_ | |
OLD | NEW |