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

Side by Side Diff: chrome/browser/views/tab_icon_view.cc

Issue 115905: Gets TabIconView compiling on linux. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 6 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
« no previous file with comments | « no previous file | chrome/chrome.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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/views/tab_icon_view.h" 5 #include "chrome/browser/views/tab_icon_view.h"
6 6
7 #if defined(OS_WIN)
7 #include <windows.h> 8 #include <windows.h>
8 #include <shellapi.h> 9 #include <shellapi.h>
10 #endif
9 11
10 #include "app/gfx/canvas.h" 12 #include "app/gfx/canvas.h"
11 #include "app/gfx/favicon_size.h" 13 #include "app/gfx/favicon_size.h"
12 #include "app/gfx/icon_util.h"
13 #include "app/resource_bundle.h" 14 #include "app/resource_bundle.h"
14 #include "base/file_util.h" 15 #include "base/file_util.h"
16 #include "base/logging.h"
15 #include "base/path_service.h" 17 #include "base/path_service.h"
16 #include "chrome/app/chrome_dll_resource.h" 18 #include "chrome/app/chrome_dll_resource.h"
17 #include "chrome/browser/tab_contents/tab_contents.h" 19 #include "chrome/browser/tab_contents/tab_contents.h"
18 #include "grit/app_resources.h" 20 #include "grit/app_resources.h"
19 #include "grit/theme_resources.h" 21 #include "grit/theme_resources.h"
20 22
23 #if defined(OS_WIN)
24 #include "app/gfx/icon_util.h"
25 #endif
26
21 static bool g_initialized = false; 27 static bool g_initialized = false;
22 static SkBitmap* g_default_fav_icon = NULL; 28 static SkBitmap* g_default_fav_icon = NULL;
23 static SkBitmap* g_throbber_frames = NULL; 29 static SkBitmap* g_throbber_frames = NULL;
24 static SkBitmap* g_throbber_frames_light = NULL; 30 static SkBitmap* g_throbber_frames_light = NULL;
25 static int g_throbber_frame_count; 31 static int g_throbber_frame_count;
26 32
27 // static 33 // static
28 void TabIconView::InitializeIfNeeded() { 34 void TabIconView::InitializeIfNeeded() {
29 if (!g_initialized) { 35 if (!g_initialized) {
30 ResourceBundle &rb = ResourceBundle::GetSharedInstance(); 36 ResourceBundle &rb = ResourceBundle::GetSharedInstance();
31 37
38 #if defined(OS_WIN)
32 // The default window icon is the application icon, not the default 39 // The default window icon is the application icon, not the default
33 // favicon. 40 // favicon.
34 std::wstring exe_path; 41 std::wstring exe_path;
35 PathService::Get(base::DIR_EXE, &exe_path); 42 PathService::Get(base::DIR_EXE, &exe_path);
36 file_util::AppendToPath(&exe_path, L"chrome.exe"); 43 file_util::AppendToPath(&exe_path, L"chrome.exe");
37 HICON app_icon = ExtractIcon(NULL, exe_path.c_str(), 0); 44 HICON app_icon = ExtractIcon(NULL, exe_path.c_str(), 0);
38 g_default_fav_icon = 45 g_default_fav_icon =
39 IconUtil::CreateSkBitmapFromHICON(app_icon, gfx::Size(16, 16)); 46 IconUtil::CreateSkBitmapFromHICON(app_icon, gfx::Size(16, 16));
40 DestroyIcon(app_icon); 47 DestroyIcon(app_icon);
48 #else
49 NOTIMPLEMENTED();
50 #endif
41 51
42 g_throbber_frames = rb.GetBitmapNamed(IDR_THROBBER); 52 g_throbber_frames = rb.GetBitmapNamed(IDR_THROBBER);
43 g_throbber_frames_light = rb.GetBitmapNamed(IDR_THROBBER_LIGHT); 53 g_throbber_frames_light = rb.GetBitmapNamed(IDR_THROBBER_LIGHT);
44 g_throbber_frame_count = g_throbber_frames->width() / 54 g_throbber_frame_count = g_throbber_frames->width() /
45 g_throbber_frames->height(); 55 g_throbber_frames->height();
46 56
47 // Verify that our light and dark styles have the same number of frames. 57 // Verify that our light and dark styles have the same number of frames.
48 DCHECK(g_throbber_frame_count == 58 DCHECK(g_throbber_frame_count ==
49 g_throbber_frames_light->width() / g_throbber_frames_light->height()); 59 g_throbber_frames_light->width() / g_throbber_frames_light->height());
50 g_initialized = true; 60 g_initialized = true;
51 } 61 }
52 } 62 }
53 63
54 TabIconView::TabIconView(TabIconViewModel* model) 64 TabIconView::TabIconView(TabIconViewModel* model)
55 : model_(model), 65 : model_(model),
66 throbber_running_(false),
56 is_light_(false), 67 is_light_(false),
57 throbber_running_(false),
58 throbber_frame_(0) { 68 throbber_frame_(0) {
59 InitializeIfNeeded(); 69 InitializeIfNeeded();
60 } 70 }
61 71
62 TabIconView::~TabIconView() { 72 TabIconView::~TabIconView() {
63 } 73 }
64 74
65 void TabIconView::Update() { 75 void TabIconView::Update() {
66 if (throbber_running_) { 76 if (throbber_running_) {
67 // We think the tab is loading. 77 // We think the tab is loading.
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 } 150 }
141 } 151 }
142 152
143 if (!rendered) 153 if (!rendered)
144 PaintFavIcon(canvas, *g_default_fav_icon); 154 PaintFavIcon(canvas, *g_default_fav_icon);
145 } 155 }
146 156
147 gfx::Size TabIconView::GetPreferredSize() { 157 gfx::Size TabIconView::GetPreferredSize() {
148 return gfx::Size(kFavIconSize, kFavIconSize); 158 return gfx::Size(kFavIconSize, kFavIconSize);
149 } 159 }
OLDNEW
« no previous file with comments | « no previous file | chrome/chrome.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698