| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/extensions/extension_app_icon_loader.h" | 5 #include "chrome/browser/extensions/extension_app_icon_loader.h" |
| 6 | 6 |
| 7 #include "base/stl_util.h" | 7 #include "base/stl_util.h" |
| 8 #include "chrome/browser/extensions/extension_service.h" | 8 #include "chrome/browser/extensions/extension_service.h" |
| 9 #include "chrome/browser/extensions/extension_util.h" | 9 #include "chrome/browser/extensions/extension_util.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 } | 47 } |
| 48 | 48 |
| 49 void ExtensionAppIconLoader::FetchImage(const std::string& id) { | 49 void ExtensionAppIconLoader::FetchImage(const std::string& id) { |
| 50 if (map_.find(id) != map_.end()) | 50 if (map_.find(id) != map_.end()) |
| 51 return; // Already loading the image. | 51 return; // Already loading the image. |
| 52 | 52 |
| 53 const extensions::Extension* extension = GetExtensionByID(profile(), id); | 53 const extensions::Extension* extension = GetExtensionByID(profile(), id); |
| 54 if (!extension) | 54 if (!extension) |
| 55 return; | 55 return; |
| 56 | 56 |
| 57 scoped_ptr<extensions::IconImage> image(new extensions::IconImage( | 57 std::unique_ptr<extensions::IconImage> image(new extensions::IconImage( |
| 58 profile(), | 58 profile(), extension, extensions::IconsInfo::GetIcons(extension), |
| 59 extension, | 59 icon_size(), extensions::util::GetDefaultAppIcon(), this)); |
| 60 extensions::IconsInfo::GetIcons(extension), | |
| 61 icon_size(), | |
| 62 extensions::util::GetDefaultAppIcon(), | |
| 63 this)); | |
| 64 | 60 |
| 65 // Triggers image loading now instead of depending on paint message. This | 61 // Triggers image loading now instead of depending on paint message. This |
| 66 // makes the temp blank image be shown for shorter time and improves user | 62 // makes the temp blank image be shown for shorter time and improves user |
| 67 // experience. See http://crbug.com/146114. | 63 // experience. See http://crbug.com/146114. |
| 68 image->image_skia().EnsureRepsForSupportedScales(); | 64 image->image_skia().EnsureRepsForSupportedScales(); |
| 69 map_[id] = std::move(image); | 65 map_[id] = std::move(image); |
| 70 } | 66 } |
| 71 | 67 |
| 72 void ExtensionAppIconLoader::ClearImage(const std::string& id) { | 68 void ExtensionAppIconLoader::ClearImage(const std::string& id) { |
| 73 map_.erase(id); | 69 map_.erase(id); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 98 | 94 |
| 99 if (!util::IsAppLaunchable(id, profile())) { | 95 if (!util::IsAppLaunchable(id, profile())) { |
| 100 const color_utils::HSL shift = {-1, 0, 0.6}; | 96 const color_utils::HSL shift = {-1, 0, 0.6}; |
| 101 image = gfx::ImageSkiaOperations::CreateHSLShiftedImage(image, shift); | 97 image = gfx::ImageSkiaOperations::CreateHSLShiftedImage(image, shift); |
| 102 } | 98 } |
| 103 | 99 |
| 104 delegate()->OnAppImageUpdated(id, image); | 100 delegate()->OnAppImageUpdated(id, image); |
| 105 } | 101 } |
| 106 | 102 |
| 107 } // namespace extensions | 103 } // namespace extensions |
| OLD | NEW |