1 // Copyright 2013 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chrome/browser/icon_loader.h"
7 #include "base/functional/bind.h"
8 #include "base/nix/mime_util_xdg.h"
9 #include "content/public/browser/browser_task_traits.h"
10 #include "content/public/browser/browser_thread.h"
11 #include "ui/linux/linux_ui.h"
14 IconLoader::IconGroup IconLoader::GroupForFilepath(
15 const base::FilePath& file_path) {
16 return base::nix::GetFileMimeType(file_path);
20 scoped_refptr<base::TaskRunner> IconLoader::GetReadIconTaskRunner() {
21 // ReadIcon() calls into ui::LinuxUi and GTK code, so it must be on the UI
23 return content::GetUIThreadTaskRunner({});
26 void IconLoader::ReadIcon() {
29 case IconLoader::SMALL:
32 case IconLoader::NORMAL:
35 case IconLoader::LARGE:
43 ui::LinuxUi* ui = ui::LinuxUi::instance();
45 image = ui->GetIconForContentType(group_, size_pixels, scale_);
48 target_task_runner_->PostTask(
50 base::BindOnce(std::move(callback_), std::move(image), group_));