| 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 "ui/base/layout.h" | 10 #include "ui/base/layout.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 class FaviconUtil { | 27 class FaviconUtil { |
| 28 public: | 28 public: |
| 29 // Returns the scale factors at which favicons should be fetched. This is | 29 // Returns the scale factors at which favicons should be fetched. This is |
| 30 // different from ui::GetSupportedScaleFactors() because clients which do | 30 // different from ui::GetSupportedScaleFactors() because clients which do |
| 31 // not support 1x should still fetch a favicon for 1x to push to sync. This | 31 // not support 1x should still fetch a favicon for 1x to push to sync. This |
| 32 // guarantees that the clients receiving sync updates pushed by this client | 32 // guarantees that the clients receiving sync updates pushed by this client |
| 33 // receive a favicon (potentially of the wrong scale factor) and do not show | 33 // receive a favicon (potentially of the wrong scale factor) and do not show |
| 34 // the default favicon. | 34 // the default favicon. |
| 35 static std::vector<ui::ScaleFactor> GetFaviconScaleFactors(); | 35 static std::vector<ui::ScaleFactor> GetFaviconScaleFactors(); |
| 36 | 36 |
| 37 // Sets the color space used for converting |image| to an NSImage to the |
| 38 // system colorspace. This makes the favicon look the same in the browser UI |
| 39 // as it does in the renderer. |
| 40 static void SetFaviconColorSpace(gfx::Image* image); |
| 41 |
| 37 // Takes a vector of png-encoded frames, decodes them, and converts them to | 42 // 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. | 43 // a favicon of size favicon_size (in DIPs) at the desired ui scale factors. |
| 39 static gfx::Image SelectFaviconFramesFromPNGs( | 44 static gfx::Image SelectFaviconFramesFromPNGs( |
| 40 const std::vector<chrome::FaviconBitmapResult>& png_data, | 45 const std::vector<chrome::FaviconBitmapResult>& png_data, |
| 41 const std::vector<ui::ScaleFactor>& scale_factors, | 46 const std::vector<ui::ScaleFactor>& scale_factors, |
| 42 int favicon_size); | 47 int favicon_size); |
| 43 | 48 |
| 44 // Takes a vector of bitmaps and returns the index of the image that will best | 49 // Takes a vector of bitmaps and returns the index of the image that will best |
| 45 // produce an image of size |desired_size| for the given |scale_factors|. | 50 // produce an image of size |desired_size| for the given |scale_factors|. |
| 46 static size_t SelectBestFaviconFromBitmaps( | 51 static size_t SelectBestFaviconFromBitmaps( |
| 47 const std::vector<SkBitmap>& bitmaps, | 52 const std::vector<SkBitmap>& bitmaps, |
| 48 const std::vector<ui::ScaleFactor>& scale_factors, | 53 const std::vector<ui::ScaleFactor>& scale_factors, |
| 49 int desired_size); | 54 int desired_size); |
| 50 | 55 |
| 51 // Given raw image data, decodes the icon, re-sampling to the correct size as | 56 // Given raw image data, decodes the icon, re-sampling to the correct size as |
| 52 // necessary, and re-encodes as PNG data in the given output vector. Returns | 57 // necessary, and re-encodes as PNG data in the given output vector. Returns |
| 53 // true on success. | 58 // true on success. |
| 54 static bool ReencodeFavicon(const unsigned char* src_data, | 59 static bool ReencodeFavicon(const unsigned char* src_data, |
| 55 size_t src_len, | 60 size_t src_len, |
| 56 std::vector<unsigned char>* png_data); | 61 std::vector<unsigned char>* png_data); |
| 57 }; | 62 }; |
| 58 | 63 |
| 59 #endif // CHROME_BROWSER_FAVICON_FAVICON_UTIL_H_ | 64 #endif // CHROME_BROWSER_FAVICON_FAVICON_UTIL_H_ |
| OLD | NEW |