1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
ash / public / cpp / image_downloader.h [blame]
// Copyright 2020 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ASH_PUBLIC_CPP_IMAGE_DOWNLOADER_H_
#define ASH_PUBLIC_CPP_IMAGE_DOWNLOADER_H_
#include "ash/public/cpp/ash_public_export.h"
#include "base/functional/callback_forward.h"
class GURL;
class AccountId;
namespace gfx {
class ImageSkia;
} // namespace gfx
namespace net {
class HttpRequestHeaders;
struct NetworkTrafficAnnotationTag;
} // namespace net
namespace ash {
// Interface for a class which is responsible for downloading images in ash.
class ASH_PUBLIC_EXPORT ImageDownloader {
public:
static ImageDownloader* Get();
using DownloadCallback = base::OnceCallback<void(const gfx::ImageSkia&)>;
ImageDownloader(const ImageDownloader&) = delete;
ImageDownloader& operator=(const ImageDownloader&) = delete;
// Downloads the image found at |url| for the primary profile. On completion,
// |callback| is run with the downloaded |image|. In the event that the
// download attempt fails, a nullptr image will be returned.
virtual void Download(const GURL& url,
const net::NetworkTrafficAnnotationTag& annotation_tag,
const AccountId& account_id,
DownloadCallback callback) = 0;
// Additionally with this method, you can specify extra HTTP request headers
// sent with the download request.
virtual void Download(const GURL& url,
const net::NetworkTrafficAnnotationTag& annotation_tag,
const AccountId& account_id,
const net::HttpRequestHeaders& additional_headers,
DownloadCallback callback) = 0;
protected:
ImageDownloader();
virtual ~ImageDownloader();
};
} // namespace ash
#endif // ASH_PUBLIC_CPP_IMAGE_DOWNLOADER_H_