Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(92)

Unified Diff: chrome/browser/android/banners/app_banner_icon_fetcher.h

Issue 155273002: Repurpose NotificationBitmapFetcher to BitmapFetcher (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: indentation Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/android/banners/app_banner_icon_fetcher.h
diff --git a/chrome/browser/android/banners/app_banner_icon_fetcher.h b/chrome/browser/android/banners/app_banner_icon_fetcher.h
new file mode 100644
index 0000000000000000000000000000000000000000..7d124225b398d44ade98216501a4e5a674d74d55
--- /dev/null
+++ b/chrome/browser/android/banners/app_banner_icon_fetcher.h
@@ -0,0 +1,64 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_ANDROID_BANNERS_APP_BANNER_ICON_FETCHER_H_
+#define CHROME_BROWSER_ANDROID_BANNERS_APP_BANNER_ICON_FETCHER_H_
+
+#include <string>
+
+#include "chrome/browser/image_decoder.h"
+#include "net/url_request/url_fetcher_delegate.h"
+#include "url/gurl.h"
+
+namespace content {
+class WebContents;
+} // namespace content
+
+namespace net {
+class URLFetcher;
+} // namespace net
+
+// Retrieves an icon from the given URL.
+class AppBannerIconFetcher : public ImageDecoder::Delegate,
+ public net::URLFetcherDelegate {
+ public:
+ class Delegate {
+ public:
+ // Called when the image has been fetched successfully.
+ virtual void OnIconFetchSuccessful(const GURL& image_url,
+ const SkBitmap& image) = 0;
+
+ // Called when the image fetch has failed.
+ virtual void OnIconFetchFailed(const GURL& image_url) = 0;
+ };
+
+ // Kicks off retrieval of the given image stored at |image_url|.
+ // The |delegate| is informed when the icon fetch has finished.
+ AppBannerIconFetcher(Delegate* delegate,
+ content::WebContents* web_contents,
+ const GURL& image_url);
+
+ virtual ~AppBannerIconFetcher();
+
+ // net::URLFetcherDelegate overrides.
+ virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE;
+
+ // ImageDecoder::Delegate overrides.
+ virtual void OnImageDecoded(const ImageDecoder* decoder,
+ const SkBitmap& decoded_image) OVERRIDE;
+
+ virtual void OnDecodeImageFailed(const ImageDecoder* decoder) OVERRIDE;
+
+ private:
+ // Alert the delegate that retrieval has failed for some reason.
+ void AlertDelegateAboutFailure();
+
+ Delegate* delegate_;
+ scoped_ptr<net::URLFetcher> fetcher_;
+ const GURL image_url_;
+
+ DISALLOW_COPY_AND_ASSIGN(AppBannerIconFetcher);
+};
+
+#endif // CHROME_BROWSER_ANDROID_BANNERS_APP_BANNER_ICON_FETCHER_H_

Powered by Google App Engine
This is Rietveld 408576698