OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/bind.h" | 9 #include "base/bind.h" |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
11 #include "base/memory/ptr_util.h" | 11 #include "base/memory/ptr_util.h" |
12 #include "base/message_loop/message_loop.h" | 12 #include "base/message_loop/message_loop.h" |
13 #include "base/strings/sys_string_conversions.h" | 13 #include "base/strings/sys_string_conversions.h" |
14 #include "base/threading/thread.h" | 14 #include "base/threading/thread.h" |
15 #include "ui/gfx/image/image_skia.h" | 15 #include "ui/gfx/image/image_skia.h" |
16 #include "ui/gfx/image/image_skia_util_mac.h" | 16 #include "ui/gfx/image/image_skia_util_mac.h" |
17 | 17 |
18 // static | 18 // static |
19 IconLoader::IconGroup IconLoader::GroupForFilepath( | 19 IconLoader::IconGroup IconLoader::GroupForFilepath( |
20 const base::FilePath& file_path) { | 20 const base::FilePath& file_path) { |
21 return file_path.Extension(); | 21 return file_path.Extension(); |
22 } | 22 } |
23 | 23 |
24 // static | 24 // static |
25 content::BrowserThread::ID IconLoader::ReadIconThreadID() { | 25 bool IconLoader::ReadIconRequiresUIThread() { |
26 return content::BrowserThread::FILE; | 26 return false; |
27 } | 27 } |
28 | 28 |
29 void IconLoader::ReadIcon() { | 29 void IconLoader::ReadIcon() { |
30 NSString* group = base::SysUTF8ToNSString(group_); | 30 NSString* group = base::SysUTF8ToNSString(group_); |
31 NSWorkspace* workspace = [NSWorkspace sharedWorkspace]; | 31 NSWorkspace* workspace = [NSWorkspace sharedWorkspace]; |
32 NSImage* icon = [workspace iconForFileType:group]; | 32 NSImage* icon = [workspace iconForFileType:group]; |
33 | 33 |
34 std::unique_ptr<gfx::Image> image; | 34 std::unique_ptr<gfx::Image> image; |
35 | 35 |
36 if (icon_size_ == ALL) { | 36 if (icon_size_ == ALL) { |
(...skipping 15 matching lines...) Expand all Loading... |
52 if (!image_skia.isNull()) { | 52 if (!image_skia.isNull()) { |
53 image_skia.MakeThreadSafe(); | 53 image_skia.MakeThreadSafe(); |
54 image = base::MakeUnique<gfx::Image>(image_skia); | 54 image = base::MakeUnique<gfx::Image>(image_skia); |
55 } | 55 } |
56 } | 56 } |
57 | 57 |
58 target_task_runner_->PostTask( | 58 target_task_runner_->PostTask( |
59 FROM_HERE, base::Bind(callback_, base::Passed(&image), group_)); | 59 FROM_HERE, base::Bind(callback_, base::Passed(&image), group_)); |
60 delete this; | 60 delete this; |
61 } | 61 } |
OLD | NEW |