| Index: chrome/browser/extensions/crx_installer.cc
|
| diff --git a/chrome/browser/extensions/crx_installer.cc b/chrome/browser/extensions/crx_installer.cc
|
| index d1f2a77c1f21132033696985f1e761549670cf66..3e6e88553fea4d05364c5370900c05ebffe40888 100644
|
| --- a/chrome/browser/extensions/crx_installer.cc
|
| +++ b/chrome/browser/extensions/crx_installer.cc
|
| @@ -47,6 +47,7 @@
|
| #include "grit/chromium_strings.h"
|
| #include "grit/generated_resources.h"
|
| #include "grit/theme_resources.h"
|
| +#include "skia/ext/image_operations.h"
|
| #include "third_party/skia/include/core/SkBitmap.h"
|
| #include "ui/base/l10n/l10n_util.h"
|
| #include "ui/base/resource/resource_bundle.h"
|
| @@ -392,6 +393,8 @@ void CrxInstaller::OnUnpackSuccess(const FilePath& temp_dir,
|
| &install_icon_);
|
| }
|
|
|
| + PreloadIcons();
|
| +
|
| if (!BrowserThread::PostTask(
|
| BrowserThread::UI, FROM_HERE,
|
| base::Bind(&CrxInstaller::CheckRequirements, this)))
|
| @@ -630,6 +633,8 @@ void CrxInstaller::ReportSuccessFromUIThread() {
|
| perms_updater.GrantActivePermissions(extension_, record_oauth2_grant_);
|
| }
|
|
|
| + CachePreloadedIcons();
|
| +
|
| // Tell the frontend about the installation and hand off ownership of
|
| // extension_ to it.
|
| frontend_weak_->OnExtensionInstalled(extension_,
|
| @@ -657,4 +662,49 @@ void CrxInstaller::NotifyCrxInstallComplete(const Extension* extension) {
|
| content::Details<const Extension>(extension));
|
| }
|
|
|
| +void CrxInstaller::PreloadIcons() {
|
| + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
|
| +
|
| + for (std::set<int>::const_iterator it = preload_sizes_.begin();
|
| + it != preload_sizes_.end(); ++it) {
|
| + scoped_ptr<SkBitmap> icon(new SkBitmap());
|
| +
|
| + const int requested_size = *it;
|
| + Extension::DecodeIcon(extension_.get(),
|
| + requested_size,
|
| + ExtensionIconSet::MATCH_BIGGER,
|
| + &icon);
|
| + if (icon->empty())
|
| + continue;
|
| +
|
| + if (icon->width() != requested_size ||
|
| + icon->height() != requested_size) {
|
| + *icon = skia::ImageOperations::Resize(
|
| + *icon, skia::ImageOperations::RESIZE_LANCZOS3,
|
| + requested_size, requested_size);
|
| + }
|
| +
|
| + preload_map_[*it] = *icon.get();
|
| + }
|
| +}
|
| +
|
| +void CrxInstaller::CachePreloadedIcons() {
|
| + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
| +
|
| + for (std::map<int, SkBitmap>::const_iterator it = preload_map_.begin();
|
| + it != preload_map_.end(); ++it) {
|
| + const std::string icon_path = extension_->icons().Get(
|
| + it->first, ExtensionIconSet::MATCH_BIGGER);
|
| + ExtensionResource icon_resource = extension_->GetResource(icon_path);
|
| + if (icon_resource.empty()) {
|
| + NOTREACHED();
|
| + continue;
|
| + }
|
| +
|
| + extension_->SetCachedImage(icon_resource,
|
| + it->second,
|
| + gfx::Size(it->first, it->first));
|
| + }
|
| +}
|
| +
|
| } // namespace extensions
|
|
|