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

Unified Diff: chrome/browser/ui/ash/launcher/launcher_app_icon_loader.cc

Issue 10868003: chromeos: Fix pixelated icons in app list and launcher (part 3) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase on tony's cl, get rid of icon cache and worker thread Created 8 years, 3 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
Index: chrome/browser/ui/ash/launcher/launcher_app_icon_loader.cc
diff --git a/chrome/browser/ui/ash/launcher/launcher_app_icon_loader.cc b/chrome/browser/ui/ash/launcher/launcher_app_icon_loader.cc
index a7e81426bf85a8982c350619bb843c1a3ddda6dc..39019b3341ebc02975415e61686dd30f4cdc0e67 100644
--- a/chrome/browser/ui/ash/launcher/launcher_app_icon_loader.cc
+++ b/chrome/browser/ui/ash/launcher/launcher_app_icon_loader.cc
@@ -4,6 +4,7 @@
#include "chrome/browser/ui/ash/launcher/launcher_app_icon_loader.h"
+#include "base/stl_util.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/tab_contents/tab_contents.h"
@@ -31,10 +32,11 @@ LauncherAppIconLoader::LauncherAppIconLoader(
}
LauncherAppIconLoader::~LauncherAppIconLoader() {
+ STLDeleteContainerPairFirstPointers(map_.begin(), map_.end());
}
void LauncherAppIconLoader::FetchImage(const std::string& id) {
- for (ImageLoaderIDToExtensionIDMap::const_iterator i = map_.begin();
+ for (ImageToExtensionIDMap::const_iterator i = map_.begin();
i != map_.end(); ++i) {
if (i->second == id)
return; // Already loading the image.
@@ -43,29 +45,35 @@ void LauncherAppIconLoader::FetchImage(const std::string& id) {
const extensions::Extension* extension = GetExtensionByID(profile_, id);
if (!extension)
return;
- if (!image_loader_.get())
- image_loader_.reset(new ImageLoadingTracker(this));
- map_[image_loader_->next_id()] = id;
- image_loader_->LoadImage(
+
+ extensions::IconImage* image = new extensions::IconImage(
extension,
- extension->GetIconResource(extension_misc::EXTENSION_ICON_SMALL,
- ExtensionIconSet::MATCH_BIGGER),
- gfx::Size(extension_misc::EXTENSION_ICON_SMALL,
- extension_misc::EXTENSION_ICON_SMALL),
- ImageLoadingTracker::CACHE);
+ extension->icons(),
+ extension_misc::EXTENSION_ICON_SMALL,
+ extensions::Extension::GetDefaultIcon(true),
+ this);
+ // |map_| takes ownership if |image|.
tbarzic 2012/09/07 17:14:07 s/if/of
xiyuan 2012/09/07 20:05:59 Done.
+ map_[image] = id;
+
+ OnExtensionIconImageChanged(image);
tbarzic 2012/09/07 17:14:07 optional: host_->SetAppImage(id, image->image_skia
xiyuan 2012/09/07 20:05:59 Done.
+}
+
+void LauncherAppIconLoader::ClearImage(const std::string& id) {
+ for (ImageToExtensionIDMap::iterator i = map_.begin();
+ i != map_.end(); ++i) {
+ if (i->second == id) {
+ delete i->first;
+ map_.erase(i);
+ break;
+ }
+ }
}
-void LauncherAppIconLoader::OnImageLoaded(const gfx::Image& image,
- const std::string& extension_id,
- int index) {
- ImageLoaderIDToExtensionIDMap::iterator i = map_.find(index);
+void LauncherAppIconLoader::OnExtensionIconImageChanged(
+ extensions::IconImage* image) {
+ ImageToExtensionIDMap::iterator i = map_.find(image);
if (i == map_.end())
- return; // The tab has since been removed, do nothing.
+ return; // The image has been removed, do nothing.
pkotwicz 2012/09/07 19:24:49 Optional: I think you can delete i->first and eras
xiyuan 2012/09/07 20:05:59 We need to keep IconImage alive so that it could l
- std::string id = i->second;
- map_.erase(i);
- if (image.IsEmpty())
- host_->SetAppImage(id, extensions::Extension::GetDefaultIcon(true));
- else
- host_->SetAppImage(id, *image.ToImageSkia());
+ host_->SetAppImage(i->second, image->image_skia());
}

Powered by Google App Engine
This is Rietveld 408576698