| Index: chrome/browser/ui/app_list/extension_app_item.cc
|
| diff --git a/chrome/browser/ui/app_list/extension_app_item.cc b/chrome/browser/ui/app_list/extension_app_item.cc
|
| index 8b0c4bb108559a91c8bfb13887cf2dd0aa3f2c2a..1f4c68452675f85bb1a92e51e2ae96d89c9c4ee2 100644
|
| --- a/chrome/browser/ui/app_list/extension_app_item.cc
|
| +++ b/chrome/browser/ui/app_list/extension_app_item.cc
|
| @@ -117,39 +117,29 @@ class ExtensionUninstaller : public ExtensionUninstallDialog::Delegate {
|
| DISALLOW_COPY_AND_ASSIGN(ExtensionUninstaller);
|
| };
|
|
|
| -class TabOverlayImageSource : public gfx::CanvasImageSource {
|
| +// Overlays a shortcut icon over the bottom left corner of a given image.
|
| +class ShortcutOverlayImageSource : public gfx::CanvasImageSource {
|
| public:
|
| - TabOverlayImageSource(const gfx::ImageSkia& icon, const gfx::Size& size)
|
| - : gfx::CanvasImageSource(size, false),
|
| + explicit ShortcutOverlayImageSource(const gfx::ImageSkia& icon)
|
| + : gfx::CanvasImageSource(icon.size(), false),
|
| icon_(icon) {
|
| - if (!icon_.isNull()) {
|
| - DCHECK_EQ(extension_misc::EXTENSION_ICON_SMALL, icon_.width());
|
| - DCHECK_EQ(extension_misc::EXTENSION_ICON_SMALL, icon_.height());
|
| - }
|
| }
|
| - virtual ~TabOverlayImageSource() {}
|
| + virtual ~ShortcutOverlayImageSource() {}
|
|
|
| private:
|
| // gfx::CanvasImageSource overrides:
|
| virtual void Draw(gfx::Canvas* canvas) OVERRIDE {
|
| - using extension_misc::EXTENSION_ICON_SMALL;
|
| - using extension_misc::EXTENSION_ICON_MEDIUM;
|
| -
|
| - const int kIconOffset = (EXTENSION_ICON_MEDIUM - EXTENSION_ICON_SMALL) / 2;
|
| -
|
| - // The tab overlay is not vertically symmetric, to position the app in the
|
| - // middle of the overlay we need a slight adjustment.
|
| - const int kVerticalAdjust = 4;
|
| - canvas->DrawImageInt(
|
| - *ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed(
|
| - IDR_APP_LIST_TAB_OVERLAY),
|
| - 0, 0);
|
| - canvas->DrawImageInt(icon_, kIconOffset, kIconOffset + kVerticalAdjust);
|
| + canvas->DrawImageInt(icon_, 0, 0);
|
| +
|
| + // Draw the overlay in the bottom left corner of the icon.
|
| + const gfx::ImageSkia& overlay = *ui::ResourceBundle::GetSharedInstance().
|
| + GetImageSkiaNamed(IDR_APP_LIST_TAB_OVERLAY);
|
| + canvas->DrawImageInt(overlay, 0, icon_.height() - overlay.height());
|
| }
|
|
|
| gfx::ImageSkia icon_;
|
|
|
| - DISALLOW_COPY_AND_ASSIGN(TabOverlayImageSource);
|
| + DISALLOW_COPY_AND_ASSIGN(ShortcutOverlayImageSource);
|
| };
|
|
|
| extensions::ExtensionPrefs::LaunchType GetExtensionLaunchType(
|
| @@ -280,17 +270,8 @@ void ExtensionAppItem::Move(const ExtensionAppItem* prev,
|
| void ExtensionAppItem::UpdateIcon() {
|
| if (!GetExtension()) {
|
| gfx::ImageSkia icon = installing_icon_;
|
| - if (HasOverlay()) {
|
| - // The tab overlay requires icons of a certain size.
|
| - gfx::Size small_size(extension_misc::EXTENSION_ICON_SMALL,
|
| - extension_misc::EXTENSION_ICON_SMALL);
|
| - icon = gfx::ImageSkiaOperations::CreateResizedImage(
|
| - icon, skia::ImageOperations::RESIZE_GOOD, small_size);
|
| -
|
| - gfx::Size size(extension_misc::EXTENSION_ICON_MEDIUM,
|
| - extension_misc::EXTENSION_ICON_MEDIUM);
|
| - icon = gfx::ImageSkia(new TabOverlayImageSource(icon, size), size);
|
| - }
|
| + if (HasOverlay())
|
| + icon = gfx::ImageSkia(new ShortcutOverlayImageSource(icon), icon.size());
|
| SetIcon(icon, !HasOverlay());
|
| return;
|
| }
|
| @@ -304,11 +285,8 @@ void ExtensionAppItem::UpdateIcon() {
|
| icon = gfx::ImageSkiaOperations::CreateHSLShiftedImage(icon, shift);
|
| }
|
|
|
| - if (HasOverlay()) {
|
| - const gfx::Size size(extension_misc::EXTENSION_ICON_MEDIUM,
|
| - extension_misc::EXTENSION_ICON_MEDIUM);
|
| - icon = gfx::ImageSkia(new TabOverlayImageSource(icon, size), size);
|
| - }
|
| + if (HasOverlay())
|
| + icon = gfx::ImageSkia(new ShortcutOverlayImageSource(icon), icon.size());
|
|
|
| SetIcon(icon, !HasOverlay());
|
| }
|
| @@ -321,15 +299,11 @@ const Extension* ExtensionAppItem::GetExtension() const {
|
| }
|
|
|
| void ExtensionAppItem::LoadImage(const Extension* extension) {
|
| - int icon_size = extension_misc::EXTENSION_ICON_MEDIUM;
|
| - if (HasOverlay())
|
| - icon_size = extension_misc::EXTENSION_ICON_SMALL;
|
| -
|
| icon_.reset(new extensions::IconImage(
|
| profile_,
|
| extension,
|
| extensions::IconsInfo::GetIcons(extension),
|
| - icon_size,
|
| + extension_misc::EXTENSION_ICON_MEDIUM,
|
| extensions::IconsInfo::GetDefaultAppIcon(),
|
| this));
|
| UpdateIcon();
|
|
|