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 #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/logging.h" | 12 #include "base/logging.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "chrome/app/chrome_command_ids.h" | 14 #include "chrome/app/chrome_command_ids.h" |
15 #include "chrome/browser/ui/views/tab_icon_view_model.h" | 15 #include "chrome/browser/ui/views/tab_icon_view_model.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 #include "ui/resources/grit/ui_resources.h" | 21 #include "ui/resources/grit/ui_resources.h" |
22 | 22 |
23 #if defined(OS_WIN) | 23 #if defined(OS_WIN) |
24 #include "chrome/browser/app_icon_win.h" | 24 #include "chrome/browser/app_icon_win.h" |
25 #include "ui/gfx/icon_util.h" | 25 #include "ui/gfx/icon_util.h" |
26 #endif | 26 #endif |
27 | 27 |
28 static bool g_initialized = false; | 28 namespace { |
29 static gfx::ImageSkia* g_default_favicon = NULL; | 29 |
| 30 bool g_initialized = false; |
| 31 gfx::ImageSkia* g_default_favicon = nullptr; |
| 32 |
| 33 } // namespace |
30 | 34 |
31 // static | 35 // static |
32 void TabIconView::InitializeIfNeeded() { | 36 void TabIconView::InitializeIfNeeded() { |
33 if (!g_initialized) { | 37 if (!g_initialized) { |
34 g_initialized = true; | 38 g_initialized = true; |
35 | 39 |
36 #if defined(OS_WIN) | 40 #if defined(OS_WIN) |
37 // The default window icon is the application icon, not the default | 41 // The default window icon is the application icon, not the default |
38 // favicon. | 42 // favicon. |
39 HICON app_icon = GetAppIcon(); | 43 HICON app_icon = GetAppIcon(); |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 if (!favicon.isNull()) { | 152 if (!favicon.isNull()) { |
149 rendered = true; | 153 rendered = true; |
150 PaintFavicon(canvas, favicon); | 154 PaintFavicon(canvas, favicon); |
151 } | 155 } |
152 } | 156 } |
153 | 157 |
154 if (!rendered) | 158 if (!rendered) |
155 PaintFavicon(canvas, *g_default_favicon); | 159 PaintFavicon(canvas, *g_default_favicon); |
156 } | 160 } |
157 | 161 |
| 162 const char* TabIconView::GetClassName() const { |
| 163 return "TabIconView"; |
| 164 } |
| 165 |
158 gfx::Size TabIconView::GetPreferredSize() const { | 166 gfx::Size TabIconView::GetPreferredSize() const { |
159 return gfx::Size(gfx::kFaviconSize, gfx::kFaviconSize); | 167 return gfx::Size(gfx::kFaviconSize, gfx::kFaviconSize); |
160 } | 168 } |
OLD | NEW |