Index: chrome/browser/ui/app_list/search/webstore_result_icon_source.h |
diff --git a/chrome/browser/ui/app_list/search/webstore_result_icon_source.h b/chrome/browser/ui/app_list/search/webstore_result_icon_source.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..0505d0391ce16b204a044940ae75ee26a8230186 |
--- /dev/null |
+++ b/chrome/browser/ui/app_list/search/webstore_result_icon_source.h |
@@ -0,0 +1,74 @@ |
+// Copyright 2013 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_UI_APP_LIST_SEARCH_WEBSTORE_RESULT_ICON_SOURCE_H_ |
+#define CHROME_BROWSER_UI_APP_LIST_SEARCH_WEBSTORE_RESULT_ICON_SOURCE_H_ |
+ |
+#include "base/basictypes.h" |
+#include "base/callback.h" |
+#include "base/memory/ref_counted.h" |
+#include "base/memory/scoped_ptr.h" |
+#include "chrome/browser/image_decoder.h" |
+#include "googleurl/src/gurl.h" |
+#include "net/url_request/url_fetcher_delegate.h" |
+#include "ui/gfx/image/image_skia.h" |
+#include "ui/gfx/image/image_skia_source.h" |
+ |
+namespace net { |
+class URLFetcher; |
+class URLRequestContextGetter; |
+} |
+ |
+namespace app_list { |
+ |
+// An ImageSkiaSource for the icon of web store result. It shows web store |
+// icon before the app icon is fetched. When the app icon is fetched |
+// successfully, it creates an representation using the app icon and web store |
+// icon as a badge. |
+class WebstoreResultIconSource : public gfx::ImageSkiaSource, |
+ public net::URLFetcherDelegate, |
+ public ImageDecoder::Delegate { |
+ public: |
+ typedef base::Closure IconLoadedCallback; |
+ |
+ WebstoreResultIconSource(const IconLoadedCallback& icon_loaded_callback, |
+ net::URLRequestContextGetter* context_getter, |
+ const GURL& icon_url, |
+ int icon_size); |
+ virtual ~WebstoreResultIconSource(); |
+ |
+ private: |
+ void StartIconFetch(); |
+ gfx::ImageSkiaRep CreateBadgedIcon(ui::ScaleFactor scale_factor); |
James Cook
2013/05/20 14:39:34
function comment?
xiyuan
2013/05/20 16:56:31
Done.
|
+ |
+ // gfx::ImageSkiaSource overrides: |
+ virtual gfx::ImageSkiaRep GetImageForScale( |
+ ui::ScaleFactor scale_factor) OVERRIDE; |
+ |
+ // 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; |
+ |
+ IconLoadedCallback icon_loaded_callback_; |
+ net::URLRequestContextGetter* context_getter_; |
+ const GURL icon_url_; |
+ const int icon_size_; |
+ |
+ bool icon_fetch_attempted_; |
+ scoped_ptr<net::URLFetcher> icon_fetcher_; |
+ |
+ scoped_refptr<ImageDecoder> image_decoder_; |
+ |
+ gfx::ImageSkia icon_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(WebstoreResultIconSource); |
+}; |
+ |
+} // namespace app_list |
+ |
+#endif // CHROME_BROWSER_UI_APP_LIST_SEARCH_WEBSTORE_RESULT_ICON_SOURCE_H_ |