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

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: Long-time rebase Created 8 years, 3 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) 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
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 }
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