Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(286)

Side by Side Diff: chrome/browser/icon_loader_win.cc

Issue 7753009: In icon_loader_win.cc, if CreateSkBitmapFromHICON fails, don't pass NULL to gfx::Image and crash. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: '' Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 13 matching lines...) Expand all
24 case IconLoader::LARGE: 24 case IconLoader::LARGE:
25 size = SHGFI_LARGEICON; 25 size = SHGFI_LARGEICON;
26 break; 26 break;
27 default: 27 default:
28 NOTREACHED(); 28 NOTREACHED();
29 } 29 }
30 SHFILEINFO file_info = { 0 }; 30 SHFILEINFO file_info = { 0 };
31 if (!SHGetFileInfo(group_.c_str(), FILE_ATTRIBUTE_NORMAL, &file_info, 31 if (!SHGetFileInfo(group_.c_str(), FILE_ATTRIBUTE_NORMAL, &file_info,
32 sizeof(SHFILEINFO), 32 sizeof(SHFILEINFO),
33 SHGFI_ICON | size | SHGFI_USEFILEATTRIBUTES)) 33 SHGFI_ICON | size | SHGFI_USEFILEATTRIBUTES))
34 return; 34 return;
Peter Kasting 2011/08/26 19:52:56 Should this also reset |image_| and notify?
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);
Peter Kasting 2011/08/26 19:52:56 I think we should also look at, rather than DCHECK
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( 45
46 IconUtil::CreateSkBitmapFromHICON(file_info.hIcon, icon_size))); 46 const SkBitmap* bitmap =
47 IconUtil::CreateSkBitmapFromHICON(file_info.hIcon, icon_size);
48 if (bitmap) {
49 image_.reset(new gfx::Image(bitmap));
50 } else {
51 LOG(ERROR) << "Decoding HICON for group " << group_ << " failed";
Peter Kasting 2011/08/26 19:52:56 Nit: TBH, I'm not sure how much use this error log
52 image_.reset();
53 }
47 54
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 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698