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

Unified Diff: chrome/browser/ui/app_list/search/webstore_result_icon_source.h

Issue 15342003: app_list: Add web store search. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase and address nits in #3 Created 7 years, 7 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/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..06b4fed33b1c9510c18045e7c896ecf8c82f3ff5
--- /dev/null
+++ b/chrome/browser/ui/app_list/search/webstore_result_icon_source.h
@@ -0,0 +1,79 @@
+// 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:
+ // Invoked from GetImageForScale to download the app icon when the hosting
+ // ImageSkia gets painted on screen.
+ void StartIconFetch();
+
+ // Creates the result icon by putting a small web store icon on the bottom
+ // right corner as a badge.
+ gfx::ImageSkiaRep CreateBadgedIcon(ui::ScaleFactor scale_factor);
+
+ // 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_
« no previous file with comments | « chrome/browser/ui/app_list/search/webstore_result.cc ('k') | chrome/browser/ui/app_list/search/webstore_result_icon_source.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698