Display new Autofill UI Contents in Views
[chromium-blink-merge.git] / webkit / glue / image_resource_fetcher.h
blobd1a4f7d6eac8c38f2cd3edd0b36da59cdeb21286
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"
13 class SkBitmap;
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 {
21 public:
22 typedef base::Callback<void(ImageResourceFetcher*, const SkBitmap&)> Callback;
24 WEBKIT_GLUE_EXPORT ImageResourceFetcher(
25 const GURL& image_url,
26 WebKit::WebFrame* frame,
27 int id,
28 int image_size,
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_; }
40 private:
41 // ResourceFetcher::Callback. Decodes the image and invokes callback_.
42 void OnURLFetchComplete(const WebKit::WebURLResponse& response,
43 const std::string& data);
45 Callback callback_;
47 // Unique identifier for the request.
48 const int id_;
50 // URL of the image.
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
55 // of the image.
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_