OLD | NEW |
(Empty) | |
| 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. |
| 4 |
| 5 #ifndef CHROME_BROWSER_UI_PASSWORDS_ACCOUNT_AVATAR_FETCHER_H_ |
| 6 #define CHROME_BROWSER_UI_PASSWORDS_ACCOUNT_AVATAR_FETCHER_H_ |
| 7 |
| 8 #include "base/memory/weak_ptr.h" |
| 9 #include "chrome/browser/bitmap_fetcher/bitmap_fetcher.h" |
| 10 #include "url/gurl.h" |
| 11 |
| 12 namespace gfx { |
| 13 class ImageSkia; |
| 14 } // namespace gfx |
| 15 |
| 16 namespace net { |
| 17 class URLRequestContextGetter; |
| 18 } // namespace net |
| 19 |
| 20 class AccountAvatarFetcherDelegate { |
| 21 public: |
| 22 virtual void UpdateAvatar(const gfx::ImageSkia& image) = 0; |
| 23 }; |
| 24 |
| 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); |
| 32 |
| 33 void Start(net::URLRequestContextGetter* request_context); |
| 34 |
| 35 private: |
| 36 ~AccountAvatarFetcher() override; |
| 37 |
| 38 // chrome::BitmapFetcherDelegate: |
| 39 void OnFetchComplete(const GURL url, const SkBitmap* bitmap) override; |
| 40 |
| 41 chrome::BitmapFetcher fetcher_; |
| 42 base::WeakPtr<AccountAvatarFetcherDelegate> delegate_; |
| 43 |
| 44 DISALLOW_COPY_AND_ASSIGN(AccountAvatarFetcher); |
| 45 }; |
| 46 |
| 47 #endif // CHROME_BROWSER_UI_PASSWORDS_ACCOUNT_AVATAR_FETCHER_H_ |
OLD | NEW |