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.
5 #ifndef CHROME_BROWSER_UI_VIEWS_TAB_ICON_VIEW_H_
6 #define CHROME_BROWSER_UI_VIEWS_TAB_ICON_VIEW_H_
8 #include "base/basictypes.h"
9 #include "base/compiler_specific.h"
10 #include "base/time/time.h"
11 #include "ui/views/controls/button/menu_button.h"
12 #include "ui/views/view.h"
15 class TabIconViewModel
;
22 // A view to display a tab favicon or a throbber.
23 class TabIconView
: public views::MenuButton
{
25 static void InitializeIfNeeded();
27 TabIconView(chrome::TabIconViewModel
* model
,
28 views::MenuButtonListener
* menu_button_listener
);
29 ~TabIconView() override
;
31 // Invoke whenever the tab state changes or the throbber should update.
34 // Set the throbber to the light style (for use on dark backgrounds).
35 void set_is_light(bool is_light
) { is_light_
= is_light
; }
39 gfx::Size
GetPreferredSize() const override
;
40 const char* GetClassName() const override
;
41 void OnPaint(gfx::Canvas
* canvas
) override
;
43 void PaintThrobber(gfx::Canvas
* canvas
);
44 void PaintFavicon(gfx::Canvas
* canvas
, const gfx::ImageSkia
& image
);
47 chrome::TabIconViewModel
* model_
;
49 // Whether we should display our light or dark style.
52 // Time we painted the first frame of the current throbber animation, or
53 // 0 if not painting the throbber.
54 base::TimeTicks throbber_start_time_
;
56 DISALLOW_COPY_AND_ASSIGN(TabIconView
);
59 #endif // CHROME_BROWSER_UI_VIEWS_TAB_ICON_VIEW_H_