visuals_decoder.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435
  1. // Copyright 2018 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_OFFLINE_PAGES_CORE_VISUALS_DECODER_H_
  5. #define COMPONENTS_OFFLINE_PAGES_CORE_VISUALS_DECODER_H_
  6. #include <string>
  7. #include "base/callback.h"
  8. namespace gfx {
  9. class Image;
  10. }
  11. namespace offline_pages {
  12. // Decodes thumbnails. Provided so that this component does not need to
  13. // depend on ImageSkiaOperations which isn't available everywhere.
  14. class VisualsDecoder {
  15. public:
  16. using DecodeComplete = base::OnceCallback<void(const gfx::Image&)>;
  17. virtual ~VisualsDecoder() {}
  18. // Decode a thumbnail or favicon image and crop it square. Calls
  19. // complete_callback when decoding completes successfully or otherwise. If
  20. // decoding fails, the returned image is empty. In the case of .ICO favicons,
  21. // chooses the frame whose size matches our preferred favicon size or the next
  22. // one larger if there is no exact match.
  23. virtual void DecodeAndCropImage(const std::string& thumbnail_data,
  24. DecodeComplete complete_callback) = 0;
  25. };
  26. } // namespace offline_pages
  27. #endif // COMPONENTS_OFFLINE_PAGES_CORE_VISUALS_DECODER_H_