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

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

Issue 2589503002: Use exact pixel sizes instead of dip in webapp/WebAPK installability code (Closed)
Patch Set: Created 4 years 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_MANIFEST_MANIFEST_ICON_DOWNLOADER_H_ 5 #ifndef CHROME_BROWSER_MANIFEST_MANIFEST_ICON_DOWNLOADER_H_
6 #define CHROME_BROWSER_MANIFEST_MANIFEST_ICON_DOWNLOADER_H_ 6 #define CHROME_BROWSER_MANIFEST_MANIFEST_ICON_DOWNLOADER_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/callback_forward.h" 10 #include "base/callback_forward.h"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 12
13 class SkBitmap; 13 class SkBitmap;
14 14
15 namespace content { 15 namespace content {
16 class WebContents; 16 class WebContents;
17 } // namespace content 17 } // namespace content
18 18
19 namespace gfx { 19 namespace gfx {
20 class Size; 20 class Size;
21 } // namespace gfx 21 } // namespace gfx
22 22
23 class GURL; 23 class GURL;
24 24
25 // Helper class which downloads the icon located at a specified. If the icon 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 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_dp, taking into account the 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 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_dp. Smaller icons will be chosen down 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_dp|. 30 // to the value specified by |minimum_icon_size_in_px|.
31 class ManifestIconDownloader final { 31 class ManifestIconDownloader final {
32 public: 32 public:
33 using IconFetchCallback = base::Callback<void(const SkBitmap&)>; 33 using IconFetchCallback = base::Callback<void(const SkBitmap&)>;
34 34
35 ManifestIconDownloader() = delete; 35 ManifestIconDownloader() = delete;
36 ~ManifestIconDownloader() = delete; 36 ~ManifestIconDownloader() = delete;
37 37
38 // Returns whether the download has started. 38 // Returns whether the download has started.
39 // It will return false if the current context or information do not allow to 39 // It will return false if the current context or information do not allow to
40 // download the image. 40 // download the image.
41 static bool Download(content::WebContents* web_contents, 41 static bool Download(content::WebContents* web_contents,
42 const GURL& icon_url, 42 const GURL& icon_url,
43 int ideal_icon_size_in_dp, 43 int ideal_icon_size_in_px,
44 int minimum_icon_size_in_dp, 44 int minimum_icon_size_in_px,
45 const IconFetchCallback& callback); 45 const IconFetchCallback& callback);
46 46
47 private: 47 private:
48 class DevToolsConsoleHelper; 48 class DevToolsConsoleHelper;
49 49
50 // Callback run after the manifest icon downloaded successfully or the 50 // Callback run after the manifest icon downloaded successfully or the
51 // download failed. 51 // download failed.
52 static void OnIconFetched(int ideal_icon_size_in_px, 52 static void OnIconFetched(int ideal_icon_size_in_px,
53 int minimum_icon_size_in_px, 53 int minimum_icon_size_in_px,
54 DevToolsConsoleHelper* console_helper, 54 DevToolsConsoleHelper* console_helper,
(...skipping 11 matching lines...) Expand all
66 static int FindClosestBitmapIndex(int ideal_icon_size_in_px, 66 static int FindClosestBitmapIndex(int ideal_icon_size_in_px,
67 int minimum_icon_size_in_px, 67 int minimum_icon_size_in_px,
68 const std::vector<SkBitmap>& bitmaps); 68 const std::vector<SkBitmap>& bitmaps);
69 69
70 friend class ManifestIconDownloaderTest; 70 friend class ManifestIconDownloaderTest;
71 71
72 DISALLOW_COPY_AND_ASSIGN(ManifestIconDownloader); 72 DISALLOW_COPY_AND_ASSIGN(ManifestIconDownloader);
73 }; 73 };
74 74
75 #endif // CHROME_BROWSER_MANIFEST_MANIFEST_ICON_DOWNLOADER_H_ 75 #endif // CHROME_BROWSER_MANIFEST_MANIFEST_ICON_DOWNLOADER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698