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

Side by Side Diff: chrome/browser/manifest/manifest_icon_downloader.h

Issue 2933743002: Move chrome/browser/manifest to content/browser. (Closed)
Patch Set: rebased Created 3 years, 6 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 unified diff | Download patch
« no previous file with comments | « chrome/browser/manifest/OWNERS ('k') | chrome/browser/manifest/manifest_icon_downloader.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 <vector>
9
10 #include "base/callback_forward.h"
11 #include "base/macros.h"
12
13 class SkBitmap;
14
15 namespace content {
16 class WebContents;
17 } // namespace content
18
19 namespace gfx {
20 class Size;
21 } // namespace gfx
22
23 class GURL;
24
25 // Helper class which downloads the icon located at a specified. If the icon
26 // file contains multiple icons then it attempts to pick the one closest in size
27 // bigger than or equal to ideal_icon_size_in_px, taking into account the
28 // density of the device. If a bigger icon is chosen then, the icon is scaled
29 // down to be equal to ideal_icon_size_in_px. Smaller icons will be chosen down
30 // to the value specified by |minimum_icon_size_in_px|.
31 class ManifestIconDownloader final {
32 public:
33 using IconFetchCallback = base::Callback<void(const SkBitmap&)>;
34
35 ManifestIconDownloader() = delete;
36 ~ManifestIconDownloader() = delete;
37
38 // Returns whether the download has started.
39 // It will return false if the current context or information do not allow to
40 // download the image.
41 static bool Download(content::WebContents* web_contents,
42 const GURL& icon_url,
43 int ideal_icon_size_in_px,
44 int minimum_icon_size_in_px,
45 const IconFetchCallback& callback);
46
47 private:
48 class DevToolsConsoleHelper;
49
50 // Callback run after the manifest icon downloaded successfully or the
51 // download failed.
52 static void OnIconFetched(int ideal_icon_size_in_px,
53 int minimum_icon_size_in_px,
54 DevToolsConsoleHelper* console_helper,
55 const IconFetchCallback& callback,
56 int id,
57 int http_status_code,
58 const GURL& url,
59 const std::vector<SkBitmap>& bitmaps,
60 const std::vector<gfx::Size>& sizes);
61
62 static void ScaleIcon(int ideal_icon_size_in_px,
63 const SkBitmap& bitmap,
64 const IconFetchCallback& callback);
65
66 static int FindClosestBitmapIndex(int ideal_icon_size_in_px,
67 int minimum_icon_size_in_px,
68 const std::vector<SkBitmap>& bitmaps);
69
70 friend class ManifestIconDownloaderTest;
71
72 DISALLOW_COPY_AND_ASSIGN(ManifestIconDownloader);
73 };
74
75 #endif // CHROME_BROWSER_MANIFEST_MANIFEST_ICON_DOWNLOADER_H_
OLDNEW
« no previous file with comments | « chrome/browser/manifest/OWNERS ('k') | chrome/browser/manifest/manifest_icon_downloader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698