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/ui/cocoa/tab_contents/favicon_util_mac.h" | 5 #include "chrome/browser/ui/cocoa/tab_contents/favicon_util_mac.h" |
6 | 6 |
7 #include "chrome/browser/favicon/favicon_tab_helper.h" | 7 #include "chrome/browser/favicon/favicon_tab_helper.h" |
8 #include "chrome/browser/ui/tab_contents/tab_contents.h" | 8 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
9 #include "grit/ui_resources.h" | 9 #include "grit/ui_resources.h" |
10 #include "ui/base/resource/resource_bundle.h" | 10 #include "ui/base/resource/resource_bundle.h" |
11 | 11 |
12 namespace mac { | 12 namespace mac { |
13 | 13 |
14 NSImage* FaviconForTabContents(TabContents* contents) { | 14 NSImage* FaviconForTabContents(TabContents* contents) { |
15 if (contents && contents->favicon_tab_helper()->FaviconIsValid()) { | 15 if (contents && contents->favicon_tab_helper()->FaviconIsValid()) { |
16 NSImage* image = contents->favicon_tab_helper()->GetFavicon().AsNSImage(); | 16 const gfx::Image& icon = contents->favicon_tab_helper()->GetFavicon(); |
17 // The |image| could be nil if the bitmap is null. In that case, fallback | 17 if (!icon.IsEmpty()) |
18 // to the default image. | 18 return icon.ToNSImage();; |
19 if (image) { | |
20 return image; | |
21 } | |
22 } | 19 } |
23 | 20 |
| 21 // Fall back to the default image. |
24 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 22 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
25 return rb.GetNativeImageNamed(IDR_DEFAULT_FAVICON); | 23 return rb.GetNativeImageNamed(IDR_DEFAULT_FAVICON); |
26 } | 24 } |
27 | 25 |
28 } // namespace mac | 26 } // namespace mac |
OLD | NEW |