[M120 Migration]Fix for crash during chrome exit
[platform/framework/web/chromium-efl.git] / chrome / browser / icon_loader_chromeos.cc
1 // Copyright 2012 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.
4
5 #include "chrome/browser/icon_loader.h"
6
7 #include "base/strings/string_util.h"
8 #include "chromeos/ui/base/file_icon_util.h"
9 #include "ui/gfx/image/image.h"
10 #include "ui/gfx/image/image_skia.h"
11
12 // static
13 IconLoader::IconGroup IconLoader::GroupForFilepath(
14     const base::FilePath& file_path) {
15   return base::ToLowerASCII(file_path.Extension());
16 }
17
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_));
38   delete this;
39 }