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

Unified Diff: chrome/browser/ui/cocoa/history_menu_bridge.mm

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/ui/cocoa/history_menu_bridge.mm
diff --git a/chrome/browser/ui/cocoa/history_menu_bridge.mm b/chrome/browser/ui/cocoa/history_menu_bridge.mm
index 6c55a9e28def1eca22f94e35d5b2d3a664298d4f..2f73278b66b652b8b5bca6a399cfcf3a30845c94 100644
--- a/chrome/browser/ui/cocoa/history_menu_bridge.mm
+++ b/chrome/browser/ui/cocoa/history_menu_bridge.mm
@@ -31,6 +31,7 @@
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/gfx/codec/png_codec.h"
+#include "ui/gfx/favicon_size.h"
#include "ui/gfx/image/image.h"
#include "ui/gfx/mac/nsimage_cache.h"
@@ -454,16 +455,18 @@ HistoryMenuBridge::HistoryItem* HistoryMenuBridge::HistoryItemForTab(
void HistoryMenuBridge::GetFaviconForHistoryItem(HistoryItem* item) {
FaviconService* service =
FaviconServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS);
- FaviconService::Handle handle = service->GetFaviconForURL(
- profile_, item->url, history::FAVICON, &favicon_consumer_,
+ FaviconService::Handle handle = service->GetFaviconImageForURL(
+ profile_, item->url, history::FAVICON, gfx::kFaviconSize,
+ &favicon_consumer_,
base::Bind(&HistoryMenuBridge::GotFaviconData, base::Unretained(this)));
favicon_consumer_.SetClientData(service, handle, item);
item->icon_handle = handle;
item->icon_requested = true;
}
-void HistoryMenuBridge::GotFaviconData(FaviconService::Handle handle,
- history::FaviconData favicon) {
+void HistoryMenuBridge::GotFaviconData(
+ FaviconService::Handle handle,
+ const history::FaviconImageResult& image_result) {
// Since we're going to do Cocoa-y things, make sure this is the main thread.
DCHECK([NSThread isMainThread]);
@@ -475,18 +478,10 @@ void HistoryMenuBridge::GotFaviconData(FaviconService::Handle handle,
item->icon_requested = false;
item->icon_handle = 0;
- // Convert the raw data to Skia and then to a NSImage.
- // TODO(rsesek): Is there an easier way to do this?
- SkBitmap icon;
- if (favicon.is_valid() &&
- gfx::PNGCodec::Decode(favicon.image_data->front(),
- favicon.image_data->size(), &icon)) {
- NSImage* image = gfx::SkBitmapToNSImage(icon);
- if (image) {
- // The conversion was successful.
- item->icon.reset([image retain]);
- [item->menu_item setImage:item->icon.get()];
- }
+ NSImage* image = image_result.image.AsNSImage();
+ if (image) {
+ item->icon.reset([image retain]);
+ [item->menu_item setImage:item->icon.get()];
}
}

Powered by Google App Engine
This is Rietveld 408576698