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

Unified Diff: chrome/browser/ui/app_list/extension_app_item.cc

Issue 13813004: Add new overlay for v1 apps in the launcher. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 7 years, 8 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 | « chrome/app/theme/theme_resources.grd ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..7ebc1ccdc1651f92a654848c27468631fbfe3a8e 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());
}
@@ -322,9 +300,6 @@ const Extension* ExtensionAppItem::GetExtension() const {
void ExtensionAppItem::LoadImage(const Extension* extension) {
int icon_size = extension_misc::EXTENSION_ICON_MEDIUM;
xiyuan 2013/04/09 18:06:27 nit: get rid of |icon_size| and use extension_misc
koz (OOO until 15th September) 2013/04/09 18:09:32 Done.
- if (HasOverlay())
- icon_size = extension_misc::EXTENSION_ICON_SMALL;
-
icon_.reset(new extensions::IconImage(
profile_,
extension,
« no previous file with comments | « chrome/app/theme/theme_resources.grd ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698