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 #include <windows.h> | 7 #include <windows.h> |
8 #include <shellapi.h> | 8 #include <shellapi.h> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.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/task_scheduler/post_task.h" |
13 #include "base/threading/thread.h" | 14 #include "base/threading/thread.h" |
14 #include "third_party/skia/include/core/SkBitmap.h" | 15 #include "third_party/skia/include/core/SkBitmap.h" |
15 #include "ui/display/win/dpi.h" | 16 #include "ui/display/win/dpi.h" |
16 #include "ui/gfx/geometry/size.h" | 17 #include "ui/gfx/geometry/size.h" |
17 #include "ui/gfx/icon_util.h" | 18 #include "ui/gfx/icon_util.h" |
18 #include "ui/gfx/image/image_skia.h" | 19 #include "ui/gfx/image/image_skia.h" |
19 | 20 |
20 // static | 21 // static |
21 IconLoader::IconGroup IconLoader::GroupForFilepath( | 22 IconLoader::IconGroup IconLoader::GroupForFilepath( |
22 const base::FilePath& file_path) { | 23 const base::FilePath& file_path) { |
23 if (file_path.MatchesExtension(L".exe") || | 24 if (file_path.MatchesExtension(L".exe") || |
24 file_path.MatchesExtension(L".dll") || | 25 file_path.MatchesExtension(L".dll") || |
25 file_path.MatchesExtension(L".ico")) { | 26 file_path.MatchesExtension(L".ico")) { |
26 return file_path.value(); | 27 return file_path.value(); |
27 } | 28 } |
28 | 29 |
29 return file_path.Extension(); | 30 return file_path.Extension(); |
30 } | 31 } |
31 | 32 |
32 // static | 33 // static |
33 content::BrowserThread::ID IconLoader::ReadIconThreadID() { | 34 scoped_refptr<base::TaskRunner> IconLoader::GetReadIconTaskRunner() { |
34 return content::BrowserThread::FILE; | 35 // Technically speaking, only a thread with COM is needed, not one that has |
| 36 // a COM STA. However, this is what is available for now. |
| 37 return base::CreateCOMSTATaskRunnerWithTraits(traits()); |
35 } | 38 } |
36 | 39 |
37 void IconLoader::ReadIcon() { | 40 void IconLoader::ReadIcon() { |
38 int size = 0; | 41 int size = 0; |
39 switch (icon_size_) { | 42 switch (icon_size_) { |
40 case IconLoader::SMALL: | 43 case IconLoader::SMALL: |
41 size = SHGFI_SMALLICON; | 44 size = SHGFI_SMALLICON; |
42 break; | 45 break; |
43 case IconLoader::NORMAL: | 46 case IconLoader::NORMAL: |
44 size = 0; | 47 size = 0; |
(...skipping 19 matching lines...) Expand all Loading... |
64 image_skia.MakeThreadSafe(); | 67 image_skia.MakeThreadSafe(); |
65 image = base::MakeUnique<gfx::Image>(image_skia); | 68 image = base::MakeUnique<gfx::Image>(image_skia); |
66 DestroyIcon(file_info.hIcon); | 69 DestroyIcon(file_info.hIcon); |
67 } | 70 } |
68 } | 71 } |
69 | 72 |
70 target_task_runner_->PostTask( | 73 target_task_runner_->PostTask( |
71 FROM_HERE, base::Bind(callback_, base::Passed(&image), group_)); | 74 FROM_HERE, base::Bind(callback_, base::Passed(&image), group_)); |
72 delete this; | 75 delete this; |
73 } | 76 } |
OLD | NEW |