[email protected] | 0f38ceae | 2009-05-08 19:01:02 | [diff] [blame] | 1 | // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
2 | // Use of this source code is governed by a BSD-style license that can be | ||||
3 | // found in the LICENSE file. | ||||
4 | |||||
5 | #include "chrome/browser/icon_loader.h" | ||||
6 | |||||
[email protected] | 09c6dec | 2009-06-16 19:57:22 | [diff] [blame] | 7 | #import <AppKit/AppKit.h> |
8 | |||||
[email protected] | 0f38ceae | 2009-05-08 19:01:02 | [diff] [blame] | 9 | #include "base/message_loop.h" |
10 | #include "base/thread.h" | ||||
[email protected] | 09c6dec | 2009-06-16 19:57:22 | [diff] [blame] | 11 | #include "base/sys_string_conversions.h" |
12 | #include "skia/ext/skia_utils_mac.h" | ||||
13 | #include "third_party/skia/include/core/SkBitmap.h" | ||||
[email protected] | 0f38ceae | 2009-05-08 19:01:02 | [diff] [blame] | 14 | |
15 | void IconLoader::ReadIcon() { | ||||
[email protected] | 09c6dec | 2009-06-16 19:57:22 | [diff] [blame] | 16 | NSString* group = base::SysUTF8ToNSString(group_); |
17 | NSWorkspace* workspace = [NSWorkspace sharedWorkspace]; | ||||
18 | NSImage* icon = [workspace iconForFileType:group]; | ||||
19 | |||||
20 | NSSize size; | ||||
21 | if (icon_size_ == NORMAL) | ||||
22 | size = NSMakeSize(32, 32); | ||||
23 | else if (icon_size_ == SMALL) | ||||
24 | size = NSMakeSize(16, 16); | ||||
25 | else | ||||
26 | return; | ||||
27 | |||||
28 | bitmap_ = new SkBitmap(gfx::NSImageToSkBitmap(icon, size, false)); | ||||
[email protected] | 0f38ceae | 2009-05-08 19:01:02 | [diff] [blame] | 29 | |
30 | target_message_loop_->PostTask(FROM_HERE, | ||||
31 | NewRunnableMethod(this, &IconLoader::NotifyDelegate)); | ||||
32 | } |