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

Unified Diff: chrome/browser/win/jumplist.cc

Issue 2665623002: Fix Jumplist favicons to have high resolution in HDPI Windows displays (Closed)
Patch Set: Better function names and parameters. Created 3 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/win/jumplist_updater.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/win/jumplist.cc
diff --git a/chrome/browser/win/jumplist.cc b/chrome/browser/win/jumplist.cc
index 508093dfa290fa460552fa29d95bdf17c8b071eb..14b6f870ca397a92d57d6b15c899bc5272e6ceb2 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::ImageSkia& image_skia,
const base::FilePath& icon_dir,
base::FilePath* icon_path) {
// Retrieve the path to a temporary file.
@@ -86,7 +89,16 @@ 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_skia.isNull()) {
+ std::vector<float> supported_scales = image_skia.GetSupportedScales();
+ for (auto& scale : supported_scales) {
+ gfx::ImageSkiaRep image_skia_rep = image_skia.GetRepresentation(scale);
+ if (!image_skia_rep.is_null())
+ image_family.Add(
+ gfx::Image::CreateFrom1xBitmap(image_skia_rep.sk_bitmap()));
+ }
+ }
+
if (!IconUtil::CreateIconFileFromImageFamily(image_family, path,
IconUtil::NORMAL_WRITE))
return false;
@@ -104,7 +116,7 @@ void CreateIconFiles(const base::FilePath& icon_dir,
for (ShellLinkItemList::const_iterator item = item_list.begin();
item != item_list.end(); ++item) {
base::FilePath icon_path;
- if (CreateIconFile((*item)->icon_data(), icon_dir, &icon_path))
+ if (CreateIconFile((*item)->icon_image(), icon_dir, &icon_path))
(*item)->set_icon(icon_path.value(), 0);
}
}
@@ -541,10 +553,12 @@ 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()) {
+ gfx::ImageSkia image_skia = image_result.image.AsImageSkia();
+ image_skia.EnsureRepsForSupportedScales();
+ std::unique_ptr<gfx::ImageSkia> deep_copy(image_skia.DeepCopy());
+ data->icon_urls_.front().second->set_icon_image(*deep_copy);
}
if (!data->icon_urls_.empty())
« no previous file with comments | « no previous file | chrome/browser/win/jumplist_updater.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698