| 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/icon_loader.h" | 5 #include "chrome/browser/icon_loader.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "content/browser/browser_thread.h" | 8 #include "content/browser/browser_thread.h" |
| 9 #include "third_party/skia/include/core/SkBitmap.h" | 9 #include "third_party/skia/include/core/SkBitmap.h" |
| 10 | 10 |
| 11 #if defined(TOOLKIT_GTK) | 11 #if defined(TOOLKIT_GTK) |
| 12 #include "base/mime_util.h" | 12 #include "base/mime_util.h" |
| 13 #endif | 13 #endif |
| 14 | 14 |
| 15 IconLoader::IconLoader(const IconGroupID& group, IconSize size, | 15 IconLoader::IconLoader(const IconGroupID& group, IconSize size, |
| 16 Delegate* delegate) | 16 Delegate* delegate) |
| 17 : target_message_loop_(NULL), | 17 : target_message_loop_(NULL), |
| 18 group_(group), | 18 group_(group), |
| 19 icon_size_(size), | 19 icon_size_(size), |
| 20 image_(NULL), | 20 image_(NULL), |
| 21 delegate_(delegate) { | 21 delegate_(delegate) { |
| 22 } | 22 } |
| 23 | 23 |
| 24 IconLoader::~IconLoader() { | 24 IconLoader::~IconLoader() { |
| 25 } | 25 } |
| 26 | 26 |
| 27 void IconLoader::Start() { | 27 void IconLoader::Start() { |
| 28 target_message_loop_ = base::MessageLoopProxy::CreateForCurrentThread(); | 28 target_message_loop_ = base::MessageLoopProxy::current(); |
| 29 | 29 |
| 30 #if defined(TOOLKIT_GTK) | 30 #if defined(TOOLKIT_GTK) |
| 31 // This call must happen on the UI thread before we can start loading icons. | 31 // This call must happen on the UI thread before we can start loading icons. |
| 32 mime_util::DetectGtkTheme(); | 32 mime_util::DetectGtkTheme(); |
| 33 #endif | 33 #endif |
| 34 | 34 |
| 35 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, | 35 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, |
| 36 NewRunnableMethod(this, &IconLoader::ReadIcon)); | 36 NewRunnableMethod(this, &IconLoader::ReadIcon)); |
| 37 } | 37 } |
| 38 | 38 |
| 39 void IconLoader::NotifyDelegate() { | 39 void IconLoader::NotifyDelegate() { |
| 40 // If the delegate takes ownership of the Image, release it from the scoped | 40 // If the delegate takes ownership of the Image, release it from the scoped |
| 41 // pointer. | 41 // pointer. |
| 42 if (delegate_->OnImageLoaded(this, image_.get())) | 42 if (delegate_->OnImageLoaded(this, image_.get())) |
| 43 ignore_result(image_.release()); // Can't ignore return value. | 43 ignore_result(image_.release()); // Can't ignore return value. |
| 44 } | 44 } |
| OLD | NEW |