OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/icon_loader.h" | 5 #include "chrome/browser/icon_loader.h" |
6 | 6 |
7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
8 #include "base/mime_util.h" | |
9 #include "base/thread.h" | 8 #include "base/thread.h" |
10 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
11 #include "third_party/skia/include/core/SkBitmap.h" | 10 #include "third_party/skia/include/core/SkBitmap.h" |
12 | 11 |
| 12 #if defined(TOOLKIT_GTK) |
| 13 #include "base/mime_util.h" |
| 14 #endif |
| 15 |
13 IconLoader::IconLoader(const IconGroupID& group, IconSize size, | 16 IconLoader::IconLoader(const IconGroupID& group, IconSize size, |
14 Delegate* delegate) | 17 Delegate* delegate) |
15 : target_message_loop_(NULL), | 18 : target_message_loop_(NULL), |
16 group_(group), | 19 group_(group), |
17 icon_size_(size), | 20 icon_size_(size), |
18 bitmap_(NULL), | 21 bitmap_(NULL), |
19 delegate_(delegate) { | 22 delegate_(delegate) { |
20 } | 23 } |
21 | 24 |
22 IconLoader::~IconLoader() { | 25 IconLoader::~IconLoader() { |
23 delete bitmap_; | 26 delete bitmap_; |
24 } | 27 } |
25 | 28 |
26 void IconLoader::Start() { | 29 void IconLoader::Start() { |
27 target_message_loop_ = MessageLoop::current(); | 30 target_message_loop_ = MessageLoop::current(); |
28 | 31 |
29 #if defined(TOOLKIT_GTK) | 32 #if defined(TOOLKIT_GTK) |
30 // This call must happen on the UI thread before we can start loading icons. | 33 // This call must happen on the UI thread before we can start loading icons. |
31 mime_util::DetectGtkTheme(); | 34 mime_util::DetectGtkTheme(); |
32 #endif | 35 #endif |
33 | 36 |
34 g_browser_process->file_thread()->message_loop()->PostTask(FROM_HERE, | 37 g_browser_process->file_thread()->message_loop()->PostTask(FROM_HERE, |
35 NewRunnableMethod(this, &IconLoader::ReadIcon)); | 38 NewRunnableMethod(this, &IconLoader::ReadIcon)); |
36 } | 39 } |
37 | 40 |
38 void IconLoader::NotifyDelegate() { | 41 void IconLoader::NotifyDelegate() { |
39 if (delegate_->OnBitmapLoaded(this, bitmap_)) | 42 if (delegate_->OnBitmapLoaded(this, bitmap_)) |
40 bitmap_ = NULL; | 43 bitmap_ = NULL; |
41 } | 44 } |
OLD | NEW |