Index: ios/web/public/web_state/web_state.h |
diff --git a/ios/web/public/web_state/web_state.h b/ios/web/public/web_state/web_state.h |
index c54cbad34544e7e05d76704662209acf42d30efc..ec3f46422b91097f71a0836c530ae35eaaa8ba8d 100644 |
--- a/ios/web/public/web_state/web_state.h |
+++ b/ios/web/public/web_state/web_state.h |
@@ -21,6 +21,7 @@ |
#include "url/gurl.h" |
class GURL; |
+class SkBitmap; |
@class CRWJSInjectionReceiver; |
@class CRWSessionStorage; |
@@ -82,6 +83,19 @@ |
// Whether this navigation is initiated by the renderer process. |
bool is_renderer_initiated; |
}; |
+ |
+ // Callback for |DownloadImage()|. |
+ typedef base::Callback<void( |
+ int, /* id */ |
+ int, /* HTTP status code */ |
+ const GURL&, /* image_url */ |
+ const std::vector<SkBitmap>&, /* bitmaps */ |
+ /* The sizes in pixel of the bitmaps before they were resized due to the |
+ max bitmap size passed to DownloadImage(). Each entry in the bitmaps |
+ vector corresponds to an entry in the sizes vector. If a bitmap was |
+ resized, there should be a single returned bitmap. */ |
+ const std::vector<gfx::Size>&)> |
+ ImageDownloadCallback; |
// Creates a new WebState. |
static std::unique_ptr<WebState> Create(const CreateParams& params); |
@@ -227,6 +241,23 @@ |
// Returns the current CRWWebViewProxy object. |
virtual CRWWebViewProxyType GetWebViewProxy() const = 0; |
+ // Sends a request to download the given image |url| and returns the unique |
+ // id of the download request. When the download is finished, |callback| will |
+ // be called with the bitmaps received from the renderer. |
+ // If |is_favicon| is true, the cookies are not sent and not accepted during |
+ // download. |
+ // Bitmaps with pixel sizes larger than |max_bitmap_size| are filtered out |
+ // from the bitmap results. If there are no bitmap results <= |
+ // |max_bitmap_size|, the smallest bitmap is resized to |max_bitmap_size| and |
+ // is the only result. A |max_bitmap_size| of 0 means unlimited. |
+ // If |bypass_cache| is true, |url| is requested from the server even if it |
+ // is present in the browser cache. |
+ virtual int DownloadImage(const GURL& url, |
+ bool is_favicon, |
+ uint32_t max_bitmap_size, |
+ bool bypass_cache, |
+ const ImageDownloadCallback& callback) = 0; |
+ |
// Returns Mojo interface registry for this WebState. |
virtual service_manager::InterfaceRegistry* GetMojoInterfaceRegistry() = 0; |