OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_UI_VIEWS_TAB_ICON_VIEW_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_TAB_ICON_VIEW_H_ |
6 #define CHROME_BROWSER_UI_VIEWS_TAB_ICON_VIEW_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_TAB_ICON_VIEW_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "ui/views/view.h" | 10 #include "ui/views/view.h" |
11 | 11 |
12 class SkBitmap; | |
13 | |
14 namespace chrome { | 12 namespace chrome { |
15 class TabIconViewModel; | 13 class TabIconViewModel; |
16 } | 14 } |
17 | 15 |
18 namespace gfx { | 16 namespace gfx { |
19 class ImageSkia; | 17 class ImageSkia; |
20 } | 18 } |
21 | 19 |
22 // A view to display a tab favicon or a throbber. | 20 // A view to display a tab favicon or a throbber. |
23 class TabIconView : public views::View { | 21 class TabIconView : public views::View { |
24 public: | 22 public: |
25 static void InitializeIfNeeded(); | 23 static void InitializeIfNeeded(); |
26 | 24 |
27 explicit TabIconView(chrome::TabIconViewModel* model); | 25 explicit TabIconView(chrome::TabIconViewModel* model); |
28 virtual ~TabIconView(); | 26 virtual ~TabIconView(); |
29 | 27 |
30 // Invoke whenever the tab state changes or the throbber should update. | 28 // Invoke whenever the tab state changes or the throbber should update. |
31 void Update(); | 29 void Update(); |
32 | 30 |
33 // Set the throbber to the light style (for use on dark backgrounds). | 31 // Set the throbber to the light style (for use on dark backgrounds). |
34 void set_is_light(bool is_light) { is_light_ = is_light; } | 32 void set_is_light(bool is_light) { is_light_ = is_light; } |
35 | 33 |
36 // Overridden from View | 34 // Overridden from View |
37 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; | 35 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; |
38 virtual gfx::Size GetPreferredSize() OVERRIDE; | 36 virtual gfx::Size GetPreferredSize() OVERRIDE; |
39 | 37 |
40 private: | 38 private: |
41 void PaintThrobber(gfx::Canvas* canvas); | 39 void PaintThrobber(gfx::Canvas* canvas); |
42 void PaintFavicon(gfx::Canvas* canvas, const SkBitmap& bitmap); | 40 void PaintFavicon(gfx::Canvas* canvas, const gfx::ImageSkia& image); |
43 void PaintIcon(gfx::Canvas* canvas, | 41 void PaintIcon(gfx::Canvas* canvas, |
44 const gfx::ImageSkia& image, | 42 const gfx::ImageSkia& image, |
45 int src_x, | 43 int src_x, |
46 int src_y, | 44 int src_y, |
47 int src_w, | 45 int src_w, |
48 int src_h, | 46 int src_h, |
49 bool filter); | 47 bool filter); |
50 | 48 |
51 // Our model. | 49 // Our model. |
52 chrome::TabIconViewModel* model_; | 50 chrome::TabIconViewModel* model_; |
53 | 51 |
54 // Whether the throbber is running. | 52 // Whether the throbber is running. |
55 bool throbber_running_; | 53 bool throbber_running_; |
56 | 54 |
57 // Whether we should display our light or dark style. | 55 // Whether we should display our light or dark style. |
58 bool is_light_; | 56 bool is_light_; |
59 | 57 |
60 // Current frame of the throbber being painted. This is only used if | 58 // Current frame of the throbber being painted. This is only used if |
61 // throbber_running_ is true. | 59 // throbber_running_ is true. |
62 int throbber_frame_; | 60 int throbber_frame_; |
63 | 61 |
64 DISALLOW_COPY_AND_ASSIGN(TabIconView); | 62 DISALLOW_COPY_AND_ASSIGN(TabIconView); |
65 }; | 63 }; |
66 | 64 |
67 #endif // CHROME_BROWSER_UI_VIEWS_TAB_ICON_VIEW_H_ | 65 #endif // CHROME_BROWSER_UI_VIEWS_TAB_ICON_VIEW_H_ |
OLD | NEW |