Fix build break
[chromium-blink-merge.git] / content / renderer / image_loading_helper.h
blob6e2302de603c97755c75587f4676ba2fe45dd7de
1 // Copyright (c) 2013 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 CONTENT_RENDERER_IMAGE_LOADING_HELPER_H_
6 #define CONTENT_RENDERER_IMAGE_LOADING_HELPER_H_
8 #include <string>
9 #include <vector>
11 #include "base/memory/scoped_vector.h"
12 #include "content/public/renderer/render_view_observer.h"
13 #include "googleurl/src/gurl.h"
15 class SkBitmap;
17 namespace webkit_glue {
18 class MultiResolutionImageResourceFetcher;
21 namespace content {
23 // This class deals with image downloading.
24 // One instance of ImageLoadingHelper is owned by RenderView.
25 class ImageLoadingHelper : public RenderViewObserver {
26 public:
27 explicit ImageLoadingHelper(RenderView* render_view);
29 private:
30 virtual ~ImageLoadingHelper();
32 // Message handler.
33 void OnDownloadImage(int id,
34 const GURL& image_url,
35 bool is_favicon,
36 int image_size);
38 // Requests to download an image. When done, the ImageLoadingHelper
39 // is notified by way of DidDownloadImage. Returns true if the
40 // request was successfully started, false otherwise. id is used to
41 // uniquely identify the request and passed back to the
42 // DidDownloadImage method. If the image is a favicon, cookies will not be
43 // sent nor accepted during download. If the image has multiple frames, the
44 // frame whose size is image_size is returned. If the image doesn't
45 // have a frame at the specified size, the first is returned.
46 bool DownloadImage(int id,
47 const GURL& image_url,
48 bool is_favicon,
49 int image_size);
51 // This callback is triggered when DownloadImage completes, either
52 // succesfully or with a failure. See DownloadImage for more
53 // details.
54 void DidDownloadImage(
55 int requested_size,
56 webkit_glue::MultiResolutionImageResourceFetcher* fetcher,
57 const std::vector<SkBitmap>& images);
59 // Decodes a data: URL image or returns an empty image in case of failure.
60 SkBitmap ImageFromDataUrl(const GURL&) const;
62 // RenderViewObserver implementation.
63 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
65 typedef ScopedVector<webkit_glue::MultiResolutionImageResourceFetcher>
66 ImageResourceFetcherList;
68 // ImageResourceFetchers schedule via DownloadImage.
69 ImageResourceFetcherList image_fetchers_;
71 DISALLOW_COPY_AND_ASSIGN(ImageLoadingHelper);
74 } // namespace content
76 #endif // CONTENT_RENDERER_IMAGE_LOADING_HELPER_H_