Popular sites on the NTP: check that experiment group StartsWith (rather than IS...
[chromium-blink-merge.git] / chrome / browser / ui / views / frame / browser_header_painter_ash.h
blob3f4e7a979ba580b98a85724876d12fe4136e9214
1 // Copyright 2014 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.
5 #ifndef CHROME_BROWSER_UI_VIEWS_FRAME_BROWSER_HEADER_PAINTER_ASH_H_
6 #define CHROME_BROWSER_UI_VIEWS_FRAME_BROWSER_HEADER_PAINTER_ASH_H_
8 #include "ash/frame/header_painter.h"
9 #include "base/basictypes.h"
10 #include "base/compiler_specific.h" // override
11 #include "base/memory/scoped_ptr.h"
12 #include "ui/gfx/animation/animation_delegate.h"
14 class BrowserView;
16 namespace ash {
17 class FrameCaptionButtonContainerView;
20 namespace gfx {
21 class ImageSkia;
22 class Rect;
23 class SlideAnimation;
25 namespace views {
26 class View;
27 class Widget;
30 // Helper class for painting the browser window header.
31 class BrowserHeaderPainterAsh : public ash::HeaderPainter,
32 public gfx::AnimationDelegate {
33 public:
34 BrowserHeaderPainterAsh();
35 ~BrowserHeaderPainterAsh() override;
37 // BrowserHeaderPainterAsh does not take ownership of any of the parameters.
38 void Init(
39 views::Widget* frame,
40 BrowserView* browser_view,
41 views::View* header_view,
42 views::View* window_icon,
43 ash::FrameCaptionButtonContainerView* caption_button_container);
45 // ash::HeaderPainter overrides:
46 int GetMinimumHeaderWidth() const override;
47 void PaintHeader(gfx::Canvas* canvas, Mode mode) override;
48 void LayoutHeader() override;
49 int GetHeaderHeight() const override;
50 int GetHeaderHeightForPainting() const override;
51 void SetHeaderHeightForPainting(int height) override;
52 void SchedulePaintForTitle() override;
53 void UpdateLeftViewXInset(int left_view_x_inset) override;
55 private:
56 // gfx::AnimationDelegate override:
57 void AnimationProgressed(const gfx::Animation* animation) override;
59 // Paints highlight around the edge of the header for restored windows.
60 void PaintHighlightForRestoredWindow(gfx::Canvas* canvas);
62 // Paints the title bar, primarily the title string.
63 void PaintTitleBar(gfx::Canvas* canvas);
65 // Sets |frame_image| and |frame_overlay_image| to the frame image and the
66 // frame overlay image respectivately which should be used to paint the
67 // header.
68 void GetFrameImages(Mode mode,
69 gfx::ImageSkia* frame_image,
70 gfx::ImageSkia* frame_overlay_image) const;
72 // Sets |frame_image| and |frame_overlay_image| to the frame image and the
73 // frame overlay image respectively that should be used to paint the header
74 // for tabbed browser windows.
75 void GetFrameImagesForTabbedBrowser(
76 Mode mode,
77 gfx::ImageSkia* frame_image,
78 gfx::ImageSkia* frame_overlay_image) const;
80 // Returns the frame image which should be used to paint the header for popup
81 // browser windows and for hosted app windows which show the toolbar.
82 gfx::ImageSkia GetFrameImageForNonTabbedBrowser(Mode mode) const;
84 // Updates the images used for the minimize, restore and close buttons.
85 void UpdateCaptionButtonImages();
87 // Returns bounds of the region in |view_| which is painted with the header
88 // images. The region is assumed to start at the top left corner of |view_|
89 // and to have the same width as |view_|.
90 gfx::Rect GetPaintedBounds() const;
92 // Returns the bounds for the title.
93 gfx::Rect GetTitleBounds() const;
95 views::Widget* frame_;
97 // Whether the header is for a tabbed browser window.
98 bool is_tabbed_;
100 // Whether the header is for an incognito browser window.
101 bool is_incognito_;
103 // The header view.
104 views::View* view_;
106 views::View* window_icon_;
107 int window_icon_x_inset_;
108 ash::FrameCaptionButtonContainerView* caption_button_container_;
109 int painted_height_;
111 // Whether the header is painted for the first time.
112 bool initial_paint_;
114 // Whether the header should be painted as active.
115 Mode mode_;
117 scoped_ptr<gfx::SlideAnimation> activation_animation_;
119 DISALLOW_COPY_AND_ASSIGN(BrowserHeaderPainterAsh);
122 #endif // CHROME_BROWSER_UI_VIEWS_FRAME_BROWSER_HEADER_PAINTER_ASH_H_