#include "extensions/browser/image_loader.h"
#include <stddef.h>
#include <map>
#include <utility>
#include <vector>
#include "base/compiler_specific.h"
#include "base/files/file_util.h"
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/strings/string_number_conversions.h"
#include "base/task/thread_pool.h"
#include "content/public/browser/browser_thread.h"
#include "extensions/browser/component_extension_resource_manager.h"
#include "extensions/browser/extensions_browser_client.h"
#include "extensions/browser/image_loader_factory.h"
#include "extensions/common/extension.h"
#include "extensions/common/manifest_handlers/icons_handler.h"
#include "skia/ext/image_operations.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/base/resource/resource_scale_factor.h"
#include "ui/display/display.h"
#include "ui/display/screen.h"
#include "ui/gfx/codec/png_codec.h"
#include "ui/gfx/image/image_family.h"
#include "ui/gfx/image/image_skia.h"
#include "ui/gfx/image/image_skia_rep.h"
BrowserThread;
namespace extensions {
namespace {
bool ShouldResizeImageRepresentation(
ImageLoader::ImageRepresentation::ResizeCondition resize_method,
const gfx::Size& decoded_size,
const gfx::Size& desired_size) { … }
SkBitmap ResizeIfNeeded(const SkBitmap& bitmap,
const ImageLoader::ImageRepresentation& image_info) { … }
void LoadResourceOnUIThread(int resource_id, SkBitmap* bitmap) { … }
void LoadImageBlocking(const ImageLoader::ImageRepresentation& image_info,
SkBitmap* bitmap) { … }
std::vector<SkBitmap> LoadResourceBitmaps(
const Extension* extension,
const std::vector<ImageLoader::ImageRepresentation>& info_list) { … }
}
ImageLoader::ImageRepresentation::ImageRepresentation(
const ExtensionResource& resource,
ResizeCondition resize_condition,
const gfx::Size& desired_size,
float scale_factor)
: … { … }
ImageLoader::ImageRepresentation::~ImageRepresentation() { … }
struct ImageLoader::LoadResult { … };
ImageLoader::LoadResult::LoadResult(
const SkBitmap& bitmap,
const gfx::Size& original_size,
const ImageLoader::ImageRepresentation& image_representation)
: … { … }
ImageLoader::LoadResult::~LoadResult() { … }
namespace {
std::vector<ImageLoader::LoadResult> LoadImagesBlocking(
const std::vector<ImageLoader::ImageRepresentation>& info_list,
const std::vector<SkBitmap>& bitmaps) { … }
}
ImageLoader::ImageLoader() = default;
ImageLoader::~ImageLoader() { … }
ImageLoader* ImageLoader::Get(content::BrowserContext* context) { … }
void ImageLoader::LoadImageAsync(const Extension* extension,
const ExtensionResource& resource,
const gfx::Size& max_size,
ImageLoaderImageCallback callback) { … }
void ImageLoader::LoadImageAtEveryScaleFactorAsync(
const Extension* extension,
const gfx::Size& dip_size,
ImageLoaderImageCallback callback) { … }
void ImageLoader::LoadImagesAsync(
const Extension* extension,
const std::vector<ImageRepresentation>& info_list,
ImageLoaderImageCallback callback) { … }
void ImageLoader::LoadImageFamilyAsync(
const Extension* extension,
const std::vector<ImageRepresentation>& info_list,
ImageLoaderImageFamilyCallback callback) { … }
void ImageLoader::ReplyBack(ImageLoaderImageCallback callback,
const std::vector<LoadResult>& load_result) { … }
void ImageLoader::ReplyBackWithImageFamily(
ImageLoaderImageFamilyCallback callback,
const std::vector<LoadResult>& load_result) { … }
}