Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(201)

Side by Side Diff: chrome/browser/ui/views/tab_icon_view.h

Issue 10736063: views: Extract TabIconViewModel into its own header file. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/compiler_specific.h" 9 #include "base/compiler_specific.h"
9 #include "ui/views/view.h" 10 #include "ui/views/view.h"
10 11
11 class SkBitmap; 12 class SkBitmap;
12 13
14 namespace chrome {
15 class TabIconViewModel;
16 }
17
13 namespace gfx { 18 namespace gfx {
14 class ImageSkia; 19 class ImageSkia;
15 } 20 }
16 21
17 ////////////////////////////////////////////////////////////////////////////////
18 //
19 // A view to display a tab favicon or a throbber. 22 // A view to display a tab favicon or a throbber.
20 //
21 ////////////////////////////////////////////////////////////////////////////////
22 class TabIconView : public views::View { 23 class TabIconView : public views::View {
23 public: 24 public:
24 // Classes implement this interface to provide state for the TabIconView.
25 class TabIconViewModel {
26 public:
27 // Returns true if the TabIconView should show a loading animation.
28 virtual bool ShouldTabIconViewAnimate() const = 0;
29
30 // Returns the favicon to display in the icon view
31 virtual gfx::ImageSkia GetFaviconForTabIconView() = 0;
32 };
33
34 static void InitializeIfNeeded(); 25 static void InitializeIfNeeded();
35 26
36 explicit TabIconView(TabIconViewModel* provider); 27 explicit TabIconView(chrome::TabIconViewModel* model);
37 virtual ~TabIconView(); 28 virtual ~TabIconView();
38 29
39 // Invoke whenever the tab state changes or the throbber should update. 30 // Invoke whenever the tab state changes or the throbber should update.
40 void Update(); 31 void Update();
41 32
42 // Set the throbber to the light style (for use on dark backgrounds). 33 // Set the throbber to the light style (for use on dark backgrounds).
43 void set_is_light(bool is_light) { is_light_ = is_light; } 34 void set_is_light(bool is_light) { is_light_ = is_light; }
44 35
45 // Overridden from View 36 // Overridden from View
46 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; 37 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE;
47 virtual gfx::Size GetPreferredSize() OVERRIDE; 38 virtual gfx::Size GetPreferredSize() OVERRIDE;
48 39
49 private: 40 private:
50 void PaintThrobber(gfx::Canvas* canvas); 41 void PaintThrobber(gfx::Canvas* canvas);
51 void PaintFavicon(gfx::Canvas* canvas, const SkBitmap& bitmap); 42 void PaintFavicon(gfx::Canvas* canvas, const SkBitmap& bitmap);
52 void PaintIcon(gfx::Canvas* canvas, 43 void PaintIcon(gfx::Canvas* canvas,
53 const gfx::ImageSkia& image, 44 const gfx::ImageSkia& image,
54 int src_x, 45 int src_x,
55 int src_y, 46 int src_y,
56 int src_w, 47 int src_w,
57 int src_h, 48 int src_h,
58 bool filter); 49 bool filter);
59 50
60 // Our model. 51 // Our model.
61 TabIconViewModel* model_; 52 chrome::TabIconViewModel* model_;
62 53
63 // Whether the throbber is running. 54 // Whether the throbber is running.
64 bool throbber_running_; 55 bool throbber_running_;
65 56
66 // Whether we should display our light or dark style. 57 // Whether we should display our light or dark style.
67 bool is_light_; 58 bool is_light_;
68 59
69 // Current frame of the throbber being painted. This is only used if 60 // Current frame of the throbber being painted. This is only used if
70 // throbber_running_ is true. 61 // throbber_running_ is true.
71 int throbber_frame_; 62 int throbber_frame_;
72 63
73 DISALLOW_COPY_AND_ASSIGN(TabIconView); 64 DISALLOW_COPY_AND_ASSIGN(TabIconView);
74 }; 65 };
75 66
76 #endif // CHROME_BROWSER_UI_VIEWS_TAB_ICON_VIEW_H_ 67 #endif // CHROME_BROWSER_UI_VIEWS_TAB_ICON_VIEW_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/frame/opaque_browser_frame_view.cc ('k') | chrome/browser/ui/views/tab_icon_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698