1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 #ifndef CHROME_BROWSER_PROFILES_PROFILE_AVATAR_DOWNLOADER_H_
5 #define CHROME_BROWSER_PROFILES_PROFILE_AVATAR_DOWNLOADER_H_
6 
7 #include <stddef.h>
8 
9 #include "base/callback_forward.h"
10 #include "base/files/file_path.h"
11 #include "chrome/browser/bitmap_fetcher/bitmap_fetcher.h"
12 
13 namespace gfx {
14 class Image;
15 }
16 
17 class ProfileAvatarDownloader : public BitmapFetcherDelegate {
18  public:
19   using FetchCompleteCallback = base::OnceCallback<
20       void(gfx::Image, const std::string&, const base::FilePath&)>;
21 
22   ProfileAvatarDownloader(size_t icon_index, FetchCompleteCallback callback);
23   ~ProfileAvatarDownloader() override;
24 
25   void Start();
26 
27   // BitmapFetcherDelegate:
28   void OnFetchComplete(const GURL& url, const SkBitmap* bitmap) override;
29 
30  private:
31   // Downloads the avatar image from a url.
32   std::unique_ptr<BitmapFetcher> fetcher_;
33 
34   // Index of the avatar being downloaded.
35   size_t icon_index_;
36 
37   FetchCompleteCallback callback_;
38 };
39 
40 #endif  // CHROME_BROWSER_PROFILES_PROFILE_AVATAR_DOWNLOADER_H_
41