favicon_util.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. // Copyright 2014 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. #ifndef COMPONENTS_FAVICON_BASE_FAVICON_UTIL_H_
  5. #define COMPONENTS_FAVICON_BASE_FAVICON_UTIL_H_
  6. #include <vector>
  7. #include "components/favicon_base/favicon_types.h"
  8. namespace gfx {
  9. class Image;
  10. }
  11. namespace favicon_base {
  12. // Returns the scales at which favicons should be fetched. This is
  13. // different from ui::GetSupportedResourceScaleFactors() because clients which
  14. // do not support 1x should still fetch a favicon for 1x to push to sync. This
  15. // guarantees that the clients receiving sync updates pushed by this client
  16. // receive a favicon (potentially of the wrong scale factor) and do not show
  17. // the default favicon.
  18. std::vector<float> GetFaviconScales();
  19. // Sets the color space used for converting |image| to an NSImage to the
  20. // system colorspace. This makes the favicon look the same in the browser UI
  21. // as it does in the renderer.
  22. void SetFaviconColorSpace(gfx::Image* image);
  23. // Takes a vector of PNG-encoded frames, and converts it to a gfx::Image of
  24. // size |favicon_size| in DIPS. The result gfx::Image has a gfx::ImageSkia with
  25. // gfx::ImageSkiaReps for each |favicon_scales|.
  26. gfx::Image SelectFaviconFramesFromPNGs(
  27. const std::vector<favicon_base::FaviconRawBitmapResult>& png_data,
  28. const std::vector<float>& favicon_scales,
  29. int favicon_size);
  30. // Generates a favicon_bitmap_result sized exactly to [desired_size,
  31. // desired_size] from the provided result set. If the exact size is found in
  32. // the set, it just returns that; otherwise, it will decode the PNG, scale,
  33. // and encode a new PNG.
  34. favicon_base::FaviconRawBitmapResult ResizeFaviconBitmapResult(
  35. const std::vector<favicon_base::FaviconRawBitmapResult>&
  36. favicon_bitmap_results,
  37. int desired_size_in_pixel);
  38. } // namespace favicon_base
  39. #endif // COMPONENTS_FAVICON_BASE_FAVICON_UTIL_H_