| 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/icon_loader.h" | 5 #include "chrome/browser/icon_loader.h" |
| 6 | 6 |
| 7 #include <windows.h> | 7 #include <windows.h> |
| 8 #include <shellapi.h> | 8 #include <shellapi.h> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 break; | 23 break; |
| 24 case IconLoader::NORMAL: | 24 case IconLoader::NORMAL: |
| 25 size = 0; | 25 size = 0; |
| 26 break; | 26 break; |
| 27 case IconLoader::LARGE: | 27 case IconLoader::LARGE: |
| 28 size = SHGFI_LARGEICON; | 28 size = SHGFI_LARGEICON; |
| 29 break; | 29 break; |
| 30 default: | 30 default: |
| 31 NOTREACHED(); | 31 NOTREACHED(); |
| 32 } | 32 } |
| 33 |
| 34 image_.reset(); |
| 35 |
| 33 SHFILEINFO file_info = { 0 }; | 36 SHFILEINFO file_info = { 0 }; |
| 34 if (!SHGetFileInfo(group_.c_str(), FILE_ATTRIBUTE_NORMAL, &file_info, | 37 if (SHGetFileInfo(group_.c_str(), FILE_ATTRIBUTE_NORMAL, &file_info, |
| 35 sizeof(SHFILEINFO), | 38 sizeof(SHFILEINFO), |
| 36 SHGFI_ICON | size | SHGFI_USEFILEATTRIBUTES)) | 39 SHGFI_ICON | size | SHGFI_USEFILEATTRIBUTES)) { |
| 37 return; | 40 scoped_ptr<SkBitmap> bitmap(IconUtil::CreateSkBitmapFromHICON( |
| 41 file_info.hIcon)); |
| 42 if (bitmap.get()) { |
| 43 gfx::ImageSkia image_skia(*bitmap); |
| 44 image_skia.MakeThreadSafe(); |
| 45 image_.reset(new gfx::Image(image_skia)); |
| 46 DestroyIcon(file_info.hIcon); |
| 47 } |
| 48 } |
| 38 | 49 |
| 39 scoped_ptr<SkBitmap> bitmap(IconUtil::CreateSkBitmapFromHICON( | 50 // Always notify the delegate, regardless of success. |
| 40 file_info.hIcon)); | |
| 41 gfx::ImageSkia image_skia(*bitmap); | |
| 42 image_skia.MakeThreadSafe(); | |
| 43 image_.reset(new gfx::Image(image_skia)); | |
| 44 DestroyIcon(file_info.hIcon); | |
| 45 target_message_loop_->PostTask(FROM_HERE, | 51 target_message_loop_->PostTask(FROM_HERE, |
| 46 base::Bind(&IconLoader::NotifyDelegate, this)); | 52 base::Bind(&IconLoader::NotifyDelegate, this)); |
| 47 } | 53 } |
| OLD | NEW |