chromium/extensions/browser/extension_icon_image.cc

// Copyright 2014 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "extensions/browser/extension_icon_image.h"

#include <vector>

#include "base/functional/bind.h"
#include "base/memory/ptr_util.h"
#include "base/memory/raw_ptr.h"
#include "base/observer_list.h"
#include "base/task/single_thread_task_runner.h"
#include "extensions/browser/image_loader.h"
#include "extensions/common/extension.h"
#include "ui/gfx/canvas.h"
#include "ui/gfx/geometry/size.h"
#include "ui/gfx/geometry/size_conversions.h"
#include "ui/gfx/image/canvas_image_source.h"
#include "ui/gfx/image/image.h"
#include "ui/gfx/image/image_skia_operations.h"
#include "ui/gfx/image/image_skia_rep.h"
#include "ui/gfx/image/image_skia_source.h"

// The ImageSkia provided by extensions::IconImage contains ImageSkiaReps that
// are computed and updated using the following algorithm (if no default icon
// was supplied, transparent icon is considered the default):
// - |LoadImageForScale()| searches the extension for an icon of an
//   appropriate size. If the extension doesn't have a icon resource needed for
//   the image representation, the default icon's representation for the
//   requested scale factor is returned by ImageSkiaSource.
// - If the extension has the resource, IconImage tries to load it using
//   ImageLoader.
// - |ImageLoader| is asynchronous.
//  - ImageSkiaSource will initially return transparent image resource of the
//    desired size.
//  - The image will be updated with an appropriate image representation when
//    the |ImageLoader| finishes. The image representation is chosen the same
//    way as in the synchronous case. The observer is notified of the image
//    change, unless the added image representation is transparent (in which
//    case the image had already contained the appropriate image
//    representation).

namespace {

extensions::ExtensionResource GetExtensionIconResource(
    const extensions::Extension& extension,
    const ExtensionIconSet& icons,
    int size,
    ExtensionIconSet::Match match_type) {}

class BlankImageSource : public gfx::CanvasImageSource {};

}  // namespace

namespace extensions {

////////////////////////////////////////////////////////////////////////////////
// IconImage::Source

class IconImage::Source : public gfx::ImageSkiaSource {};

IconImage::Source::Source(IconImage* host, const gfx::Size& size_in_dip)
    :{}

IconImage::Source::~Source() {}

void IconImage::Source::ResetHost() {}

gfx::ImageSkiaRep IconImage::Source::GetImageForScale(float scale) {}

////////////////////////////////////////////////////////////////////////////////
// IconImage

IconImage::IconImage(content::BrowserContext* context,
                     const Extension* extension,
                     const ExtensionIconSet& icon_set,
                     int resource_size_in_dip,
                     bool keep_original_size,
                     const gfx::ImageSkia& default_icon,
                     Observer* observer)
    :{}

IconImage::IconImage(content::BrowserContext* context,
                     const Extension* extension,
                     const ExtensionIconSet& icon_set,
                     int resource_size_in_dip,
                     const gfx::ImageSkia& default_icon,
                     Observer* observer)
    :{}

void IconImage::AddObserver(Observer* observer) {}

void IconImage::RemoveObserver(Observer* observer) {}

IconImage::~IconImage() {}

void IconImage::LoadImageForScaleAsync(float scale) {}

void IconImage::OnImageLoaded(float scale, const gfx::Image& image_in) {}

void IconImage::OnImageRepLoaded(const gfx::ImageSkiaRep& rep) {}

void IconImage::OnExtensionUnloaded(content::BrowserContext* browser_context,
                                    const Extension* extension,
                                    UnloadedExtensionReason reason) {}

void IconImage::OnShutdown(ExtensionRegistry* extension_registry) {}

}  // namespace extensions