blob: 289d87e073782ce889be1b06f1773809649b3fe8 [file] [log] [blame]
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#import <Foundation/Foundation.h>
#include "base/memory/ref_counted.h"
#include "components/image_fetcher/core/image_data_fetcher.h"
#include "components/image_fetcher/core/image_fetcher_types.h"
namespace network {
class SharedURLLoaderFactory;
class GURL;
namespace image_fetcher {
class IOSImageDataFetcherWrapper {
// The TaskRunner is used to decode the image if it is WebP-encoded.
explicit IOSImageDataFetcherWrapper(
scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory);
virtual ~IOSImageDataFetcherWrapper();
// Helper to start downloading and possibly decoding the image without a
// referrer.
void FetchImageDataWebpDecoded(const GURL& image_url,
ImageDataFetcherBlock callback,
bool send_cookies = false);
// Start downloading the image at the given |image_url|. The |callback| will
// be called with the downloaded image, or nil if any error happened. If the
// image is WebP it will be decoded.
// The |referrer| and |referrer_policy| will be passed on to the underlying
// URLFetcher.
// |callback| cannot be nil.
void FetchImageDataWebpDecoded(
const GURL& image_url,
ImageDataFetcherBlock callback,
const std::string& referrer,
net::URLRequest::ReferrerPolicy referrer_policy,
bool send_cookies = false);
// Test-only accessor for underlying ImageDataFetcher.
ImageDataFetcher* AccessImageDataFetcherForTesting() {
return &image_data_fetcher_;
ImageDataFetcherCallback CallbackForImageDataFetcher(
ImageDataFetcherBlock callback);
ImageDataFetcher image_data_fetcher_;
} // namespace image_fetcher