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

Unified Diff: chrome/browser/manifest/manifest_icon_downloader.h

Issue 1261143004: Implement manifest icon downloader (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix issues raised in comments Created 5 years, 4 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/manifest/manifest_icon_downloader.h
diff --git a/chrome/browser/manifest/manifest_icon_downloader.h b/chrome/browser/manifest/manifest_icon_downloader.h
new file mode 100644
index 0000000000000000000000000000000000000000..36475d14037c8fc239bfb4e8371d34caa3eff914
--- /dev/null
+++ b/chrome/browser/manifest/manifest_icon_downloader.h
@@ -0,0 +1,52 @@
+// Copyright 2015 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_MANIFEST_MANIFEST_ICON_DOWNLOADER_H_
+#define CHROME_BROWSER_MANIFEST_MANIFEST_ICON_DOWNLOADER_H_
+
+#include "base/basictypes.h"
+#include "base/bind.h"
+#include "base/memory/ref_counted.h"
+#include "content/public/browser/web_contents_observer.h"
+#include "content/public/common/manifest.h"
mlamouri (slow - plz ping) 2015/08/05 08:20:17 nit: do you need that include?
Lalit Maganti 2015/08/05 14:47:13 Removed.
+#include "third_party/skia/include/core/SkBitmap.h"
+#include "url/gurl.h"
mlamouri (slow - plz ping) 2015/08/05 08:20:17 I think you can forward declare GURL.
Lalit Maganti 2015/08/05 14:47:13 Done.
+
+namespace content {
+class WebContents;
+} // namespace content
+
+class ManifestIconDownloader
+ : public content::WebContentsObserver {
+ public:
+ typedef base::Callback<void(const SkBitmap&)> Callback;
mlamouri (slow - plz ping) 2015/08/05 08:20:17 nit: Callback is too generic of a name, maybe Icon
Lalit Maganti 2015/08/05 14:47:13 Done.
+
+ explicit ManifestIconDownloader(content::WebContents* web_contents);
+ virtual ~ManifestIconDownloader() {}
mlamouri (slow - plz ping) 2015/08/05 08:20:17 s/{}/= default;/
Lalit Maganti 2015/08/05 14:47:13 Done.
+
+ // Downloads the icon located at icon_url. If more than one icon is present
+ // at the URL then it attempts to pick the one closest in size bigger than or
mlamouri (slow - plz ping) 2015/08/05 08:20:17 nit: I would say "If the file contains multiple ic
Lalit Maganti 2015/08/05 14:47:13 Done.
+ // equal to ideal_icon_size_in_dp, taking into account the density of the
+ // device. If a bigger icon is chosen then the icon is scaled down to be equal
+ // to ideal_icon_size_in_dp.
mlamouri (slow - plz ping) 2015/08/05 08:20:17 nit: could you document what the return value mean
Lalit Maganti 2015/08/05 14:47:13 Done.
+ bool Download(const GURL& icon_url,
+ int ideal_icon_size_in_dp,
+ const Callback& callback);
+
+ private:
+ // Callback run after an attempt to download the manifest icon has been made.
+ void OnIconFetched(const int ideal_icon_size_in_dp,
+ const Callback& callback,
+ int id,
+ int http_status_code,
+ const GURL& url,
+ const std::vector<SkBitmap>& bitmaps,
+ const std::vector<gfx::Size>& sizes);
+
+ base::WeakPtrFactory<ManifestIconDownloader> weak_ptr_factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(ManifestIconDownloader);
+};
+
+#endif // CHROME_BROWSER_MANIFEST_MANIFEST_ICON_DOWNLOADER_H_

Powered by Google App Engine
This is Rietveld 408576698