summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorthakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-08-06 15:16:50 +0000
committerthakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-08-06 15:16:50 +0000
commit81e513a94e5ab4e1108aae7b06f754115f219051 (patch)
tree4922c62b409bef63412e74c01969a99fb1706cd6
parent7cd52e4b63b62ca556f8e8d8e9ed5e5051c9becc (diff)
downloadchromium_src-81e513a94e5ab4e1108aae7b06f754115f219051.zip
chromium_src-81e513a94e5ab4e1108aae7b06f754115f219051.tar.gz
chromium_src-81e513a94e5ab4e1108aae7b06f754115f219051.tar.bz2
Fall back to the default favicon on invalid favicon files.
I regressed this in r149891. BUG=140689 Review URL: https://chromiumcodereview.appspot.com/10853018 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@150092 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/ui/cocoa/tab_contents/favicon_util_mac.mm2
-rw-r--r--ui/gfx/image/image.cc8
-rw-r--r--ui/gfx/image/image.h9
3 files changed, 15 insertions, 4 deletions
diff --git a/chrome/browser/ui/cocoa/tab_contents/favicon_util_mac.mm b/chrome/browser/ui/cocoa/tab_contents/favicon_util_mac.mm
index 8ab22c2..9cc016e 100644
--- a/chrome/browser/ui/cocoa/tab_contents/favicon_util_mac.mm
+++ b/chrome/browser/ui/cocoa/tab_contents/favicon_util_mac.mm
@@ -13,7 +13,7 @@ namespace mac {
NSImage* FaviconForTabContents(TabContents* contents) {
if (contents && contents->favicon_tab_helper()->FaviconIsValid()) {
- NSImage* image = contents->favicon_tab_helper()->GetFavicon().ToNSImage();
+ NSImage* image = contents->favicon_tab_helper()->GetFavicon().AsNSImage();
// The |image| could be nil if the bitmap is null. In that case, fallback
// to the default image.
if (image) {
diff --git a/ui/gfx/image/image.cc b/ui/gfx/image/image.cc
index 9854787..9c709dc 100644
--- a/ui/gfx/image/image.cc
+++ b/ui/gfx/image/image.cc
@@ -342,9 +342,15 @@ SkBitmap Image::AsBitmap() const {
}
ImageSkia Image::AsImageSkia() const {
- return IsEmpty() ? ImageSkia(SkBitmap()) : *ToImageSkia();
+ return IsEmpty() ? ImageSkia() : *ToImageSkia();
}
+#if defined(OS_MACOSX)
+NSImage* Image::AsNSImage() const {
+ return IsEmpty() ? nil : ToNSImage();
+}
+#endif
+
ImageSkia* Image::CopyImageSkia() const {
return new ImageSkia(*ToImageSkia());
}
diff --git a/ui/gfx/image/image.h b/ui/gfx/image/image.h
index 04a79da..b643362 100644
--- a/ui/gfx/image/image.h
+++ b/ui/gfx/image/image.h
@@ -97,7 +97,7 @@ class UI_EXPORT Image {
// Converts the Image to the desired representation and stores it internally.
// The returned result is a weak pointer owned by and scoped to the life of
- // the Image.
+ // the Image. Must only be called if IsEmpty() is false.
const SkBitmap* ToSkBitmap() const;
const ImageSkia* ToImageSkia() const;
#if defined(TOOLKIT_GTK)
@@ -110,10 +110,15 @@ class UI_EXPORT Image {
// Same as ToSkBitmap(), but returns a null SkBitmap if this image is empty.
SkBitmap AsBitmap() const;
- // Same as ToSkBitmap(), but returns a ImageSkia with a null SkBitmap if this
+ // Same as ToImageSkia(), but returns an empty ImageSkia if this
// image is empty.
ImageSkia AsImageSkia() const;
+#if defined(OS_MACOSX)
+ // Same as ToSkBitmap(), but returns nil if this image is empty.
+ NSImage* AsNSImage() const;
+#endif
+
// Performs a conversion, like above, but returns a copy of the result rather
// than a weak pointer. The caller is responsible for deleting the result.
// Note that the result is only a copy in terms of memory management; the