| 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 4d4f0dd0ec58c2078233e004d796a54378fbe0ee..f7bbcb14b79421d05a5a4221370acc8487c16b59 100644
|
| --- a/chrome/browser/ui/app_list/extension_app_item.cc
|
| +++ b/chrome/browser/ui/app_list/extension_app_item.cc
|
| @@ -9,6 +9,9 @@
|
| #include "base/macros.h"
|
| #include "base/metrics/user_metrics.h"
|
| #include "build/build_config.h"
|
| +#include "chrome/browser/chromeos/extensions/gfx_utils.h"
|
| +#include "chrome/browser/extensions/extension_app_icon.h"
|
| +#include "chrome/browser/extensions/extension_app_icon_service.h"
|
| #include "chrome/browser/extensions/extension_util.h"
|
| #include "chrome/browser/extensions/launch_util.h"
|
| #include "chrome/browser/profiles/profile.h"
|
| @@ -33,74 +36,9 @@
|
| #include "ui/gfx/geometry/rect.h"
|
| #include "ui/gfx/image/canvas_image_source.h"
|
| #include "ui/gfx/skia_util.h"
|
| -#include "chrome/browser/chromeos/extensions/gfx_utils.h"
|
|
|
| using extensions::Extension;
|
|
|
| -namespace {
|
| -
|
| -// Overlays a shortcut icon over the bottom left corner of a given image.
|
| -class ShortcutOverlayImageSource : public gfx::CanvasImageSource {
|
| - public:
|
| - explicit ShortcutOverlayImageSource(const gfx::ImageSkia& icon)
|
| - : gfx::CanvasImageSource(icon.size(), false),
|
| - icon_(icon) {
|
| - }
|
| - ~ShortcutOverlayImageSource() override {}
|
| -
|
| - private:
|
| - // gfx::CanvasImageSource overrides:
|
| - void Draw(gfx::Canvas* canvas) override {
|
| - 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(ShortcutOverlayImageSource);
|
| -};
|
| -
|
| -// Rounds the corners of a given image.
|
| -class RoundedCornersImageSource : public gfx::CanvasImageSource {
|
| - public:
|
| - explicit RoundedCornersImageSource(const gfx::ImageSkia& icon)
|
| - : gfx::CanvasImageSource(icon.size(), false),
|
| - icon_(icon) {
|
| - }
|
| - ~RoundedCornersImageSource() override {}
|
| -
|
| - private:
|
| - // gfx::CanvasImageSource overrides:
|
| - void Draw(gfx::Canvas* canvas) override {
|
| - // The radius used to round the app icon.
|
| - const size_t kRoundingRadius = 2;
|
| -
|
| - canvas->DrawImageInt(icon_, 0, 0);
|
| -
|
| - cc::PaintFlags masking_flags;
|
| - masking_flags.setBlendMode(SkBlendMode::kDstIn);
|
| - canvas->SaveLayerWithFlags(masking_flags);
|
| -
|
| - cc::PaintFlags mask_flags;
|
| - mask_flags.setAntiAlias(true);
|
| - mask_flags.setColor(SK_ColorWHITE);
|
| - canvas->DrawRoundRect(gfx::Rect(icon_.width(), icon_.height()),
|
| - kRoundingRadius, mask_flags);
|
| -
|
| - canvas->Restore();
|
| - }
|
| -
|
| - gfx::ImageSkia icon_;
|
| -
|
| - DISALLOW_COPY_AND_ASSIGN(RoundedCornersImageSource);
|
| -};
|
| -
|
| -} // namespace
|
| -
|
| ExtensionAppItem::ExtensionAppItem(
|
| Profile* profile,
|
| const app_list::AppListSyncableService::SyncItem* sync_item,
|
| @@ -129,31 +67,21 @@ void ExtensionAppItem::Reload() {
|
| SetIsInstalling(is_installing);
|
| if (is_installing) {
|
| SetName(extension_name_);
|
| - UpdateIcon();
|
| + SetIcon(installing_icon_);
|
| return;
|
| }
|
| SetNameAndShortName(extension->name(), extension->short_name());
|
| - LoadImage(extension);
|
| + if (!icon_) {
|
| + icon_ = extensions::ExtensionAppIconService::Get(profile())->CreateIcon(
|
| + this, extension_id(), extension_misc::EXTENSION_ICON_MEDIUM);
|
| + } else {
|
| + icon_->Reload();
|
| + }
|
| }
|
|
|
| -void ExtensionAppItem::UpdateIcon() {
|
| - gfx::ImageSkia icon = installing_icon_;
|
| -
|
| - // Use the app icon if the app exists. Turn the image greyscale if the app is
|
| - // not launchable.
|
| - if (GetExtension() && icon_) {
|
| - icon = icon_->image_skia();
|
| - const bool enabled = extensions::util::IsAppLaunchable(extension_id(),
|
| - profile());
|
| - extensions::util::MaybeApplyChromeBadge(profile(), id(), &icon);
|
| -
|
| - if (!enabled)
|
| - icon = CreateDisabledIcon(icon);
|
| -
|
| - if (GetExtension()->from_bookmark())
|
| - icon = gfx::ImageSkia(new RoundedCornersImageSource(icon), icon.size());
|
| - }
|
| - SetIcon(icon);
|
| +void ExtensionAppItem::UpdateIcon(extensions::ExtensionAppIcon* icon,
|
| + const gfx::ImageSkia& image) {
|
| + SetIcon(icon->IsValid() ? image : installing_icon_);
|
| }
|
|
|
| const Extension* ExtensionAppItem::GetExtension() const {
|
| @@ -164,17 +92,6 @@ const Extension* ExtensionAppItem::GetExtension() const {
|
| return extension;
|
| }
|
|
|
| -void ExtensionAppItem::LoadImage(const Extension* extension) {
|
| - icon_.reset(new extensions::IconImage(
|
| - profile(),
|
| - extension,
|
| - extensions::IconsInfo::GetIcons(extension),
|
| - extension_misc::EXTENSION_ICON_MEDIUM,
|
| - extensions::util::GetDefaultAppIcon(),
|
| - this));
|
| - UpdateIcon();
|
| -}
|
| -
|
| bool ExtensionAppItem::RunExtensionEnableFlow() {
|
| if (extensions::util::IsAppLaunchableWithoutEnabling(extension_id(),
|
| profile()))
|
| @@ -211,17 +128,6 @@ void ExtensionAppItem::Launch(int event_flags) {
|
| event_flags);
|
| }
|
|
|
| -void ExtensionAppItem::OnExtensionIconImageChanged(
|
| - extensions::IconImage* image) {
|
| - DCHECK(icon_.get() == image);
|
| - UpdateIcon();
|
| -}
|
| -
|
| -void ExtensionAppItem::OnExtensionIconImageDestroyed(
|
| - extensions::IconImage* image) {
|
| - SetIcon(gfx::ImageSkia());
|
| -}
|
| -
|
| void ExtensionAppItem::ExtensionEnableFlowFinished() {
|
| extension_enable_flow_.reset();
|
| extension_enable_flow_controller_->OnCloseChildDialog();
|
|
|