#ifndef CHROME_BROWSER_EXTENSIONS_CHROME_APP_ICON_LOADER_H_
#define CHROME_BROWSER_EXTENSIONS_CHROME_APP_ICON_LOADER_H_
#include <map>
#include <memory>
#include <string>
#include "base/functional/callback.h"
#include "base/memory/raw_ptr.h"
#include "chrome/browser/extensions/chrome_app_icon_delegate.h"
#include "components/app_icon_loader/app_icon_loader.h"
#include "extensions/buildflags/buildflags.h"
static_assert(BUILDFLAG(ENABLE_EXTENSIONS_CORE));
class Profile;
namespace gfx {
class ImageSkia;
class Size;
}
namespace extensions {
class ChromeAppIconLoader : public AppIconLoader, public ChromeAppIconDelegate {
public:
using ResizeFunction =
base::RepeatingCallback<void(const gfx::Size&, gfx::ImageSkia*)>;
ChromeAppIconLoader(Profile* profile,
int icon_size_in_dip,
const ResizeFunction& resize_function,
AppIconLoaderDelegate* delegate);
ChromeAppIconLoader(Profile* profile,
int icon_size_in_dip,
AppIconLoaderDelegate* delegate);
ChromeAppIconLoader(const ChromeAppIconLoader&) = delete;
ChromeAppIconLoader& operator=(const ChromeAppIconLoader&) = delete;
~ChromeAppIconLoader() override;
bool CanLoadImageForApp(const std::string& id) override;
void FetchImage(const std::string& id) override;
void ClearImage(const std::string& id) override;
void UpdateImage(const std::string& id) override;
void SetExtensionsOnly();
Profile* profile() { return profile_; }
private:
using ExtensionIDToChromeAppIconMap =
std::map<std::string, std::unique_ptr<ChromeAppIcon>>;
void OnIconUpdated(ChromeAppIcon* icon) override;
const raw_ptr<Profile, DanglingUntriaged> profile_ = nullptr;
ExtensionIDToChromeAppIconMap map_;
const ResizeFunction resize_function_;
bool extensions_only_ = false;
};
}
#endif