Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(513)

Side by Side Diff: content/renderer/image_loading_helper.h

Issue 934693002: Reload favicon from HTTP cache on Ctrl+Refresh (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
11 #include "base/memory/scoped_vector.h" 11 #include "base/memory/scoped_vector.h"
12 #include "content/public/renderer/render_frame_observer.h" 12 #include "content/public/renderer/render_frame_observer.h"
13 #include "third_party/WebKit/public/platform/WebURLRequest.h"
13 #include "url/gurl.h" 14 #include "url/gurl.h"
14 15
15 class SkBitmap; 16 class SkBitmap;
16 17
17 namespace content { 18 namespace content {
18 19
19 class MultiResolutionImageResourceFetcher; 20 class MultiResolutionImageResourceFetcher;
20 21
21 // This class deals with image downloading. 22 // This class deals with image downloading.
22 // One instance of ImageLoadingHelper is owned by RenderFrame. 23 // One instance of ImageLoadingHelper is owned by RenderFrame.
23 class ImageLoadingHelper : public RenderFrameObserver { 24 class ImageLoadingHelper : public RenderFrameObserver {
24 public: 25 public:
25 explicit ImageLoadingHelper(RenderFrame* render_frame); 26 explicit ImageLoadingHelper(RenderFrame* render_frame);
26 27
27 private: 28 private:
28 ~ImageLoadingHelper() override; 29 ~ImageLoadingHelper() override;
29 30
30 // Message handler. 31 // Message handler.
31 void OnDownloadImage(int id, 32 void OnDownloadImage(int id,
32 const GURL& image_url, 33 const GURL& image_url,
33 bool is_favicon, 34 bool is_favicon,
34 uint32_t max_image_size); 35 uint32_t max_image_size,
36 blink::WebURLRequest::CachePolicy cache_policy);
35 37
36 // Requests to download an image. When done, the ImageLoadingHelper 38 // Requests to download an image. When done, the ImageLoadingHelper
37 // is notified by way of DidDownloadImage. Returns true if the 39 // is notified by way of DidDownloadImage. Returns true if the
38 // request was successfully started, false otherwise. id is used to 40 // request was successfully started, false otherwise. id is used to
39 // uniquely identify the request and passed back to the 41 // uniquely identify the request and passed back to the
40 // DidDownloadImage method. If the image is a favicon, cookies will not be 42 // 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 43 // 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 44 // 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 45 // 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 46 // |max_image_size| and is the only result. |max_image_size| == 0 is
45 // interpreted as no max image size. 47 // interpreted as no max image size.
46 bool DownloadImage(int id, 48 bool DownloadImage(int id,
47 const GURL& image_url, 49 const GURL& image_url,
48 bool is_favicon, 50 bool is_favicon,
49 uint32_t max_image_size); 51 uint32_t max_image_size,
52 blink::WebURLRequest::CachePolicy cache_policy);
50 53
51 // This callback is triggered when DownloadImage completes, either 54 // This callback is triggered when DownloadImage completes, either
52 // succesfully or with a failure. See DownloadImage for more 55 // succesfully or with a failure. See DownloadImage for more
53 // details. 56 // details.
54 void DidDownloadImage( 57 void DidDownloadImage(
55 uint32_t max_image_size, 58 uint32_t max_image_size,
56 MultiResolutionImageResourceFetcher* fetcher, 59 MultiResolutionImageResourceFetcher* fetcher,
57 const std::vector<SkBitmap>& images); 60 const std::vector<SkBitmap>& images);
58 61
59 // Decodes a data: URL image or returns an empty image in case of failure. 62 // Decodes a data: URL image or returns an empty image in case of failure.
60 SkBitmap ImageFromDataUrl(const GURL&) const; 63 SkBitmap ImageFromDataUrl(const GURL&) const;
61 64
62 // RenderFrameObserver implementation. 65 // RenderFrameObserver implementation.
63 bool OnMessageReceived(const IPC::Message& message) override; 66 bool OnMessageReceived(const IPC::Message& message) override;
64 67
65 typedef ScopedVector<MultiResolutionImageResourceFetcher> 68 typedef ScopedVector<MultiResolutionImageResourceFetcher>
66 ImageResourceFetcherList; 69 ImageResourceFetcherList;
67 70
68 // ImageResourceFetchers schedule via DownloadImage. 71 // ImageResourceFetchers schedule via DownloadImage.
69 ImageResourceFetcherList image_fetchers_; 72 ImageResourceFetcherList image_fetchers_;
70 73
71 DISALLOW_COPY_AND_ASSIGN(ImageLoadingHelper); 74 DISALLOW_COPY_AND_ASSIGN(ImageLoadingHelper);
72 }; 75 };
73 76
74 } // namespace content 77 } // namespace content
75 78
76 #endif // CONTENT_RENDERER_IMAGE_LOADING_HELPER_H_ 79 #endif // CONTENT_RENDERER_IMAGE_LOADING_HELPER_H_
77 80
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698