diff options
author | ananta <ananta@chromium.org> | 2015-03-25 13:04:32 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-03-25 20:04:57 +0000 |
commit | 764a6e3d09a5e9043f72db15cca606d4e5467941 (patch) | |
tree | 440b89b152e38e41dfa13053855474753eb484ff /extensions/browser/extension_icon_image.cc | |
parent | a836d40219f594b84b3dee73ff97987fc4cbcdeb (diff) | |
download | chromium_src-764a6e3d09a5e9043f72db15cca606d4e5467941.zip chromium_src-764a6e3d09a5e9043f72db15cca606d4e5467941.tar.gz chromium_src-764a6e3d09a5e9043f72db15cca606d4e5467941.tar.bz2 |
Ensure that the extension icons show up in the omnibox at fractional scales.
Proposed fix is to discard all unsupported representations (Read fractional scales) in the Extension icon image when
the icon is loaded. This ensures that stale caches are invalidated and the correct icons are loaded when the cache is regenerated.
BUG=461958
Review URL: https://codereview.chromium.org/1025513004
Cr-Commit-Position: refs/heads/master@{#322225}
Diffstat (limited to 'extensions/browser/extension_icon_image.cc')
-rw-r--r-- | extensions/browser/extension_icon_image.cc | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/extensions/browser/extension_icon_image.cc b/extensions/browser/extension_icon_image.cc index 5ebc400..31ddd61 100644 --- a/extensions/browser/extension_icon_image.cc +++ b/extensions/browser/extension_icon_image.cc @@ -11,6 +11,7 @@ #include "extensions/browser/image_loader.h" #include "extensions/browser/notification_types.h" #include "extensions/common/extension.h" +#include "ui/base/layout.h" #include "ui/gfx/canvas.h" #include "ui/gfx/geometry/size.h" #include "ui/gfx/geometry/size_conversions.h" @@ -223,7 +224,21 @@ void IconImage::OnImageLoaded(float scale, const gfx::Image& image_in) { DCHECK(!rep.is_null()); DCHECK_EQ(scale, rep.scale()); - // Remove old representation if there is one. + // Remove fractional scale image representations as they may have become + // stale here. These images are generated by ImageSkia on request from + // supported scales like 1x, 2x, etc. + // TODO(oshima) + // A better approach might be to set the |image_| member using the ImageSkia + // copy from the image passed in and set the |image_skia_| member using + // image_.ToImageSkia(). However that does not work correctly as the + // ImageSkia from the image does not contain a source which breaks requests + // for scaled images. + std::vector<gfx::ImageSkiaRep> reps = image_skia_.image_reps(); + for (const auto rep : reps) { + if (!ui::IsSupportedScale(rep.scale())) + image_skia_.RemoveRepresentation(rep.scale()); + } + image_skia_.RemoveRepresentation(scale); image_skia_.AddRepresentation(rep); |