#ifndef CHROME_BROWSER_APPS_APP_SERVICE_APP_ICON_APP_ICON_FACTORY_H_
#define CHROME_BROWSER_APPS_APP_SERVICE_APP_ICON_APP_ICON_FACTORY_H_
#include <map>
#include <string>
#include <vector>
#include "base/containers/span.h"
#include "base/files/file_path.h"
#include "base/functional/callback_forward.h"
#include "build/chromeos_buildflags.h"
#include "chrome/browser/web_applications/web_app_install_info.h"
#include "components/services/app_service/public/cpp/icon_effects.h"
#include "components/services/app_service/public/cpp/icon_types.h"
#include "ui/gfx/image/image_skia.h"
#if BUILDFLAG(IS_CHROMEOS)
#include "ui/base/resource/resource_scale_factor.h"
#endif
#if BUILDFLAG(IS_CHROMEOS_ASH)
#include "ash/components/arc/mojom/app.mojom-forward.h"
#include "ash/components/arc/mojom/intent_helper.mojom-forward.h"
#endif
namespace gfx {
class ImageSkia;
}
class Profile;
class SkBitmap;
namespace apps {
ScaleToSize;
static const int kInvalidIconResource = …;
std::map<std::pair<int, int>, gfx::ImageSkia>& GetResourceIconCache();
gfx::ImageSkia CreateResizedResourceImage(int icon_resource,
int32_t size_in_dip);
apps::ScaleToSize GetScaleToSize(const gfx::ImageSkia& image_skia);
void CompressedDataToSkBitmap(
base::span<const uint8_t> compressed_data,
base::OnceCallback<void(const SkBitmap&)> callback);
void CompressedDataToImageSkia(
base::span<const uint8_t> compressed_data,
float icon_scale,
base::OnceCallback<void(gfx::ImageSkia)> callback);
base::OnceCallback<void(std::vector<uint8_t> compressed_data)>
CompressedDataToImageSkiaCallback(
base::OnceCallback<void(gfx::ImageSkia)> callback,
float icon_scale);
gfx::ImageSkia SkBitmapToImageSkia(const SkBitmap& bitmap, float icon_scale);
std::vector<uint8_t> EncodeImageToPngBytes(const gfx::ImageSkia image,
float rep_icon_scale);
gfx::ImageSkia LoadMaskImage(const ScaleToSize& scale_to_size);
gfx::ImageSkia ApplyBackgroundAndMask(const gfx::ImageSkia& image);
#if BUILDFLAG(IS_CHROMEOS_ASH)
gfx::ImageSkia CompositeImagesAndApplyMask(
const gfx::ImageSkia& foreground_image,
const gfx::ImageSkia& background_image);
void ArcRawIconPngDataToImageSkia(
arc::mojom::RawIconPngDataPtr icon,
int size_hint_in_dip,
base::OnceCallback<void(const gfx::ImageSkia& icon)> callback);
void ArcActivityIconsToImageSkias(
const std::vector<arc::mojom::ActivityIconPtr>& icons,
base::OnceCallback<void(const std::vector<gfx::ImageSkia>& icons)>
callback);
gfx::ImageSkia ConvertSquareBitmapsToImageSkia(
const std::map<web_app::SquareSizePx, SkBitmap>& icon_bitmaps,
IconEffects icon_effects,
int size_hint_in_dip);
#endif
gfx::ImageSkia ConvertIconBitmapsToImageSkia(
const std::map<web_app::SquareSizePx, SkBitmap>& icon_bitmaps,
int size_hint_in_dip);
void ApplyIconEffects(Profile* profile,
const std::optional<std::string>& app_id,
IconEffects icon_effects,
int size_hint_in_dip,
IconValuePtr iv,
LoadIconCallback callback);
void ConvertUncompressedIconToCompressedIconWithScale(float rep_icon_scale,
LoadIconCallback callback,
IconValuePtr iv);
void ConvertUncompressedIconToCompressedIcon(IconValuePtr iv,
LoadIconCallback callback);
void LoadIconFromExtension(IconType icon_type,
int size_hint_in_dip,
Profile* profile,
const std::string& extension_id,
IconEffects icon_effects,
LoadIconCallback callback);
void LoadIconFromWebApp(Profile* profile,
IconType icon_type,
int size_hint_in_dip,
const std::string& web_app_id,
IconEffects icon_effects,
LoadIconCallback callback);
#if BUILDFLAG(IS_CHROMEOS)
void GetWebAppCompressedIconData(Profile* profile,
const std::string& web_app_id,
int size_in_dip,
ui::ResourceScaleFactor scale_factor,
LoadIconCallback callback);
void GetChromeAppCompressedIconData(Profile* profile,
const std::string& extension_id,
int size_in_dip,
ui::ResourceScaleFactor scale_factor,
LoadIconCallback callback);
#endif
#if BUILDFLAG(IS_CHROMEOS_ASH)
void GetArcAppCompressedIconData(Profile* profile,
const std::string& app_id,
int size_in_dip,
ui::ResourceScaleFactor scale_factor,
LoadIconCallback callback);
void GetGuestOSAppCompressedIconData(Profile* profile,
const std::string& app_id,
int size_in_dip,
ui::ResourceScaleFactor scale_factor,
LoadIconCallback callback);
#endif
void LoadIconFromFileWithFallback(
IconType icon_type,
int size_hint_in_dip,
const base::FilePath& path,
IconEffects icon_effects,
LoadIconCallback callback,
base::OnceCallback<void(LoadIconCallback)> fallback);
void LoadIconFromCompressedData(IconType icon_type,
int size_hint_in_dip,
IconEffects icon_effects,
const std::string& compressed_icon_data,
LoadIconCallback callback);
void LoadIconFromResource(Profile* profile,
std::optional<std::string> app_id,
IconType icon_type,
int size_hint_in_dip,
int resource_id,
bool is_placeholder_icon,
IconEffects icon_effects,
LoadIconCallback callback);
}
#endif