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

Side by Side Diff: chrome/browser/icon_loader_mac.mm

Issue 6995068: Mac: Fix icons in download dom UI (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix linux build Created 9 years, 6 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/icon_loader.h" 5 #include "chrome/browser/icon_loader.h"
6 6
7 #import <AppKit/AppKit.h> 7 #import <AppKit/AppKit.h>
8 8
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/threading/thread.h" 10 #include "base/threading/thread.h"
11 #include "base/sys_string_conversions.h" 11 #include "base/sys_string_conversions.h"
12 #include "skia/ext/skia_utils_mac.h" 12 #include "skia/ext/skia_utils_mac.h"
13 #include "third_party/skia/include/core/SkBitmap.h" 13 #include "third_party/skia/include/core/SkBitmap.h"
14 14
15 void IconLoader::ReadIcon() { 15 void IconLoader::ReadIcon() {
16 NSString* group = base::SysUTF8ToNSString(group_); 16 NSString* group = base::SysUTF8ToNSString(group_);
17 NSWorkspace* workspace = [NSWorkspace sharedWorkspace]; 17 NSWorkspace* workspace = [NSWorkspace sharedWorkspace];
18 NSImage* icon = [workspace iconForFileType:group]; 18 NSImage* icon = [workspace iconForFileType:group];
19 19
20 // Mac will ignore the size because icons have multiple size representations 20 if (icon_size_ == ALL) {
21 // and NSImage choses the best at draw-time. 21 // The NSImage already has all sizes.
22 image_.reset(new gfx::Image([icon retain])); 22 image_.reset(new gfx::Image([icon retain]));
23 } else {
24 NSSize size = NSZeroSize;
25 switch (icon_size_) {
26 case IconLoader::SMALL:
27 size = NSMakeSize(16, 16);
28 break;
29 case IconLoader::NORMAL:
30 size = NSMakeSize(32, 32);
31 break;
32 default:
33 NOTREACHED();
34 }
35 image_.reset(new gfx::Image(new SkBitmap(
36 gfx::NSImageToSkBitmap(icon, size, false))));
37 }
23 38
24 target_message_loop_->PostTask(FROM_HERE, 39 target_message_loop_->PostTask(FROM_HERE,
25 NewRunnableMethod(this, &IconLoader::NotifyDelegate)); 40 NewRunnableMethod(this, &IconLoader::NotifyDelegate));
26 } 41 }
OLDNEW
« no previous file with comments | « chrome/browser/icon_loader_linux.cc ('k') | chrome/browser/ui/cocoa/download/download_item_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698