| 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 754004c3613f7b0f96757a363e38481559996f0d..86df6a650d5ce894b206790a29bd295866074acb 100644
|
| --- a/chrome/browser/ui/web_applications/web_app_ui.cc
|
| +++ b/chrome/browser/ui/web_applications/web_app_ui.cc
|
| @@ -29,6 +29,9 @@
|
| #include "skia/ext/image_operations.h"
|
| #include "third_party/skia/include/core/SkBitmap.h"
|
| #include "ui/base/resource/resource_bundle.h"
|
| +#include "ui/gfx/image/image.h"
|
| +#include "ui/gfx/image/image_family.h"
|
| +#include "ui/gfx/image/image_skia.h"
|
|
|
| #if defined(OS_POSIX) && !defined(OS_MACOSX)
|
| #include "base/environment.h"
|
| @@ -195,8 +198,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::Image::CreateFrom1xBitmap(bitmaps[closest_index]));
|
| extensions::TabHelper* extensions_tab_helper =
|
| extensions::TabHelper::FromWebContents(web_contents_);
|
| extensions_tab_helper->SetAppIcon(bitmaps[closest_index]);
|
| @@ -270,8 +273,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();
|
| @@ -332,9 +334,23 @@ 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::Image::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.AsImageSkia();
|
| + // NOTE: We do not call ImageSkia::EnsureRepsForSupportedScaleFactors here.
|
| + // The image reps here are not really for different scale factors (ImageSkia
|
| + // is just being used as a handy container for multiple images).
|
| + 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) {
|
| + gfx::ImageSkia image_skia(*it);
|
| + image_skia.MakeThreadSafe();
|
| + shortcut_info.favicon.Add(image_skia);
|
| + }
|
| }
|
|
|
| callback.Run(shortcut_info);
|
| @@ -368,7 +384,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());
|
|
|
| Profile* profile =
|
| Profile::FromBrowserContext(web_contents->GetBrowserContext());
|
| @@ -402,6 +418,11 @@ void UpdateShortcutInfoAndIconForApp(
|
| ShellIntegration::ShortcutInfo shortcut_info =
|
| ShortcutInfoForExtensionAndProfile(&extension, profile);
|
|
|
| + // We want to load each icon into a separate ImageSkia to insert into an
|
| + // ImageFamily, 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 ImageFamily.
|
| std::vector<extensions::ImageLoader::ImageRepresentation> info_list;
|
| for (size_t i = 0; i < arraysize(kDesiredSizes); ++i) {
|
| int size = kDesiredSizes[i];
|
|
|