#ifndef CHROME_BROWSER_ASH_IMAGE_SOURCE_IMAGE_SOURCE_H_
#define CHROME_BROWSER_ASH_IMAGE_SOURCE_IMAGE_SOURCE_H_
#include <string>
#include "base/files/file_path.h"
#include "base/memory/scoped_refptr.h"
#include "base/memory/weak_ptr.h"
#include "content/public/browser/url_data_source.h"
namespace base {
class SequencedTaskRunner;
}
namespace ash {
class ImageSource : public content::URLDataSource {
public:
ImageSource();
ImageSource(const ImageSource&) = delete;
ImageSource& operator=(const ImageSource&) = delete;
~ImageSource() override;
std::string GetSource() override;
void StartDataRequest(
const GURL& url,
const content::WebContents::Getter& wc_getter,
content::URLDataSource::GotDataCallback got_data_callback) override;
std::string GetMimeType(const GURL& url) override;
private:
void StartDataRequestAfterPathExists(
const base::FilePath& image_path,
content::URLDataSource::GotDataCallback got_data_callback,
bool path_exists);
bool IsAllowlisted(const std::string& path) const;
scoped_refptr<base::SequencedTaskRunner> task_runner_;
base::WeakPtrFactory<ImageSource> weak_factory_{this};
};
}
#endif