browser_non_client_frame_view_ash.h revision 424c4d7b64af9d0d8fd9624f381f469654d5e3d2
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 FrameCaptionButtonContainerView; 17class FramePainter; 18} 19namespace views { 20class ImageButton; 21class ToggleImageButton; 22} 23 24class BrowserNonClientFrameViewAsh 25 : public BrowserNonClientFrameView, 26 public chrome::TabIconViewModel { 27 public: 28 static const char kViewClassName[]; 29 30 BrowserNonClientFrameViewAsh(BrowserFrame* frame, BrowserView* browser_view); 31 virtual ~BrowserNonClientFrameViewAsh(); 32 33 void Init(); 34 35 // BrowserNonClientFrameView overrides: 36 virtual gfx::Rect GetBoundsForTabStrip(views::View* tabstrip) const OVERRIDE; 37 virtual TabStripInsets GetTabStripInsets(bool force_restored) const OVERRIDE; 38 virtual int GetThemeBackgroundXInset() const OVERRIDE; 39 virtual void UpdateThrobber(bool running) OVERRIDE; 40 41 // views::NonClientFrameView overrides: 42 virtual gfx::Rect GetBoundsForClientView() const OVERRIDE; 43 virtual gfx::Rect GetWindowBoundsForClientBounds( 44 const gfx::Rect& client_bounds) const OVERRIDE; 45 virtual int NonClientHitTest(const gfx::Point& point) OVERRIDE; 46 virtual void GetWindowMask(const gfx::Size& size, 47 gfx::Path* window_mask) OVERRIDE; 48 virtual void ResetWindowControls() OVERRIDE; 49 virtual void UpdateWindowIcon() OVERRIDE; 50 virtual void UpdateWindowTitle() OVERRIDE; 51 52 // views::View overrides: 53 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; 54 virtual void Layout() OVERRIDE; 55 virtual const char* GetClassName() const OVERRIDE; 56 virtual bool HitTestRect(const gfx::Rect& rect) const OVERRIDE; 57 virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; 58 virtual gfx::Size GetMinimumSize() OVERRIDE; 59 virtual void OnThemeChanged() 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 top of window and client area. 73 int NonClientTopBorderHeight(bool force_restored) const; 74 75 // Returns true if we should use a short header, such as for popup windows. 76 bool UseShortHeader() const; 77 78 // Returns true if we should use a super short header with light bars instead 79 // of regular tabs. This header is used in immersive fullscreen when the 80 // top-of-window views are not revealed. 81 bool UseImmersiveLightbarHeaderStyle() const; 82 83 // Layout the incognito icon. 84 void LayoutAvatar(); 85 86 // Returns true if there is anything to paint. Some fullscreen windows do not 87 // need their frames painted. 88 bool ShouldPaint() const; 89 90 // Paints the header background when the frame is in immersive fullscreen and 91 // tab light bar is visible. 92 void PaintImmersiveLightbarStyleHeader(gfx::Canvas* canvas); 93 94 void PaintToolbarBackground(gfx::Canvas* canvas); 95 96 // Windows without a toolbar need to draw their own line under the header, 97 // above the content area. 98 void PaintContentEdge(gfx::Canvas* canvas); 99 100 // Returns the id of the header frame image based on the browser type, 101 // activation state and incognito mode. 102 int GetThemeFrameImageId() const; 103 104 // Returns the id of the header frame overlay image based on the activation 105 // state and incognito mode. 106 // Returns 0 if no overlay image should be used. 107 int GetThemeFrameOverlayImageId() const; 108 109 // View which contains the window controls. 110 ash::FrameCaptionButtonContainerView* caption_button_container_; 111 112 // For popups, the window icon. 113 TabIconView* window_icon_; 114 115 // Painter for the frame header. 116 scoped_ptr<ash::FramePainter> frame_painter_; 117 118 DISALLOW_COPY_AND_ASSIGN(BrowserNonClientFrameViewAsh); 119}; 120 121#endif // CHROME_BROWSER_UI_VIEWS_FRAME_BROWSER_NON_CLIENT_FRAME_VIEW_ASH_H_ 122