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