OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #include "chrome/browser/ui/views/tab_icon_view.h" | 5 #include "chrome/browser/ui/views/tab_icon_view.h" |
6 | 6 |
7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
8 #include <windows.h> | 8 #include <windows.h> |
9 #include <shellapi.h> | 9 #include <shellapi.h> |
10 #endif | 10 #endif |
11 | 11 |
12 #include "base/file_util.h" | 12 #include "base/file_util.h" |
13 #include "base/logging.h" | 13 #include "base/logging.h" |
14 #include "chrome/app/chrome_command_ids.h" | 14 #include "chrome/app/chrome_command_ids.h" |
15 #include "grit/app_resources.h" | 15 #include "grit/app_resources.h" |
16 #include "grit/theme_resources.h" | 16 #include "grit/theme_resources.h" |
17 #include "ui/base/resource/resource_bundle.h" | 17 #include "ui/base/resource/resource_bundle.h" |
18 #include "ui/base/theme_provider.h" | 18 #include "ui/base/theme_provider.h" |
19 #include "ui/gfx/canvas.h" | 19 #include "ui/gfx/canvas.h" |
20 #include "ui/gfx/favicon_size.h" | 20 #include "ui/gfx/favicon_size.h" |
21 | 21 |
22 #if defined(OS_WIN) | 22 #if defined(OS_WIN) |
23 #include "chrome/browser/app_icon_win.h" | 23 #include "chrome/browser/app_icon_win.h" |
24 #include "ui/gfx/icon_util.h" | 24 #include "ui/gfx/icon_util.h" |
25 #endif | 25 #endif |
26 | 26 |
27 static bool g_initialized = false; | 27 static bool g_initialized = false; |
28 static SkBitmap* g_default_fav_icon = NULL; | 28 static SkBitmap* g_default_favicon = NULL; |
29 | 29 |
30 // static | 30 // static |
31 void TabIconView::InitializeIfNeeded() { | 31 void TabIconView::InitializeIfNeeded() { |
32 if (!g_initialized) { | 32 if (!g_initialized) { |
33 g_initialized = true; | 33 g_initialized = true; |
34 | 34 |
35 #if defined(OS_WIN) | 35 #if defined(OS_WIN) |
36 // The default window icon is the application icon, not the default | 36 // The default window icon is the application icon, not the default |
37 // favicon. | 37 // favicon. |
38 HICON app_icon = GetAppIcon(); | 38 HICON app_icon = GetAppIcon(); |
39 g_default_fav_icon = | 39 g_default_favicon = |
40 IconUtil::CreateSkBitmapFromHICON(app_icon, gfx::Size(16, 16)); | 40 IconUtil::CreateSkBitmapFromHICON(app_icon, gfx::Size(16, 16)); |
41 DestroyIcon(app_icon); | 41 DestroyIcon(app_icon); |
42 #else | 42 #else |
43 g_default_fav_icon = | 43 g_default_favicon = |
44 ResourceBundle::GetSharedInstance().GetBitmapNamed(IDR_PRODUCT_LOGO_16); | 44 ResourceBundle::GetSharedInstance().GetBitmapNamed(IDR_PRODUCT_LOGO_16); |
45 #endif | 45 #endif |
46 } | 46 } |
47 } | 47 } |
48 | 48 |
49 TabIconView::TabIconView(TabIconViewModel* model) | 49 TabIconView::TabIconView(TabIconViewModel* model) |
50 : model_(model), | 50 : model_(model), |
51 throbber_running_(false), | 51 throbber_running_(false), |
52 is_light_(false), | 52 is_light_(false), |
53 throbber_frame_(0) { | 53 throbber_frame_(0) { |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 PaintThrobber(canvas); | 140 PaintThrobber(canvas); |
141 } else { | 141 } else { |
142 SkBitmap favicon = model_->GetFavIconForTabIconView(); | 142 SkBitmap favicon = model_->GetFavIconForTabIconView(); |
143 if (!favicon.isNull()) { | 143 if (!favicon.isNull()) { |
144 rendered = true; | 144 rendered = true; |
145 PaintFavIcon(canvas, favicon); | 145 PaintFavIcon(canvas, favicon); |
146 } | 146 } |
147 } | 147 } |
148 | 148 |
149 if (!rendered) | 149 if (!rendered) |
150 PaintFavIcon(canvas, *g_default_fav_icon); | 150 PaintFavIcon(canvas, *g_default_favicon); |
151 } | 151 } |
152 | 152 |
153 gfx::Size TabIconView::GetPreferredSize() { | 153 gfx::Size TabIconView::GetPreferredSize() { |
154 return gfx::Size(kFaviconSize, kFaviconSize); | 154 return gfx::Size(kFaviconSize, kFaviconSize); |
155 } | 155 } |
OLD | NEW |