OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CONTENT_RENDERER_IMAGE_LOADING_HELPER_H_ | 5 #ifndef CONTENT_RENDERER_IMAGE_LOADING_HELPER_H_ |
6 #define CONTENT_RENDERER_IMAGE_LOADING_HELPER_H_ | 6 #define CONTENT_RENDERER_IMAGE_LOADING_HELPER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 13 matching lines...) Expand all Loading... |
24 public: | 24 public: |
25 explicit ImageLoadingHelper(RenderFrame* render_frame); | 25 explicit ImageLoadingHelper(RenderFrame* render_frame); |
26 | 26 |
27 private: | 27 private: |
28 ~ImageLoadingHelper() override; | 28 ~ImageLoadingHelper() override; |
29 | 29 |
30 // Message handler. | 30 // Message handler. |
31 void OnDownloadImage(int id, | 31 void OnDownloadImage(int id, |
32 const GURL& image_url, | 32 const GURL& image_url, |
33 bool is_favicon, | 33 bool is_favicon, |
34 uint32_t max_image_size); | 34 uint32_t max_image_size, |
| 35 bool bypass_cache); |
35 | 36 |
36 // Requests to download an image. When done, the ImageLoadingHelper | 37 // Requests to download an image. When done, the ImageLoadingHelper |
37 // is notified by way of DidDownloadImage. Returns true if the | 38 // is notified by way of DidDownloadImage. Returns true if the |
38 // request was successfully started, false otherwise. id is used to | 39 // request was successfully started, false otherwise. id is used to |
39 // uniquely identify the request and passed back to the | 40 // uniquely identify the request and passed back to the |
40 // DidDownloadImage method. If the image is a favicon, cookies will not be | 41 // DidDownloadImage method. If the image is a favicon, cookies will not be |
41 // sent nor accepted during download. If the image has multiple frames, all | 42 // sent nor accepted during download. If the image has multiple frames, all |
42 // the frames whose size <= |max_image_size| are returned. If all of the | 43 // the frames whose size <= |max_image_size| are returned. If all of the |
43 // frames are larger than |max_image_size|, the smallest frame is resized to | 44 // frames are larger than |max_image_size|, the smallest frame is resized to |
44 // |max_image_size| and is the only result. |max_image_size| == 0 is | 45 // |max_image_size| and is the only result. |max_image_size| == 0 is |
45 // interpreted as no max image size. | 46 // interpreted as no max image size. |
46 bool DownloadImage(int id, | 47 bool DownloadImage(int id, |
47 const GURL& image_url, | 48 const GURL& image_url, |
48 bool is_favicon, | 49 bool is_favicon, |
49 uint32_t max_image_size); | 50 uint32_t max_image_size, |
| 51 bool bypass_cache); |
50 | 52 |
51 // This callback is triggered when DownloadImage completes, either | 53 // This callback is triggered when DownloadImage completes, either |
52 // succesfully or with a failure. See DownloadImage for more | 54 // succesfully or with a failure. See DownloadImage for more |
53 // details. | 55 // details. |
54 void DidDownloadImage( | 56 void DidDownloadImage( |
55 uint32_t max_image_size, | 57 uint32_t max_image_size, |
56 MultiResolutionImageResourceFetcher* fetcher, | 58 MultiResolutionImageResourceFetcher* fetcher, |
57 const std::vector<SkBitmap>& images); | 59 const std::vector<SkBitmap>& images); |
58 | 60 |
59 // Decodes a data: URL image or returns an empty image in case of failure. | 61 // Decodes a data: URL image or returns an empty image in case of failure. |
60 SkBitmap ImageFromDataUrl(const GURL&) const; | 62 SkBitmap ImageFromDataUrl(const GURL&) const; |
61 | 63 |
62 // RenderFrameObserver implementation. | 64 // RenderFrameObserver implementation. |
63 bool OnMessageReceived(const IPC::Message& message) override; | 65 bool OnMessageReceived(const IPC::Message& message) override; |
64 | 66 |
65 typedef ScopedVector<MultiResolutionImageResourceFetcher> | 67 typedef ScopedVector<MultiResolutionImageResourceFetcher> |
66 ImageResourceFetcherList; | 68 ImageResourceFetcherList; |
67 | 69 |
68 // ImageResourceFetchers schedule via DownloadImage. | 70 // ImageResourceFetchers schedule via DownloadImage. |
69 ImageResourceFetcherList image_fetchers_; | 71 ImageResourceFetcherList image_fetchers_; |
70 | 72 |
71 DISALLOW_COPY_AND_ASSIGN(ImageLoadingHelper); | 73 DISALLOW_COPY_AND_ASSIGN(ImageLoadingHelper); |
72 }; | 74 }; |
73 | 75 |
74 } // namespace content | 76 } // namespace content |
75 | 77 |
76 #endif // CONTENT_RENDERER_IMAGE_LOADING_HELPER_H_ | 78 #endif // CONTENT_RENDERER_IMAGE_LOADING_HELPER_H_ |
77 | 79 |
OLD | NEW |