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

Side by Side Diff: chrome/browser/ui/cocoa/tab_contents/favicon_util.mm

Issue 6906001: Protect against image conversion failure in mac::FaviconForTabContents(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Comment nit Created 9 years, 8 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/ui/cocoa/tab_contents/favicon_util.h" 5 #include "chrome/browser/ui/cocoa/tab_contents/favicon_util.h"
6 6
7 #import <AppKit/AppKit.h> 7 #import <AppKit/AppKit.h>
8 8
9 #include "app/mac/nsimage_cache.h" 9 #include "app/mac/nsimage_cache.h"
10 #include "base/mac/mac_util.h" 10 #include "base/mac/mac_util.h"
11 #include "content/browser/tab_contents/tab_contents.h" 11 #include "content/browser/tab_contents/tab_contents.h"
12 #include "skia/ext/skia_utils_mac.h" 12 #include "skia/ext/skia_utils_mac.h"
13 13
14 namespace mac { 14 namespace mac {
15 15
16 NSImage* FaviconForTabContents(TabContents* contents) { 16 NSImage* FaviconForTabContents(TabContents* contents) {
17 // TabContents returns IDR_DEFAULT_FAVICON, which is a rasterized version of 17 // TabContents returns IDR_DEFAULT_FAVICON, which is a rasterized version of
18 // the Mac PDF. Use the PDF so the icon in the Omnibox matches the default 18 // the Mac PDF. Use the PDF so the icon in the Omnibox matches the default
19 // favicon. 19 // favicon.
20 if (contents && contents->FaviconIsValid()) { 20 if (contents && contents->FaviconIsValid()) {
21 CGColorSpaceRef color_space = base::mac::GetSystemColorSpace(); 21 CGColorSpaceRef color_space = base::mac::GetSystemColorSpace();
22 return gfx::SkBitmapToNSImageWithColorSpace(contents->GetFavicon(), 22 NSImage* image =
23 color_space); 23 gfx::SkBitmapToNSImageWithColorSpace(contents->GetFavicon(),
24 color_space);
25 // The |image| could be nil if the bitmap is null. In that case, fallback
26 // to the default image.
27 if (image) {
28 return image;
29 }
24 } 30 }
25 31
26 return app::mac::GetCachedImageWithName(@"nav.pdf"); 32 return app::mac::GetCachedImageWithName(@"nav.pdf");
27 } 33 }
28 34
29 } // namespace mac 35 } // namespace mac
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