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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 #include <string> | 10 #include <string> |
11 #include <utility> | 11 #include <utility> |
12 | 12 |
13 #include "base/bind.h" | 13 #include "base/bind.h" |
14 #include "base/files/file_path.h" | 14 #include "base/files/file_path.h" |
15 #include "base/lazy_instance.h" | 15 #include "base/lazy_instance.h" |
16 #include "base/macros.h" | 16 #include "base/macros.h" |
17 #include "base/memory/ref_counted_memory.h" | 17 #include "base/memory/ref_counted_memory.h" |
18 #include "base/message_loop/message_loop.h" | 18 #include "base/message_loop/message_loop.h" |
19 #include "base/strings/string_util.h" | 19 #include "base/strings/string_util.h" |
20 #include "chrome/grit/theme_resources.h" | 20 #include "chrome/grit/theme_resources.h" |
21 #include "media/media_features.h" | |
22 #include "third_party/skia/include/core/SkBitmap.h" | 21 #include "third_party/skia/include/core/SkBitmap.h" |
23 #include "ui/base/layout.h" | 22 #include "ui/base/layout.h" |
24 #include "ui/base/resource/resource_bundle.h" | 23 #include "ui/base/resource/resource_bundle.h" |
25 #include "ui/gfx/canvas.h" | 24 #include "ui/gfx/canvas.h" |
26 #include "ui/gfx/codec/png_codec.h" | 25 #include "ui/gfx/codec/png_codec.h" |
27 #include "ui/gfx/image/image.h" | 26 #include "ui/gfx/image/image.h" |
28 #include "ui/gfx/image/image_skia.h" | 27 #include "ui/gfx/image/image_skia.h" |
29 #include "ui/gfx/image/image_skia_operations.h" | 28 #include "ui/gfx/image/image_skia_operations.h" |
30 | 29 |
31 namespace { | 30 namespace { |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 const IdrBySize kGenericIdrs = { | 63 const IdrBySize kGenericIdrs = { |
65 IDR_FILETYPE_GENERIC, | 64 IDR_FILETYPE_GENERIC, |
66 IDR_FILETYPE_LARGE_GENERIC, | 65 IDR_FILETYPE_LARGE_GENERIC, |
67 IDR_FILETYPE_LARGE_GENERIC | 66 IDR_FILETYPE_LARGE_GENERIC |
68 }; | 67 }; |
69 const IdrBySize kImageIdrs = { | 68 const IdrBySize kImageIdrs = { |
70 IDR_FILETYPE_IMAGE, | 69 IDR_FILETYPE_IMAGE, |
71 IDR_FILETYPE_IMAGE, | 70 IDR_FILETYPE_IMAGE, |
72 IDR_FILETYPE_IMAGE | 71 IDR_FILETYPE_IMAGE |
73 }; | 72 }; |
74 #if BUILDFLAG(USE_PROPRIETARY_CODECS) | 73 #if defined(USE_PROPRIETARY_CODECS) |
75 const IdrBySize kPdfIdrs = { | 74 const IdrBySize kPdfIdrs = { |
76 IDR_FILETYPE_PDF, | 75 IDR_FILETYPE_PDF, |
77 IDR_FILETYPE_PDF, | 76 IDR_FILETYPE_PDF, |
78 IDR_FILETYPE_PDF | 77 IDR_FILETYPE_PDF |
79 }; | 78 }; |
80 #endif | 79 #endif |
81 const IdrBySize kVideoIdrs = { | 80 const IdrBySize kVideoIdrs = { |
82 IDR_FILETYPE_VIDEO, | 81 IDR_FILETYPE_VIDEO, |
83 IDR_FILETYPE_LARGE_VIDEO, | 82 IDR_FILETYPE_LARGE_VIDEO, |
84 IDR_FILETYPE_LARGE_VIDEO | 83 IDR_FILETYPE_LARGE_VIDEO |
85 }; | 84 }; |
86 | 85 |
87 IconMapper::IconMapper() { | 86 IconMapper::IconMapper() { |
88 // The code below should match translation in | 87 // The code below should match translation in |
89 // ui/file_manager/file_manager/js/file_manager.js | 88 // ui/file_manager/file_manager/js/file_manager.js |
90 // ui/file_manager/file_manager/css/file_manager.css | 89 // ui/file_manager/file_manager/css/file_manager.css |
91 // 'audio': /\.(mp3|m4a|oga|ogg|wav)$/i, | 90 // 'audio': /\.(mp3|m4a|oga|ogg|wav)$/i, |
92 // 'html': /\.(html?)$/i, | 91 // 'html': /\.(html?)$/i, |
93 // 'image': /\.(bmp|gif|jpe?g|ico|png|webp)$/i, | 92 // 'image': /\.(bmp|gif|jpe?g|ico|png|webp)$/i, |
94 // 'pdf' : /\.(pdf)$/i, | 93 // 'pdf' : /\.(pdf)$/i, |
95 // 'text': /\.(pod|rst|txt|log)$/i, | 94 // 'text': /\.(pod|rst|txt|log)$/i, |
96 // 'video': /\.(mov|mp4|m4v|mpe?g4?|ogm|ogv|ogx|webm)$/i | 95 // 'video': /\.(mov|mp4|m4v|mpe?g4?|ogm|ogv|ogx|webm)$/i |
97 | 96 |
98 const ExtensionIconMap::value_type kExtensionIdrBySizeData[] = { | 97 const ExtensionIconMap::value_type kExtensionIdrBySizeData[] = { |
99 #if BUILDFLAG(USE_PROPRIETARY_CODECS) | 98 #if defined(USE_PROPRIETARY_CODECS) |
100 std::make_pair(".m4a", kAudioIdrs), | 99 std::make_pair(".m4a", kAudioIdrs), |
101 std::make_pair(".mp3", kAudioIdrs), | 100 std::make_pair(".mp3", kAudioIdrs), |
102 std::make_pair(".pdf", kPdfIdrs), | 101 std::make_pair(".pdf", kPdfIdrs), |
103 std::make_pair(".3gp", kVideoIdrs), | 102 std::make_pair(".3gp", kVideoIdrs), |
104 std::make_pair(".avi", kVideoIdrs), | 103 std::make_pair(".avi", kVideoIdrs), |
105 std::make_pair(".m4v", kVideoIdrs), | 104 std::make_pair(".m4v", kVideoIdrs), |
106 std::make_pair(".mov", kVideoIdrs), | 105 std::make_pair(".mov", kVideoIdrs), |
107 std::make_pair(".mp4", kVideoIdrs), | 106 std::make_pair(".mp4", kVideoIdrs), |
108 std::make_pair(".mpeg", kVideoIdrs), | 107 std::make_pair(".mpeg", kVideoIdrs), |
109 std::make_pair(".mpg", kVideoIdrs), | 108 std::make_pair(".mpg", kVideoIdrs), |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 LAZY_INSTANCE_INITIALIZER; | 203 LAZY_INSTANCE_INITIALIZER; |
205 int idr = icon_mapper.Get().Lookup(group_, icon_size_); | 204 int idr = icon_mapper.Get().Lookup(group_, icon_size_); |
206 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 205 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
207 gfx::ImageSkia image_skia(ResizeImage(*(rb.GetImageNamed(idr)).ToImageSkia(), | 206 gfx::ImageSkia image_skia(ResizeImage(*(rb.GetImageNamed(idr)).ToImageSkia(), |
208 IconSizeToDIPSize(icon_size_))); | 207 IconSizeToDIPSize(icon_size_))); |
209 image_skia.MakeThreadSafe(); | 208 image_skia.MakeThreadSafe(); |
210 image_.reset(new gfx::Image(image_skia)); | 209 image_.reset(new gfx::Image(image_skia)); |
211 target_task_runner_->PostTask( | 210 target_task_runner_->PostTask( |
212 FROM_HERE, base::Bind(&IconLoader::NotifyDelegate, this)); | 211 FROM_HERE, base::Bind(&IconLoader::NotifyDelegate, this)); |
213 } | 212 } |
OLD | NEW |