OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_FAVICON_FAVICON_UTIL_H_ | 5 #ifndef CHROME_BROWSER_FAVICON_FAVICON_UTIL_H_ |
6 #define CHROME_BROWSER_FAVICON_FAVICON_UTIL_H_ | 6 #define CHROME_BROWSER_FAVICON_FAVICON_UTIL_H_ |
7 | 7 |
8 #include "ui/base/layout.h" | 8 #include "ui/base/layout.h" |
9 | 9 |
10 class GURL; | 10 class GURL; |
(...skipping 14 matching lines...) Expand all Loading... |
25 class FaviconUtil { | 25 class FaviconUtil { |
26 public: | 26 public: |
27 // Returns the scale factors at which favicons should be fetched. This is | 27 // Returns the scale factors at which favicons should be fetched. This is |
28 // different from ui::GetSupportedScaleFactors() because clients which do | 28 // different from ui::GetSupportedScaleFactors() because clients which do |
29 // not support 1x should still fetch a favicon for 1x to push to sync. This | 29 // not support 1x should still fetch a favicon for 1x to push to sync. This |
30 // guarantees that the clients receiving sync updates pushed by this client | 30 // guarantees that the clients receiving sync updates pushed by this client |
31 // receive a favicon (potentially of the wrong scale factor) and do not show | 31 // receive a favicon (potentially of the wrong scale factor) and do not show |
32 // the default favicon. | 32 // the default favicon. |
33 static std::vector<ui::ScaleFactor> GetFaviconScaleFactors(); | 33 static std::vector<ui::ScaleFactor> GetFaviconScaleFactors(); |
34 | 34 |
35 // Starts the download of the given favicon |url| from the given render view | |
36 // host. When the download is finished, an IconHostMsg_DidDownloadFavicon IPC | |
37 // message will be sent. | |
38 // Returns the unique id of the download request. The id will be sent in the | |
39 // IPC message. | |
40 static int DownloadFavicon(content::RenderViewHost* rvh, | |
41 const GURL& url, | |
42 int image_size); | |
43 | |
44 // Takes a vector of png-encoded frames, decodes them, and converts them to | 35 // Takes a vector of png-encoded frames, decodes them, and converts them to |
45 // a favicon of size favicon_size (in DIPs) at the desired ui scale factors. | 36 // a favicon of size favicon_size (in DIPs) at the desired ui scale factors. |
46 static gfx::Image SelectFaviconFramesFromPNGs( | 37 static gfx::Image SelectFaviconFramesFromPNGs( |
47 const std::vector<history::FaviconBitmapResult>& png_data, | 38 const std::vector<history::FaviconBitmapResult>& png_data, |
48 const std::vector<ui::ScaleFactor> scale_factors, | 39 const std::vector<ui::ScaleFactor> scale_factors, |
49 int favicon_size); | 40 int favicon_size); |
50 | 41 |
51 // Takes a vector of bitmaps and returns the index of the image that will best | 42 // Takes a vector of bitmaps and returns the index of the image that will best |
52 // produce an image of size |desired_size| for the given |scale_factors|. | 43 // produce an image of size |desired_size| for the given |scale_factors|. |
53 static size_t SelectBestFaviconFromBitmaps( | 44 static size_t SelectBestFaviconFromBitmaps( |
54 const std::vector<SkBitmap>& bitmaps, | 45 const std::vector<SkBitmap>& bitmaps, |
55 const std::vector<ui::ScaleFactor>& scale_factors, | 46 const std::vector<ui::ScaleFactor>& scale_factors, |
56 int desired_size); | 47 int desired_size); |
57 }; | 48 }; |
58 | 49 |
59 #endif // CHROME_BROWSER_FAVICON_FAVICON_UTIL_H_ | 50 #endif // CHROME_BROWSER_FAVICON_FAVICON_UTIL_H_ |
OLD | NEW |