diff options
author | xiyuan@chromium.org <xiyuan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-24 23:28:42 +0000 |
---|---|---|
committer | xiyuan@chromium.org <xiyuan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-24 23:28:42 +0000 |
commit | b417267a31948ab7ebac1f97b528b5103bfa999a (patch) | |
tree | 1f1dd587194b2dfb0f479677cc4b30015ab011db | |
parent | 4b90c2064ae457ae2caed9b2c57a73ea030d7954 (diff) | |
download | chromium_src-b417267a31948ab7ebac1f97b528b5103bfa999a.zip chromium_src-b417267a31948ab7ebac1f97b528b5103bfa999a.tar.gz chromium_src-b417267a31948ab7ebac1f97b528b5103bfa999a.tar.bz2 |
ash: Clean up extension icon loading special cases.
Those special cases are handled in ImageLoadingTracker after r133657.
BUG=none.
TEST=No change.
Review URL: http://codereview.chromium.org/10212004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@133803 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/ui/views/ash/app_list/extension_app_item.cc | 56 | ||||
-rw-r--r-- | chrome/browser/ui/views/ash/app_list/extension_app_item.h | 3 |
2 files changed, 4 insertions, 55 deletions
diff --git a/chrome/browser/ui/views/ash/app_list/extension_app_item.cc b/chrome/browser/ui/views/ash/app_list/extension_app_item.cc index e996593..91486b6 100644 --- a/chrome/browser/ui/views/ash/app_list/extension_app_item.cc +++ b/chrome/browser/ui/views/ash/app_list/extension_app_item.cc @@ -17,15 +17,9 @@ #include "chrome/browser/ui/views/ash/launcher/chrome_launcher_delegate.h" #include "chrome/common/extensions/extension.h" #include "chrome/common/extensions/extension_icon_set.h" -#include "chrome/common/extensions/extension_resource.h" #include "grit/chromium_strings.h" -#include "grit/component_extension_resources_map.h" #include "grit/generated_resources.h" -#include "grit/theme_resources.h" -#include "third_party/skia/include/core/SkBitmap.h" #include "ui/base/l10n/l10n_util.h" -#include "ui/base/resource/resource_bundle.h" -#include "ui/gfx/codec/png_codec.h" #include "ui/gfx/image/image.h" namespace { @@ -149,58 +143,16 @@ const Extension* ExtensionAppItem::GetExtension() const { } void ExtensionAppItem::LoadImage(const Extension* extension) { - ExtensionResource icon = extension->GetIconResource( - ExtensionIconSet::EXTENSION_ICON_LARGE, - ExtensionIconSet::MATCH_BIGGER); - if (icon.relative_path().empty()) { - LoadDefaultImage(); - return; - } - - if (extension->location() == Extension::COMPONENT) { - FilePath directory_path = extension->path(); - FilePath relative_path = directory_path.BaseName().Append( - icon.relative_path()); - for (size_t i = 0; i < kComponentExtensionResourcesSize; ++i) { - FilePath bm_resource_path = - FilePath().AppendASCII(kComponentExtensionResources[i].name); - bm_resource_path = bm_resource_path.NormalizePathSeparators(); - if (relative_path == bm_resource_path) { - ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); - int resource = kComponentExtensionResources[i].value; - - base::StringPiece contents = rb.GetRawDataResource(resource); - SkBitmap icon; - if (gfx::PNGCodec::Decode( - reinterpret_cast<const unsigned char*>(contents.data()), - contents.size(), &icon)) { - SetIcon(icon); - return; - } else { - NOTREACHED() << "Unable to decode image resource " << resource; - } - } - } - } - tracker_.reset(new ImageLoadingTracker(this)); tracker_->LoadImage(extension, - icon, + extension->GetIconResource( + ExtensionIconSet::EXTENSION_ICON_LARGE, + ExtensionIconSet::MATCH_BIGGER), gfx::Size(ExtensionIconSet::EXTENSION_ICON_LARGE, ExtensionIconSet::EXTENSION_ICON_LARGE), ImageLoadingTracker::DONT_CACHE); } -void ExtensionAppItem::LoadDefaultImage() { - const Extension* extension = GetExtension(); - int resource = IDR_APP_DEFAULT_ICON; - if (extension && extension->id() == extension_misc::kWebStoreAppId) - resource = IDR_WEBSTORE_ICON; - - ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); - SetIcon(*rb.GetImageNamed(resource).ToSkBitmap()); -} - void ExtensionAppItem::ShowExtensionOptions() { const Extension* extension = GetExtension(); if (!extension) @@ -230,7 +182,7 @@ void ExtensionAppItem::OnImageLoaded(const gfx::Image& image, if (!image.IsEmpty()) SetIcon(*image.ToSkBitmap()); else - LoadDefaultImage(); + SetIcon(Extension::GetDefaultIcon(true /* is_app */)); } bool ExtensionAppItem::IsItemForCommandIdDynamic(int command_id) const { diff --git a/chrome/browser/ui/views/ash/app_list/extension_app_item.h b/chrome/browser/ui/views/ash/app_list/extension_app_item.h index 8bb1c05..19aad01 100644 --- a/chrome/browser/ui/views/ash/app_list/extension_app_item.h +++ b/chrome/browser/ui/views/ash/app_list/extension_app_item.h @@ -36,9 +36,6 @@ class ExtensionAppItem : public ChromeAppListItem, // Loads extension icon. void LoadImage(const Extension* extension); - // Loads default extension icon. - void LoadDefaultImage(); - void ShowExtensionOptions(); void StartExtensionUninstall(); |