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

Unified Diff: chrome/browser/ui/web_applications/web_app_ui.cc

Issue 12881003: ShortcutInfo::favicon is now a gfx::ImageFamily instead of gfx::Image. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: web_app_mac: Fix compile error (no Mac to test it on so I'm building in the dark). Created 7 years, 9 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
Index: chrome/browser/ui/web_applications/web_app_ui.cc
diff --git a/chrome/browser/ui/web_applications/web_app_ui.cc b/chrome/browser/ui/web_applications/web_app_ui.cc
index 34ad3d0994fe056d0662e1e20e848ba65cea95bc..7e2ae049b84de6b022ef2c7b8ebd0d1951f94493 100644
--- a/chrome/browser/ui/web_applications/web_app_ui.cc
+++ b/chrome/browser/ui/web_applications/web_app_ui.cc
@@ -194,8 +194,8 @@ void UpdateShortcutWorker::DidDownloadFavicon(
if (!bitmaps.empty() && !bitmaps[closest_index].isNull()) {
// Update icon with download image and update shortcut.
- shortcut_info_.favicon =
- gfx::Image::CreateFrom1xBitmap(bitmaps[closest_index]);
+ shortcut_info_.favicon.Add(
+ gfx::ImageSkia::CreateFrom1xBitmap(bitmaps[closest_index]));
extensions::TabHelper* extensions_tab_helper =
extensions::TabHelper::FromWebContents(web_contents_);
extensions_tab_helper->SetAppIcon(bitmaps[closest_index]);
@@ -269,8 +269,7 @@ void UpdateShortcutWorker::UpdateShortcutsOnFileThread() {
base::FilePath icon_file = web_app_path.Append(file_name_).ReplaceExtension(
FILE_PATH_LITERAL(".ico"));
- web_app::internals::CheckAndSaveIcon(icon_file,
- *shortcut_info_.favicon.ToSkBitmap());
+ web_app::internals::CheckAndSaveIcon(icon_file, shortcut_info_.favicon);
// Update existing shortcuts' description, icon and app id.
CheckExistingShortcuts();
@@ -331,9 +330,21 @@ void OnImageLoaded(ShellIntegration::ShortcutInfo shortcut_info,
SkBitmap bmp = skia::ImageOperations::Resize(
*default_icon.ToSkBitmap(), skia::ImageOperations::RESIZE_BEST,
size, size);
- shortcut_info.favicon = gfx::Image::CreateFrom1xBitmap(bmp);
+ shortcut_info.favicon.Add(gfx::ImageSkia::CreateFrom1xBitmap(bmp));
} else {
- shortcut_info.favicon = image;
+ // As described in UpdateShortcutInfoAndIconForApp, image contains all of
+ // the icons, hackily put into a single ImageSkia. Separate them out into
+ // individual ImageSkias and insert them into the icon family.
+ const gfx::ImageSkia& multires_image_skia = *(image.ToImageSkia());
+ std::vector<gfx::ImageSkiaRep> image_reps =
+ multires_image_skia.image_reps();
+ for (std::vector<gfx::ImageSkiaRep>::const_iterator it = image_reps.begin();
+ it != image_reps.end(); ++it) {
+ const gfx::ImageSkiaRep& image = *it;
+ gfx::ImageSkia image_skia(image);
+ image_skia.MakeThreadSafe();
+ shortcut_info.favicon.Add(image_skia);
+ }
}
callback.Run(shortcut_info);
@@ -367,7 +378,7 @@ void GetShortcutInfoForTab(WebContents* web_contents,
web_contents->GetTitle()) :
app_info.title;
info->description = app_info.description;
- info->favicon = gfx::Image(favicon_tab_helper->GetFavicon());
+ info->favicon.Add(favicon_tab_helper->GetFavicon());
pkotwicz 2013/03/18 03:22:43 Comment: Please let me know if you want to fix thi
Matt Giuca 2013/03/18 07:41:16 Sorry, I'm not really sure what this code is doing
Profile* profile =
Profile::FromBrowserContext(web_contents->GetBrowserContext());
@@ -401,6 +412,11 @@ void UpdateShortcutInfoAndIconForApp(
ShellIntegration::ShortcutInfo shortcut_info =
ShortcutInfoForExtensionAndProfile(&extension, profile);
+ // We want to load each icon into a separate ImageSkia to insert into an
+ // IconFamily, but LoadImagesAsync currently only builds a single ImageSkia.
+ // Hack around this by loading all images into the ImageSkia as 100%
+ // representations, and later (in OnImageLoaded), pulling them out and
+ // individually inserting them into an IconFamily.
pkotwicz 2013/03/18 03:22:43 Comment: It would be nice to get rid of this hack
Matt Giuca 2013/03/18 07:41:16 Yeah, although I think that will require refactori
std::vector<extensions::ImageLoader::ImageRepresentation> info_list;
for (size_t i = 0; i < arraysize(kDesiredSizes); ++i) {
int size = kDesiredSizes[i];

Powered by Google App Engine
This is Rietveld 408576698