OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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_BROWSER_RENDERER_HOST_CROSS_SITE_RESOURCE_HANDLER_H_ | 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_CROSS_SITE_RESOURCE_HANDLER_H_ |
6 #define CONTENT_BROWSER_RENDERER_HOST_CROSS_SITE_RESOURCE_HANDLER_H_ | 6 #define CONTENT_BROWSER_RENDERER_HOST_CROSS_SITE_RESOURCE_HANDLER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "content/browser/renderer_host/resource_handler.h" | 9 #include "content/browser/renderer_host/resource_handler.h" |
10 #include "net/url_request/url_request_status.h" | 10 #include "net/url_request/url_request_status.h" |
11 | 11 |
12 class ResourceDispatcherHost; | 12 class ResourceDispatcherHost; |
13 struct GlobalRequestID; | 13 struct GlobalRequestID; |
14 | 14 |
15 // Ensures that cross-site responses are delayed until the onunload handler of | 15 // Ensures that cross-site responses are delayed until the onunload handler of |
16 // the previous page is allowed to run. This handler wraps an | 16 // the previous page is allowed to run. This handler wraps an |
17 // AsyncEventHandler, and it sits inside SafeBrowsing and Buffered event | 17 // AsyncEventHandler, and it sits inside SafeBrowsing and Buffered event |
18 // handlers. This is important, so that it can intercept OnResponseStarted | 18 // handlers. This is important, so that it can intercept OnResponseStarted |
19 // after we determine that a response is safe and not a download. | 19 // after we determine that a response is safe and not a download. |
20 class CrossSiteResourceHandler : public ResourceHandler { | 20 class CrossSiteResourceHandler : public ResourceHandler { |
21 public: | 21 public: |
22 CrossSiteResourceHandler(ResourceHandler* handler, | 22 CrossSiteResourceHandler(ResourceHandler* handler, |
23 int render_process_host_id, | 23 int render_process_host_id, |
24 int render_view_id, | 24 int render_view_id, |
25 ResourceDispatcherHost* resource_dispatcher_host); | 25 ResourceDispatcherHost* resource_dispatcher_host); |
26 | 26 |
27 // ResourceHandler implementation: | 27 // ResourceHandler implementation: |
28 virtual bool OnUploadProgress(int request_id, uint64 position, uint64 size); | 28 virtual bool OnUploadProgress(int request_id, |
29 virtual bool OnRequestRedirected(int request_id, const GURL& new_url, | 29 uint64 position, |
30 ResourceResponse* response, bool* defer); | 30 uint64 size) OVERRIDE; |
| 31 virtual bool OnRequestRedirected(int request_id, |
| 32 const GURL& new_url, |
| 33 ResourceResponse* response, |
| 34 bool* defer) OVERRIDE; |
31 virtual bool OnResponseStarted(int request_id, | 35 virtual bool OnResponseStarted(int request_id, |
32 ResourceResponse* response); | 36 ResourceResponse* response) OVERRIDE; |
33 virtual bool OnWillStart(int request_id, const GURL& url, bool* defer); | 37 virtual bool OnWillStart(int request_id, |
34 virtual bool OnWillRead(int request_id, net::IOBuffer** buf, int* buf_size, | 38 const GURL& url, |
35 int min_size); | 39 bool* defer) OVERRIDE; |
36 virtual bool OnReadCompleted(int request_id, int* bytes_read); | 40 virtual bool OnWillRead(int request_id, |
| 41 net::IOBuffer** buf, |
| 42 int* buf_size, |
| 43 int min_size) OVERRIDE; |
| 44 virtual bool OnReadCompleted(int request_id, |
| 45 int* bytes_read) OVERRIDE; |
37 virtual bool OnResponseCompleted(int request_id, | 46 virtual bool OnResponseCompleted(int request_id, |
38 const net::URLRequestStatus& status, | 47 const net::URLRequestStatus& status, |
39 const std::string& security_info); | 48 const std::string& security_info) OVERRIDE; |
40 virtual void OnRequestClosed(); | 49 virtual void OnRequestClosed() OVERRIDE; |
41 | 50 |
42 // We can now send the response to the new renderer, which will cause | 51 // We can now send the response to the new renderer, which will cause |
43 // TabContents to swap in the new renderer and destroy the old one. | 52 // TabContents to swap in the new renderer and destroy the old one. |
44 void ResumeResponse(); | 53 void ResumeResponse(); |
45 | 54 |
46 private: | 55 private: |
47 virtual ~CrossSiteResourceHandler(); | 56 virtual ~CrossSiteResourceHandler(); |
48 | 57 |
49 // Prepare to render the cross-site response in a new RenderViewHost, by | 58 // Prepare to render the cross-site response in a new RenderViewHost, by |
50 // telling the old RenderViewHost to run its onunload handler. | 59 // telling the old RenderViewHost to run its onunload handler. |
(...skipping 11 matching lines...) Expand all Loading... |
62 bool completed_during_transition_; | 71 bool completed_during_transition_; |
63 net::URLRequestStatus completed_status_; | 72 net::URLRequestStatus completed_status_; |
64 std::string completed_security_info_; | 73 std::string completed_security_info_; |
65 ResourceResponse* response_; | 74 ResourceResponse* response_; |
66 ResourceDispatcherHost* rdh_; | 75 ResourceDispatcherHost* rdh_; |
67 | 76 |
68 DISALLOW_COPY_AND_ASSIGN(CrossSiteResourceHandler); | 77 DISALLOW_COPY_AND_ASSIGN(CrossSiteResourceHandler); |
69 }; | 78 }; |
70 | 79 |
71 #endif // CONTENT_BROWSER_RENDERER_HOST_CROSS_SITE_RESOURCE_HANDLER_H_ | 80 #endif // CONTENT_BROWSER_RENDERER_HOST_CROSS_SITE_RESOURCE_HANDLER_H_ |
OLD | NEW |