1 // Copyright (c) 2011 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.
5 #ifndef WEBKIT_GLUE_IMAGE_RESOURCE_FETCHER_H_
6 #define WEBKIT_GLUE_IMAGE_RESOURCE_FETCHER_H_
8 #include "base/basictypes.h"
9 #include "base/callback.h"
10 #include "webkit/glue/resource_fetcher.h"
11 #include "webkit/glue/webkit_glue_export.h"
15 namespace webkit_glue
{
17 // ImageResourceFetcher handles downloading an image for a webview. Once
18 // downloading is done the supplied callback is notified. ImageResourceFetcher
19 // is used to download the favicon and images for web apps.
20 class ImageResourceFetcher
{
22 typedef base::Callback
<void(ImageResourceFetcher
*, const SkBitmap
&)> Callback
;
24 WEBKIT_GLUE_EXPORT
ImageResourceFetcher(
25 const GURL
& image_url
,
26 WebKit::WebFrame
* frame
,
29 WebKit::WebURLRequest::TargetType target_type
,
30 const Callback
& callback
);
32 WEBKIT_GLUE_EXPORT
virtual ~ImageResourceFetcher();
34 // URL of the image we're downloading.
35 const GURL
& image_url() const { return image_url_
; }
37 // Unique identifier for the request.
38 int id() const { return id_
; }
41 // ResourceFetcher::Callback. Decodes the image and invokes callback_.
42 void OnURLFetchComplete(const WebKit::WebURLResponse
& response
,
43 const std::string
& data
);
47 // Unique identifier for the request.
51 const GURL image_url_
;
53 // The size of the image. This is only a hint that is used if the image
54 // contains multiple sizes. A value of 0 results in using the first frame
56 const int image_size_
;
58 // Does the actual download.
59 scoped_ptr
<ResourceFetcher
> fetcher_
;
61 DISALLOW_COPY_AND_ASSIGN(ImageResourceFetcher
);
64 } // namespace webkit_glue
66 #endif // WEBKIT_GLUE_IMAGE_RESOURCE_FETCHER_H_