Home | History | Annotate | Download | only in frame
      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 #include "ui/views/controls/button/button.h"  // ButtonListener
     13 
     14 class TabIconView;
     15 
     16 namespace ash {
     17 class FramePainter;
     18 }
     19 namespace views {
     20 class ImageButton;
     21 class ToggleImageButton;
     22 }
     23 
     24 class BrowserNonClientFrameViewAsh
     25     : public BrowserNonClientFrameView,
     26       public views::ButtonListener,
     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 TabStripInsets GetTabStripInsets(bool force_restored) 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::AccessibleViewState* state) OVERRIDE;
     59   virtual gfx::Size GetMinimumSize() OVERRIDE;
     60   virtual void OnThemeChanged() OVERRIDE;
     61 
     62   // views::ButtonListener overrides:
     63   virtual void ButtonPressed(views::Button* sender,
     64                              const ui::Event& event) OVERRIDE;
     65 
     66   // Overridden from chrome::TabIconViewModel:
     67   virtual bool ShouldTabIconViewAnimate() const OVERRIDE;
     68   virtual gfx::ImageSkia GetFaviconForTabIconView() OVERRIDE;
     69 
     70  private:
     71   FRIEND_TEST_ALL_PREFIXES(BrowserNonClientFrameViewAshTest, WindowHeader);
     72   FRIEND_TEST_ALL_PREFIXES(BrowserNonClientFrameViewAshTest,
     73                            NonImmersiveFullscreen);
     74   FRIEND_TEST_ALL_PREFIXES(BrowserNonClientFrameViewAshTest,
     75                            ImmersiveFullscreen);
     76 
     77   // Distance between top of window and client area.
     78   int NonClientTopBorderHeight(bool force_restored) const;
     79 
     80   // Returns true if we should use a short header, such as for popup windows.
     81   bool UseShortHeader() const;
     82 
     83   // Returns true if we should use a super short header with light bars instead
     84   // of regular tabs. This header is used in immersive fullscreen when the
     85   // top-of-window views are not revealed.
     86   bool UseImmersiveLightbarHeaderStyle() const;
     87 
     88   // Layout the incognito icon.
     89   void LayoutAvatar();
     90 
     91   // Returns true if there is anything to paint. Some fullscreen windows do not
     92   // need their frames painted.
     93   bool ShouldPaint() const;
     94 
     95   // Paints the header background when the frame is in immersive fullscreen and
     96   // tab light bar is visible.
     97   void PaintImmersiveLightbarStyleHeader(gfx::Canvas* canvas);
     98 
     99   void PaintToolbarBackground(gfx::Canvas* canvas);
    100 
    101   // Windows without a toolbar need to draw their own line under the header,
    102   // above the content area.
    103   void PaintContentEdge(gfx::Canvas* canvas);
    104 
    105   // Returns the id of the header frame image based on the browser type,
    106   // activation state and incognito mode.
    107   int GetThemeFrameImageId() const;
    108 
    109   // Returns the id of the header frame overlay image based on the activation
    110   // state and incognito mode.
    111   // Returns 0 if no overlay image should be used.
    112   int GetThemeFrameOverlayImageId() const;
    113 
    114   // Window controls. The |size_button_| either toggles maximized or toggles
    115   // minimized. The exact behavior is determined by |size_button_minimizes_|.
    116   views::ImageButton* size_button_;
    117   views::ImageButton* close_button_;
    118 
    119   // For popups, the window icon.
    120   TabIconView* window_icon_;
    121 
    122   // Painter for the frame header.
    123   scoped_ptr<ash::FramePainter> frame_painter_;
    124 
    125   // If true the |size_button_| minimizes, otherwise it toggles between
    126   // maximized and restored.
    127   bool size_button_minimizes_;
    128 
    129   DISALLOW_COPY_AND_ASSIGN(BrowserNonClientFrameViewAsh);
    130 };
    131 
    132 #endif  // CHROME_BROWSER_UI_VIEWS_FRAME_BROWSER_NON_CLIENT_FRAME_VIEW_ASH_H_
    133