| 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/extensions/extension_icon_manager.h" | 5 #include "chrome/browser/extensions/extension_icon_manager.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
| 10 #include "chrome/browser/extensions/image_loader.h" | 10 #include "chrome/browser/extensions/image_loader.h" |
| 11 #include "chrome/common/extensions/api/icons/icons_handler.h" |
| 11 #include "chrome/common/extensions/extension.h" | 12 #include "chrome/common/extensions/extension.h" |
| 12 #include "chrome/common/extensions/extension_constants.h" | 13 #include "chrome/common/extensions/extension_constants.h" |
| 13 #include "chrome/common/extensions/extension_icon_set.h" | 14 #include "chrome/common/extensions/extension_icon_set.h" |
| 14 #include "chrome/common/extensions/extension_resource.h" | 15 #include "chrome/common/extensions/extension_resource.h" |
| 15 #include "grit/theme_resources.h" | 16 #include "grit/theme_resources.h" |
| 16 #include "skia/ext/image_operations.h" | 17 #include "skia/ext/image_operations.h" |
| 17 #include "ui/base/resource/resource_bundle.h" | 18 #include "ui/base/resource/resource_bundle.h" |
| 18 #include "ui/gfx/canvas.h" | 19 #include "ui/gfx/canvas.h" |
| 19 #include "ui/gfx/color_utils.h" | 20 #include "ui/gfx/color_utils.h" |
| 20 #include "ui/gfx/favicon_size.h" | 21 #include "ui/gfx/favicon_size.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 46 ExtensionIconManager::ExtensionIconManager() | 47 ExtensionIconManager::ExtensionIconManager() |
| 47 : monochrome_(false), | 48 : monochrome_(false), |
| 48 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) { | 49 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) { |
| 49 } | 50 } |
| 50 | 51 |
| 51 ExtensionIconManager::~ExtensionIconManager() { | 52 ExtensionIconManager::~ExtensionIconManager() { |
| 52 } | 53 } |
| 53 | 54 |
| 54 void ExtensionIconManager::LoadIcon(Profile* profile, | 55 void ExtensionIconManager::LoadIcon(Profile* profile, |
| 55 const extensions::Extension* extension) { | 56 const extensions::Extension* extension) { |
| 56 ExtensionResource icon_resource = extension->GetIconResource( | 57 ExtensionResource icon_resource = extensions::IconsInfo::GetIconResource( |
| 57 extension_misc::EXTENSION_ICON_BITTY, ExtensionIconSet::MATCH_BIGGER); | 58 extension, |
| 59 extension_misc::EXTENSION_ICON_BITTY, |
| 60 ExtensionIconSet::MATCH_BIGGER); |
| 58 if (!icon_resource.extension_root().empty()) { | 61 if (!icon_resource.extension_root().empty()) { |
| 59 // Insert into pending_icons_ first because LoadImage can call us back | 62 // Insert into pending_icons_ first because LoadImage can call us back |
| 60 // synchronously if the image is already cached. | 63 // synchronously if the image is already cached. |
| 61 pending_icons_.insert(extension->id()); | 64 pending_icons_.insert(extension->id()); |
| 62 extensions::ImageLoader* loader = extensions::ImageLoader::Get(profile); | 65 extensions::ImageLoader* loader = extensions::ImageLoader::Get(profile); |
| 63 loader->LoadImageAsync(extension, icon_resource, | 66 loader->LoadImageAsync(extension, icon_resource, |
| 64 gfx::Size(gfx::kFaviconSize, gfx::kFaviconSize), | 67 gfx::Size(gfx::kFaviconSize, gfx::kFaviconSize), |
| 65 base::Bind( | 68 base::Bind( |
| 66 &ExtensionIconManager::OnImageLoaded, | 69 &ExtensionIconManager::OnImageLoaded, |
| 67 weak_ptr_factory_.GetWeakPtr(), | 70 weak_ptr_factory_.GetWeakPtr(), |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 if (monochrome_) { | 126 if (monochrome_) { |
| 124 color_utils::HSL shift = {-1, 0, 0.6}; | 127 color_utils::HSL shift = {-1, 0, 0.6}; |
| 125 result = SkBitmapOperations::CreateHSLShiftedBitmap(result, shift); | 128 result = SkBitmapOperations::CreateHSLShiftedBitmap(result, shift); |
| 126 } | 129 } |
| 127 | 130 |
| 128 if (!padding_.empty()) | 131 if (!padding_.empty()) |
| 129 result = ApplyPadding(result, padding_); | 132 result = ApplyPadding(result, padding_); |
| 130 | 133 |
| 131 return result; | 134 return result; |
| 132 } | 135 } |
| OLD | NEW |