| 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/ptr_util.h" |
| 17 #include "base/memory/ref_counted_memory.h" | 18 #include "base/memory/ref_counted_memory.h" |
| 18 #include "base/message_loop/message_loop.h" | 19 #include "base/message_loop/message_loop.h" |
| 19 #include "base/strings/string_util.h" | 20 #include "base/strings/string_util.h" |
| 20 #include "chrome/grit/theme_resources.h" | 21 #include "chrome/grit/theme_resources.h" |
| 21 #include "media/media_features.h" | 22 #include "media/media_features.h" |
| 22 #include "third_party/skia/include/core/SkBitmap.h" | 23 #include "third_party/skia/include/core/SkBitmap.h" |
| 23 #include "ui/base/layout.h" | 24 #include "ui/base/layout.h" |
| 24 #include "ui/base/resource/resource_bundle.h" | 25 #include "ui/base/resource/resource_bundle.h" |
| 25 #include "ui/gfx/canvas.h" | 26 #include "ui/gfx/canvas.h" |
| 26 #include "ui/gfx/codec/png_codec.h" | 27 #include "ui/gfx/codec/png_codec.h" |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 } | 196 } |
| 196 | 197 |
| 197 void IconLoader::ReadIcon() { | 198 void IconLoader::ReadIcon() { |
| 198 static base::LazyInstance<IconMapper>::Leaky icon_mapper = | 199 static base::LazyInstance<IconMapper>::Leaky icon_mapper = |
| 199 LAZY_INSTANCE_INITIALIZER; | 200 LAZY_INSTANCE_INITIALIZER; |
| 200 int idr = icon_mapper.Get().Lookup(group_, icon_size_); | 201 int idr = icon_mapper.Get().Lookup(group_, icon_size_); |
| 201 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 202 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
| 202 gfx::ImageSkia image_skia(ResizeImage(*(rb.GetImageNamed(idr)).ToImageSkia(), | 203 gfx::ImageSkia image_skia(ResizeImage(*(rb.GetImageNamed(idr)).ToImageSkia(), |
| 203 IconSizeToDIPSize(icon_size_))); | 204 IconSizeToDIPSize(icon_size_))); |
| 204 image_skia.MakeThreadSafe(); | 205 image_skia.MakeThreadSafe(); |
| 205 image_.reset(new gfx::Image(image_skia)); | 206 std::unique_ptr<gfx::Image> image = base::MakeUnique<gfx::Image>(image_skia); |
| 206 target_task_runner_->PostTask( | 207 target_task_runner_->PostTask( |
| 207 FROM_HERE, base::Bind(callback_, base::Passed(&image_), group_)); | 208 FROM_HERE, base::Bind(callback_, base::Passed(&image), group_)); |
| 208 delete this; | 209 delete this; |
| 209 } | 210 } |
| OLD | NEW |