summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/icon_loader.h3
-rw-r--r--chrome/browser/icon_loader_linux.cc20
-rw-r--r--chrome/browser/icon_loader_mac.mm21
-rw-r--r--chrome/browser/ui/cocoa/download/download_item_mac.mm4
4 files changed, 36 insertions, 12 deletions
diff --git a/chrome/browser/icon_loader.h b/chrome/browser/icon_loader.h
index 0b6cf25..8e1f15a 100644
--- a/chrome/browser/icon_loader.h
+++ b/chrome/browser/icon_loader.h
@@ -40,7 +40,8 @@ class IconLoader : public base::RefCountedThreadSafe<IconLoader> {
enum IconSize {
SMALL = 0, // 16x16
NORMAL, // 32x32
- LARGE
+ LARGE, // Windows: 32x32, Linux: 48x48, Mac: Unsupported
+ ALL, // All sizes available
};
class Delegate {
diff --git a/chrome/browser/icon_loader_linux.cc b/chrome/browser/icon_loader_linux.cc
index ce8eade..c5b0423 100644
--- a/chrome/browser/icon_loader_linux.cc
+++ b/chrome/browser/icon_loader_linux.cc
@@ -16,12 +16,20 @@
#include "base/string_util.h"
static int SizeToInt(IconLoader::IconSize size) {
- int pixels = 48;
- if (size == IconLoader::NORMAL)
- pixels = 32;
- else if (size == IconLoader::SMALL)
- pixels = 16;
-
+ int pixels = 0;
+ switch (size) {
+ case IconLoader::SMALL:
+ pixels = 16;
+ break;
+ case IconLoader::NORMAL:
+ pixels = 32;
+ break;
+ case IconLoader::LARGE:
+ pixels = 48;
+ break;
+ default:
+ NOTREACHED();
+ }
return pixels;
}
diff --git a/chrome/browser/icon_loader_mac.mm b/chrome/browser/icon_loader_mac.mm
index 9b26ff3..8502a7d 100644
--- a/chrome/browser/icon_loader_mac.mm
+++ b/chrome/browser/icon_loader_mac.mm
@@ -17,9 +17,24 @@ void IconLoader::ReadIcon() {
NSWorkspace* workspace = [NSWorkspace sharedWorkspace];
NSImage* icon = [workspace iconForFileType:group];
- // Mac will ignore the size because icons have multiple size representations
- // and NSImage choses the best at draw-time.
- image_.reset(new gfx::Image([icon retain]));
+ if (icon_size_ == ALL) {
+ // The NSImage already has all sizes.
+ image_.reset(new gfx::Image([icon retain]));
+ } else {
+ NSSize size = NSZeroSize;
+ switch (icon_size_) {
+ case IconLoader::SMALL:
+ size = NSMakeSize(16, 16);
+ break;
+ case IconLoader::NORMAL:
+ size = NSMakeSize(32, 32);
+ break;
+ default:
+ NOTREACHED();
+ }
+ image_.reset(new gfx::Image(new SkBitmap(
+ gfx::NSImageToSkBitmap(icon, size, false))));
+ }
target_message_loop_->PostTask(FROM_HERE,
NewRunnableMethod(this, &IconLoader::NotifyDelegate));
diff --git a/chrome/browser/ui/cocoa/download/download_item_mac.mm b/chrome/browser/ui/cocoa/download/download_item_mac.mm
index 0297ab4..9b47e8d 100644
--- a/chrome/browser/ui/cocoa/download/download_item_mac.mm
+++ b/chrome/browser/ui/cocoa/download/download_item_mac.mm
@@ -79,14 +79,14 @@ void DownloadItemMac::LoadIcon() {
// We may already have this particular image cached.
FilePath file = download_model_->download()->GetUserVerifiedFilePath();
- gfx::Image* icon = icon_manager->LookupIcon(file, IconLoader::SMALL);
+ gfx::Image* icon = icon_manager->LookupIcon(file, IconLoader::ALL);
if (icon) {
[item_controller_ setIcon:*icon];
return;
}
// The icon isn't cached, load it asynchronously.
- icon_manager->LoadIcon(file, IconLoader::SMALL, &icon_consumer_,
+ icon_manager->LoadIcon(file, IconLoader::ALL, &icon_consumer_,
NewCallback(this,
&DownloadItemMac::OnExtractIconComplete));
}