browser_non_client_frame_view_ash.h revision 5f1c94371a64b3196d4be9466099bb892df9b88e
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/ui/views/frame/browser_non_client_frame_view.h" 12#include "chrome/browser/ui/views/tab_icon_view_model.h" 13 14class TabIconView; 15 16namespace ash { 17class FrameBorderHitTestController; 18class FrameCaptionButtonContainerView; 19class HeaderPainter; 20} 21namespace views { 22class ImageButton; 23class ToggleImageButton; 24} 25 26class BrowserNonClientFrameViewAsh 27 : public BrowserNonClientFrameView, 28 public ash::ShellObserver, 29 public chrome::TabIconViewModel { 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: 39 virtual gfx::Rect GetBoundsForTabStrip(views::View* tabstrip) const OVERRIDE; 40 virtual int GetTopInset() const OVERRIDE; 41 virtual int GetThemeBackgroundXInset() const OVERRIDE; 42 virtual void UpdateThrobber(bool running) OVERRIDE; 43 44 // views::NonClientFrameView: 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: 56 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; 57 virtual void Layout() OVERRIDE; 58 virtual const char* GetClassName() const OVERRIDE; 59 virtual void GetAccessibleState(ui::AXViewState* state) OVERRIDE; 60 virtual gfx::Size GetMinimumSize() const OVERRIDE; 61 virtual void ChildPreferredSizeChanged(views::View* child) OVERRIDE; 62 63 // ash::ShellObserver: 64 virtual void OnMaximizeModeStarted() OVERRIDE; 65 virtual void OnMaximizeModeEnded() OVERRIDE; 66 67 // chrome::TabIconViewModel: 68 virtual bool ShouldTabIconViewAnimate() const OVERRIDE; 69 virtual gfx::ImageSkia GetFaviconForTabIconView() OVERRIDE; 70 71 private: 72 FRIEND_TEST_ALL_PREFIXES(BrowserNonClientFrameViewAshTest, WindowHeader); 73 FRIEND_TEST_ALL_PREFIXES(BrowserNonClientFrameViewAshTest, 74 NonImmersiveFullscreen); 75 FRIEND_TEST_ALL_PREFIXES(BrowserNonClientFrameViewAshTest, 76 ImmersiveFullscreen); 77 FRIEND_TEST_ALL_PREFIXES(BrowserNonClientFrameViewAshTest, 78 ToggleMaximizeModeRelayout); 79 80 // views::NonClientFrameView: 81 virtual bool DoesIntersectRect(const views::View* target, 82 const gfx::Rect& rect) const OVERRIDE; 83 84 // Distance between the left edge of the NonClientFrameView and the tab strip. 85 int GetTabStripLeftInset() const; 86 87 // Distance between the right edge of the NonClientFrameView and the tab 88 // strip. 89 int GetTabStripRightInset() const; 90 91 // Returns true if we should use a super short header with light bars instead 92 // of regular tabs. This header is used in immersive fullscreen when the 93 // top-of-window views are not revealed. 94 bool UseImmersiveLightbarHeaderStyle() const; 95 96 // Returns true if the header should be painted so that it looks the same as 97 // the header used for packaged apps. Packaged apps use a different color 98 // scheme than browser windows. 99 bool UsePackagedAppHeaderStyle() const; 100 101 // Layout the incognito icon. 102 void LayoutAvatar(); 103 104 // Returns true if there is anything to paint. Some fullscreen windows do not 105 // need their frames painted. 106 bool ShouldPaint() const; 107 108 // Paints the header background when the frame is in immersive fullscreen and 109 // tab light bar is visible. 110 void PaintImmersiveLightbarStyleHeader(gfx::Canvas* canvas); 111 112 void PaintToolbarBackground(gfx::Canvas* canvas); 113 114 // Draws the line under the header for windows without a toolbar and not using 115 // the packaged app header style. 116 void PaintContentEdge(gfx::Canvas* canvas); 117 118 // View which contains the window controls. 119 ash::FrameCaptionButtonContainerView* caption_button_container_; 120 121 // For popups, the window icon. 122 TabIconView* window_icon_; 123 124 // Helper class for painting the header. 125 scoped_ptr<ash::HeaderPainter> header_painter_; 126 127 // Updates the hittest bounds overrides based on the window show type. 128 scoped_ptr<ash::FrameBorderHitTestController> 129 frame_border_hit_test_controller_; 130 131 DISALLOW_COPY_AND_ASSIGN(BrowserNonClientFrameViewAsh); 132}; 133 134#endif // CHROME_BROWSER_UI_VIEWS_FRAME_BROWSER_NON_CLIENT_FRAME_VIEW_ASH_H_ 135