#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "extensions/browser/image_sanitizer.h"
#include "base/debug/dump_without_crashing.h"
#include "base/files/file_util.h"
#include "base/functional/bind.h"
#include "base/task/sequenced_task_runner.h"
#include "extensions/browser/extension_file_task_runner.h"
#include "extensions/common/extension_resource_path_normalizer.h"
#include "services/data_decoder/public/cpp/decode_image.h"
#include "ui/gfx/codec/png_codec.h"
namespace extensions {
namespace {
const int kMaxImageCanvas = …;
std::tuple<std::vector<uint8_t>, bool, bool> ReadAndDeleteBinaryFile(
const base::FilePath& path) { … }
std::pair<bool, std::vector<unsigned char>> EncodeImage(const SkBitmap& image) { … }
bool WriteFile(const base::FilePath& path,
const std::vector<unsigned char>& data) { … }
}
std::unique_ptr<ImageSanitizer> ImageSanitizer::CreateAndStart(
scoped_refptr<Client> client,
const base::FilePath& image_dir,
const std::set<base::FilePath>& image_paths,
const scoped_refptr<base::SequencedTaskRunner>& io_task_runner) { … }
ImageSanitizer::ImageSanitizer(
scoped_refptr<Client> client,
const base::FilePath& image_dir,
const std::set<base::FilePath>& image_relative_paths,
const scoped_refptr<base::SequencedTaskRunner>& io_task_runner)
: … { … }
ImageSanitizer::~ImageSanitizer() = default;
ImageSanitizer::Client::~Client() = default;
void ImageSanitizer::Start() { … }
void ImageSanitizer::ImageFileRead(
const base::FilePath& image_path,
std::tuple<std::vector<uint8_t>, bool, bool> read_and_delete_result) { … }
void ImageSanitizer::ImageDecoded(const base::FilePath& image_path,
const SkBitmap& decoded_image) { … }
void ImageSanitizer::ImageReencoded(
const base::FilePath& image_path,
std::pair<bool, std::vector<unsigned char>> result) { … }
void ImageSanitizer::ImageWritten(const base::FilePath& image_path,
bool success) { … }
void ImageSanitizer::ReportSuccess() { … }
void ImageSanitizer::ReportError(Status status, const base::FilePath& path) { … }
}