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

Unified Diff: chrome/browser/extensions/extension_web_ui.cc

Issue 10870022: Change FaviconData to be able to return data for multiple bitmaps for same icon URL (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 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/extensions/extension_web_ui.cc
diff --git a/chrome/browser/extensions/extension_web_ui.cc b/chrome/browser/extensions/extension_web_ui.cc
index 71f8d41e0845893275ef4df3e2f11c7a939a50ea..1494de9c9241669e870240dfc81011baab56b47e 100644
--- a/chrome/browser/extensions/extension_web_ui.cc
+++ b/chrome/browser/extensions/extension_web_ui.cc
@@ -105,37 +105,44 @@ class ExtensionWebUIImageLoadingTracker : public ImageLoadingTracker::Observer {
gfx::Size(gfx::kFaviconSize, gfx::kFaviconSize),
ImageLoadingTracker::DONT_CACHE);
} else {
- ForwardResult(NULL);
+ ForwardResult(gfx::Image());
}
}
virtual void OnImageLoaded(const gfx::Image& image,
const std::string& extension_id,
int index) OVERRIDE {
- if (!image.IsEmpty()) {
- std::vector<unsigned char> image_data;
- if (!gfx::PNGCodec::EncodeBGRASkBitmap(*image.ToSkBitmap(), false,
- &image_data)) {
- NOTREACHED() << "Could not encode extension favicon";
- }
- ForwardResult(base::RefCountedBytes::TakeVector(&image_data));
- } else {
- ForwardResult(NULL);
- }
+ ForwardResult(image);
}
private:
~ExtensionWebUIImageLoadingTracker() {}
- // Forwards the result on the request. If no favicon was available then
- // |icon_data| may be backed by NULL. Once the result has been forwarded the
- // instance is deleted.
- void ForwardResult(scoped_refptr<base::RefCountedMemory> icon_data) {
- history::FaviconData favicon;
- favicon.known_icon = icon_data.get() != NULL && icon_data->size() > 0;
- favicon.image_data = icon_data;
- favicon.icon_type = history::FAVICON;
- request_->ForwardResultAsync(request_->handle(), favicon);
+ // Forwards the result of the request. If no favicon was available then
+ // |icon| will be empty. Once the result has been forwarded the instance is
+ // deleted.
+ void ForwardResult(const gfx::Image& icon) {
+ std::vector<history::FaviconBitmapResult> favicon_bitmap_results;
+ SkBitmap icon_bitmap = icon.AsBitmap();
+ if (!icon_bitmap.empty()) {
+ scoped_refptr<base::RefCountedBytes> icon_data(
+ new base::RefCountedBytes());
+ if (gfx::PNGCodec::EncodeBGRASkBitmap(icon_bitmap, false,
+ &icon_data->data())) {
+ history::FaviconBitmapResult bitmap_result;
+ bitmap_result.bitmap_data = icon_data;
+ bitmap_result.pixel_size = gfx::Size(icon_bitmap.width(),
+ icon_bitmap.height());
+ bitmap_result.icon_type = history::FAVICON;
+
+ favicon_bitmap_results.push_back(bitmap_result);
+ } else {
+ NOTREACHED() << "Could not encode extension favicon";
+ }
+ }
+
+ request_->ForwardResultAsync(request_->handle(), favicon_bitmap_results,
+ history::IconURLSizesMap());
delete this;
}

Powered by Google App Engine
This is Rietveld 408576698