#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "third_party/blink/renderer/modules/image_downloader/image_downloader_impl.h"
#include <utility>
#include "base/check.h"
#include "base/functional/bind.h"
#include "skia/ext/image_operations.h"
#include "third_party/blink/public/mojom/fetch/fetch_api_request.mojom-blink.h"
#include "third_party/blink/public/platform/interface_registry.h"
#include "third_party/blink/public/platform/web_data.h"
#include "third_party/blink/public/platform/web_string.h"
#include "third_party/blink/public/platform/web_vector.h"
#include "third_party/blink/public/web/web_image.h"
#include "third_party/blink/renderer/core/accessibility/ax_object_cache.h"
#include "third_party/blink/renderer/core/dom/document.h"
#include "third_party/blink/renderer/core/frame/local_dom_window.h"
#include "third_party/blink/renderer/core/frame/local_frame.h"
#include "third_party/blink/renderer/modules/accessibility/ax_object.h"
#include "third_party/blink/renderer/modules/image_downloader/multi_resolution_image_resource_fetcher.h"
#include "third_party/blink/renderer/platform/heap/visitor.h"
#include "third_party/blink/renderer/platform/network/network_utils.h"
#include "third_party/blink/renderer/platform/weborigin/kurl.h"
#include "third_party/blink/renderer/platform/wtf/vector.h"
#include "ui/gfx/geometry/size.h"
namespace {
WTF::Vector<SkBitmap> DecodeImageData(const std::string& data,
const std::string& mime_type,
const gfx::Size& preferred_size) { … }
WTF::Vector<SkBitmap> ImagesFromDataUrl(const blink::KURL& url,
const gfx::Size& preferred_size) { … }
SkBitmap ResizeImage(const SkBitmap& image, uint32_t max_image_size) { … }
void FilterAndResizeImagesForMaximalSize(
const WTF::Vector<SkBitmap>& unfiltered,
uint32_t max_image_size,
WTF::Vector<SkBitmap>* images,
WTF::Vector<gfx::Size>* original_image_sizes) { … }
}
namespace blink {
const char ImageDownloaderImpl::kSupplementName[] = …;
ImageDownloaderImpl* ImageDownloaderImpl::From(LocalFrame& frame) { … }
void ImageDownloaderImpl::ProvideTo(LocalFrame& frame) { … }
ImageDownloaderImpl::ImageDownloaderImpl(LocalFrame& frame)
: … { … }
ImageDownloaderImpl::~ImageDownloaderImpl() { … }
void ImageDownloaderImpl::CreateMojoService(
mojo::PendingReceiver<mojom::blink::ImageDownloader> receiver) { … }
void ImageDownloaderImpl::DownloadImage(const KURL& image_url,
bool is_favicon,
const gfx::Size& preferred_size,
uint32_t max_bitmap_size,
bool bypass_cache,
DownloadImageCallback callback) { … }
void ImageDownloaderImpl::DownloadImageFromAxNode(
int ax_node_id,
const gfx::Size& preferred_size,
uint32_t max_bitmap_size,
bool bypass_cache,
DownloadImageCallback callback) { … }
void ImageDownloaderImpl::DidDownloadImage(
uint32_t max_image_size,
DownloadImageCallback callback,
int32_t http_status_code,
const WTF::Vector<SkBitmap>& images) { … }
void ImageDownloaderImpl::Dispose() { … }
void ImageDownloaderImpl::FetchImage(const KURL& image_url,
bool is_favicon,
const gfx::Size& preferred_size,
bool bypass_cache,
DownloadCallback callback) { … }
void ImageDownloaderImpl::DidFetchImage(
DownloadCallback callback,
const gfx::Size& preferred_size,
MultiResolutionImageResourceFetcher* fetcher,
const std::string& image_data,
const WebString& mime_type) { … }
void ImageDownloaderImpl::Trace(Visitor* visitor) const { … }
void ImageDownloaderImpl::ContextDestroyed() { … }
}