Chromium Code Reviews| 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 <windows.h> | 7 #include <windows.h> |
| 8 #include <shellapi.h> | 8 #include <shellapi.h> |
| 9 | 9 |
| 10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 35 | 35 |
| 36 ICONINFO icon_info = { 0 }; | 36 ICONINFO icon_info = { 0 }; |
| 37 BITMAP bitmap_info = { 0 }; | 37 BITMAP bitmap_info = { 0 }; |
| 38 | 38 |
| 39 BOOL r = ::GetIconInfo(file_info.hIcon, &icon_info); | 39 BOOL r = ::GetIconInfo(file_info.hIcon, &icon_info); |
| 40 DCHECK(r); | 40 DCHECK(r); |
| 41 r = ::GetObject(icon_info.hbmMask, sizeof(bitmap_info), &bitmap_info); | 41 r = ::GetObject(icon_info.hbmMask, sizeof(bitmap_info), &bitmap_info); |
| 42 DCHECK(r); | 42 DCHECK(r); |
| 43 | 43 |
| 44 gfx::Size icon_size(bitmap_info.bmWidth, bitmap_info.bmHeight); | 44 gfx::Size icon_size(bitmap_info.bmWidth, bitmap_info.bmHeight); |
| 45 image_.reset(new gfx::Image( | |
| 46 IconUtil::CreateSkBitmapFromHICON(file_info.hIcon, icon_size))); | |
| 47 | 45 |
| 46 const SkBitmap* bitmap = | |
| 47 IconUtil::CreateSkBitmapFromHICON(file_info.hIcon, icon_size); | |
| 48 if (!bitmap) { | |
| 49 LOG(ERROR) << "Decoding HICON for group " << group_ << " failed"; | |
| 50 // Don't create a gfx::Image and crash. The delegate won't be notified. | |
|
Peter Kasting
2011/08/26 18:12:56
Should we instead set |image_| to a non-NULL but z
Robert Sesek
2011/08/26 19:38:28
No, we should actually notify with a NULL pointer,
| |
| 51 return; | |
| 52 } | |
| 53 | |
| 54 image_.reset(new gfx::Image(bitmap)); | |
| 48 target_message_loop_->PostTask(FROM_HERE, | 55 target_message_loop_->PostTask(FROM_HERE, |
| 49 NewRunnableMethod(this, &IconLoader::NotifyDelegate)); | 56 NewRunnableMethod(this, &IconLoader::NotifyDelegate)); |
| 50 } | 57 } |
| OLD | NEW |