Chromium Code Reviews| Index: chrome/browser/win/jumplist.cc |
| diff --git a/chrome/browser/win/jumplist.cc b/chrome/browser/win/jumplist.cc |
| index 508093dfa290fa460552fa29d95bdf17c8b071eb..e27959d505f4776a59cb5e7e9daa3ee722ea9365 100644 |
| --- a/chrome/browser/win/jumplist.cc |
| +++ b/chrome/browser/win/jumplist.cc |
| @@ -44,7 +44,10 @@ |
| #include "ui/gfx/codec/png_codec.h" |
| #include "ui/gfx/favicon_size.h" |
| #include "ui/gfx/icon_util.h" |
| +#include "ui/gfx/image/image.h" |
| #include "ui/gfx/image/image_family.h" |
| +#include "ui/gfx/image/image_skia.h" |
| +#include "ui/gfx/image/image_skia_rep.h" |
| #include "url/gurl.h" |
| using content::BrowserThread; |
| @@ -73,7 +76,7 @@ scoped_refptr<ShellLinkItem> CreateShellLink() { |
| } |
| // Creates a temporary icon file to be shown in JumpList. |
| -bool CreateIconFile(const SkBitmap& bitmap, |
| +bool CreateIconFile(const gfx::Image& image, |
| const base::FilePath& icon_dir, |
| base::FilePath* icon_path) { |
| // Retrieve the path to a temporary file. |
| @@ -86,7 +89,18 @@ bool CreateIconFile(const SkBitmap& bitmap, |
| // Create an icon file from the favicon attached to the given |page|, and |
| // save it as the temporary file. |
| gfx::ImageFamily image_family; |
| - image_family.Add(gfx::Image::CreateFrom1xBitmap(bitmap)); |
| + if (!image.IsEmpty()) { |
| + const gfx::ImageSkia* imageskia = image.ToImageSkia(); |
|
sky
2017/02/08 03:14:54
image_skia.
chengx
2017/02/08 07:42:26
Done.
|
| + DCHECK(imageskia); |
| + std::vector<float> supportedScales = imageskia->GetSupportedScales(); |
|
sky
2017/02/08 03:14:54
supported_scales (or use directly in for statement
chengx
2017/02/08 07:42:26
Done.
|
| + for (auto& scale : supportedScales) { |
| + gfx::ImageSkiaRep imageSkiaRep = imageskia->GetRepresentation(scale); |
|
sky
2017/02/08 03:14:54
image_skia_rep.
chengx
2017/02/08 07:42:26
Done.
|
| + if (!imageSkiaRep.is_null()) |
| + image_family.Add( |
| + gfx::Image::CreateFrom1xBitmap(imageSkiaRep.sk_bitmap())); |
| + } |
| + } |
| + |
| if (!IconUtil::CreateIconFileFromImageFamily(image_family, path, |
| IconUtil::NORMAL_WRITE)) |
| return false; |
| @@ -541,10 +555,9 @@ void JumpList::OnFaviconDataAvailable( |
| base::AutoLock auto_lock(data->list_lock_); |
| // Attach the received data to the ShellLinkItem object. |
| // This data will be decoded by the RunUpdateOnFileThread method. |
| - if (!image_result.image.IsEmpty()) { |
| - if (!data->icon_urls_.empty() && data->icon_urls_.front().second.get()) |
| - data->icon_urls_.front().second->set_icon_data( |
| - image_result.image.AsBitmap()); |
| + if (!image_result.image.IsEmpty() && !data->icon_urls_.empty() && |
| + data->icon_urls_.front().second.get()) { |
| + data->icon_urls_.front().second->set_icon_data(image_result.image); |
|
sky
2017/02/08 03:14:54
I'm worried about using the image from multiple th
chengx
2017/02/08 07:42:26
Agreed. I switched to ImageSkia.
|
| } |
| if (!data->icon_urls_.empty()) |