BookmarkManager: Fix 'new folder text field size changes on clicking it' issue.
[chromium-blink-merge.git] / chrome / browser / ui / views / tab_icon_view.h
blobe7de72a540233a66a67ea8683e297365f41e9d91
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"
14 namespace chrome {
15 class TabIconViewModel;
18 namespace gfx {
19 class ImageSkia;
22 // A view to display a tab favicon or a throbber.
23 class TabIconView : public views::MenuButton {
24 public:
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.
32 void 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; }
37 private:
38 // views::MenuButton:
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);
46 // Our model.
47 chrome::TabIconViewModel* model_;
49 // Whether we should display our light or dark style.
50 bool is_light_;
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_