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_MANIFEST_MANIFEST_ICON_DOWNLOADER_H_ | |
6 #define CHROME_BROWSER_MANIFEST_MANIFEST_ICON_DOWNLOADER_H_ | |
7 | |
8 #include "base/basictypes.h" | |
9 #include "base/bind.h" | |
10 #include "base/memory/ref_counted.h" | |
11 #include "content/public/browser/web_contents_observer.h" | |
12 #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.
| |
13 #include "third_party/skia/include/core/SkBitmap.h" | |
14 #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.
| |
15 | |
16 namespace content { | |
17 class WebContents; | |
18 } // namespace content | |
19 | |
20 class ManifestIconDownloader | |
21 : public content::WebContentsObserver { | |
22 public: | |
23 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.
| |
24 | |
25 explicit ManifestIconDownloader(content::WebContents* web_contents); | |
26 virtual ~ManifestIconDownloader() {} | |
mlamouri (slow - plz ping)
2015/08/05 08:20:17
s/{}/= default;/
Lalit Maganti
2015/08/05 14:47:13
Done.
| |
27 | |
28 // Downloads the icon located at icon_url. If more than one icon is present | |
29 // 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.
| |
30 // equal to ideal_icon_size_in_dp, taking into account the density of the | |
31 // device. If a bigger icon is chosen then the icon is scaled down to be equal | |
32 // 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.
| |
33 bool Download(const GURL& icon_url, | |
34 int ideal_icon_size_in_dp, | |
35 const Callback& callback); | |
36 | |
37 private: | |
38 // Callback run after an attempt to download the manifest icon has been made. | |
39 void OnIconFetched(const int ideal_icon_size_in_dp, | |
40 const Callback& callback, | |
41 int id, | |
42 int http_status_code, | |
43 const GURL& url, | |
44 const std::vector<SkBitmap>& bitmaps, | |
45 const std::vector<gfx::Size>& sizes); | |
46 | |
47 base::WeakPtrFactory<ManifestIconDownloader> weak_ptr_factory_; | |
48 | |
49 DISALLOW_COPY_AND_ASSIGN(ManifestIconDownloader); | |
50 }; | |
51 | |
52 #endif // CHROME_BROWSER_MANIFEST_MANIFEST_ICON_DOWNLOADER_H_ | |
OLD | NEW |