Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / chrome / browser / ui / passwords / account_avatar_fetcher.h
blobea7121d7b3d50454c4a0fcc3ce2e5ef6861167dd
1 // Copyright 2015 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.
5 #ifndef CHROME_BROWSER_UI_PASSWORDS_ACCOUNT_AVATAR_FETCHER_H_
6 #define CHROME_BROWSER_UI_PASSWORDS_ACCOUNT_AVATAR_FETCHER_H_
8 #include "base/memory/weak_ptr.h"
9 #include "chrome/browser/bitmap_fetcher/bitmap_fetcher.h"
10 #include "url/gurl.h"
12 namespace gfx {
13 class ImageSkia;
14 } // namespace gfx
16 namespace net {
17 class URLRequestContextGetter;
18 } // namespace net
20 class AccountAvatarFetcherDelegate {
21 public:
22 virtual void UpdateAvatar(const gfx::ImageSkia& image) = 0;
25 // Helper class to download an avatar. It deletes itself once the request is
26 // done.
27 class AccountAvatarFetcher : public chrome::BitmapFetcherDelegate {
28 public:
29 AccountAvatarFetcher(
30 const GURL& url,
31 const base::WeakPtr<AccountAvatarFetcherDelegate>& delegate);
33 ~AccountAvatarFetcher() override;
35 void Start(net::URLRequestContextGetter* request_context);
37 private:
38 // chrome::BitmapFetcherDelegate:
39 void OnFetchComplete(const GURL& url, const SkBitmap* bitmap) override;
41 chrome::BitmapFetcher fetcher_;
42 base::WeakPtr<AccountAvatarFetcherDelegate> delegate_;
44 DISALLOW_COPY_AND_ASSIGN(AccountAvatarFetcher);
47 #endif // CHROME_BROWSER_UI_PASSWORDS_ACCOUNT_AVATAR_FETCHER_H_