Avi Drissman | 4a8573c | 2022-09-09 19:35:54 | [diff] [blame] | 1 | // Copyright 2012 The Chromium Authors |
[email protected] | 25cc750 | 2012-01-31 19:33:55 | [diff] [blame] | 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] | 9c7ddc9 | 2013-06-11 01:40:57 | [diff] [blame] | 7 | #include "base/strings/string_util.h" |
Evan Stade | 91b50f5 | 2022-02-14 17:09:57 | [diff] [blame] | 8 | #include "chromeos/ui/base/file_icon_util.h" |
[email protected] | 25cc750 | 2012-01-31 19:33:55 | [diff] [blame] | 9 | #include "ui/gfx/image/image.h" |
[email protected] | 2b8ac34 | 2012-08-29 03:46:27 | [diff] [blame] | 10 | #include "ui/gfx/image/image_skia.h" |
[email protected] | 25cc750 | 2012-01-31 19:33:55 | [diff] [blame] | 11 | |
[email protected] | bc0147b | 2013-04-03 20:50:59 | [diff] [blame] | 12 | // static |
avi | 381f719f | 2016-12-16 00:05:02 | [diff] [blame] | 13 | IconLoader::IconGroup IconLoader::GroupForFilepath( |
14 | const base::FilePath& file_path) { | ||||
15 | return base::ToLowerASCII(file_path.Extension()); | ||||
[email protected] | 681b4b8 | 2013-04-09 23:34:21 | [diff] [blame] | 16 | } |
17 | |||||
Evan Stade | 91b50f5 | 2022-02-14 17:09:57 | [diff] [blame] | 18 | // The Chrome OS implementation doesn't use an I/O thread because vector icons |
19 | // are created on the UI thread. | ||||
20 | void IconLoader::Start() { | ||||
21 | int dip_size = 0; | ||||
22 | switch (icon_size_) { | ||||
23 | case IconLoader::SMALL: | ||||
24 | dip_size = 16; | ||||
25 | break; | ||||
26 | case IconLoader::NORMAL: | ||||
27 | dip_size = 32; | ||||
28 | break; | ||||
29 | case IconLoader::LARGE: | ||||
30 | case IconLoader::ALL: | ||||
31 | dip_size = 48; | ||||
32 | break; | ||||
33 | } | ||||
34 | std::move(callback_).Run( | ||||
35 | gfx::Image(chromeos::GetIconForPath(file_path_, /*dark_background=*/false, | ||||
36 | dip_size)), | ||||
37 | GroupForFilepath(file_path_)); | ||||
avi | f0a7b5b81 | 2016-12-17 19:01:31 | [diff] [blame] | 38 | delete this; |
[email protected] | 25cc750 | 2012-01-31 19:33:55 | [diff] [blame] | 39 | } |