| 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 <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "components/favicon_base/favicon_types.h" | 10 #include "components/favicon_base/favicon_types.h" |
| 11 #include "ui/base/layout.h" | 11 #include "ui/base/layout.h" |
| 12 | 12 |
| 13 namespace chrome { | 13 namespace chrome { |
| 14 struct FaviconBitmapResult; | 14 struct FaviconRawBitmapResult; |
| 15 } | 15 } |
| 16 | 16 |
| 17 namespace gfx { | 17 namespace gfx { |
| 18 class Image; | 18 class Image; |
| 19 } | 19 } |
| 20 | 20 |
| 21 // Utility class for common favicon related code. | 21 // Utility class for common favicon related code. |
| 22 class FaviconUtil { | 22 class FaviconUtil { |
| 23 public: | 23 public: |
| 24 // Returns the scale factors at which favicons should be fetched. This is | 24 // Returns the scale factors at which favicons should be fetched. This is |
| 25 // different from ui::GetSupportedScaleFactors() because clients which do | 25 // different from ui::GetSupportedScaleFactors() because clients which do |
| 26 // not support 1x should still fetch a favicon for 1x to push to sync. This | 26 // not support 1x should still fetch a favicon for 1x to push to sync. This |
| 27 // guarantees that the clients receiving sync updates pushed by this client | 27 // guarantees that the clients receiving sync updates pushed by this client |
| 28 // receive a favicon (potentially of the wrong scale factor) and do not show | 28 // receive a favicon (potentially of the wrong scale factor) and do not show |
| 29 // the default favicon. | 29 // the default favicon. |
| 30 static std::vector<ui::ScaleFactor> GetFaviconScaleFactors(); | 30 static std::vector<ui::ScaleFactor> GetFaviconScaleFactors(); |
| 31 | 31 |
| 32 // Sets the color space used for converting |image| to an NSImage to the | 32 // Sets the color space used for converting |image| to an NSImage to the |
| 33 // system colorspace. This makes the favicon look the same in the browser UI | 33 // system colorspace. This makes the favicon look the same in the browser UI |
| 34 // as it does in the renderer. | 34 // as it does in the renderer. |
| 35 static void SetFaviconColorSpace(gfx::Image* image); | 35 static void SetFaviconColorSpace(gfx::Image* image); |
| 36 | 36 |
| 37 // Takes a vector of png-encoded frames, decodes them, and converts them to | 37 // Takes a vector of png-encoded frames, decodes them, and converts them to |
| 38 // a favicon of size favicon_size (in DIPs) at the desired ui scale factors. | 38 // a favicon of size favicon_size (in DIPs) at the desired ui scale factors. |
| 39 static gfx::Image SelectFaviconFramesFromPNGs( | 39 static gfx::Image SelectFaviconFramesFromPNGs( |
| 40 const std::vector<favicon_base::FaviconBitmapResult>& png_data, | 40 const std::vector<favicon_base::FaviconRawBitmapResult>& png_data, |
| 41 const std::vector<ui::ScaleFactor>& scale_factors, | 41 const std::vector<ui::ScaleFactor>& scale_factors, |
| 42 int favicon_size); | 42 int favicon_size); |
| 43 }; | 43 }; |
| 44 | 44 |
| 45 #endif // CHROME_BROWSER_FAVICON_FAVICON_UTIL_H_ | 45 #endif // CHROME_BROWSER_FAVICON_FAVICON_UTIL_H_ |
| OLD | NEW |