blob: a4000903bed2aa76624f96fe3dff017251e09754 [file] [log] [blame]
Avi Drissman4a8573c2022-09-09 19:35:541// Copyright 2012 The Chromium Authors
[email protected]25cc7502012-01-31 19:33:552// 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]9c7ddc92013-06-11 01:40:577#include "base/strings/string_util.h"
Evan Stade91b50f52022-02-14 17:09:578#include "chromeos/ui/base/file_icon_util.h"
[email protected]25cc7502012-01-31 19:33:559#include "ui/gfx/image/image.h"
[email protected]2b8ac342012-08-29 03:46:2710#include "ui/gfx/image/image_skia.h"
[email protected]25cc7502012-01-31 19:33:5511
[email protected]bc0147b2013-04-03 20:50:5912// static
avi381f719f2016-12-16 00:05:0213IconLoader::IconGroup IconLoader::GroupForFilepath(
14 const base::FilePath& file_path) {
15 return base::ToLowerASCII(file_path.Extension());
[email protected]681b4b82013-04-09 23:34:2116}
17
Evan Stade91b50f52022-02-14 17:09:5718// The Chrome OS implementation doesn't use an I/O thread because vector icons
19// are created on the UI thread.
20void 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_));
avif0a7b5b812016-12-17 19:01:3138 delete this;
[email protected]25cc7502012-01-31 19:33:5539}