OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 CHROME_BROWSER_RENDERER_HOST_CROSS_SITE_RESOURCE_HANDLER_H_ | 5 #ifndef CHROME_BROWSER_RENDERER_HOST_CROSS_SITE_RESOURCE_HANDLER_H_ |
6 #define CHROME_BROWSER_RENDERER_HOST_CROSS_SITE_RESOURCE_HANDLER_H_ | 6 #define CHROME_BROWSER_RENDERER_HOST_CROSS_SITE_RESOURCE_HANDLER_H_ |
7 | 7 |
8 #include "chrome/browser/renderer_host/resource_dispatcher_host.h" | 8 #include "chrome/browser/renderer_host/resource_dispatcher_host.h" |
9 #include "chrome/browser/renderer_host/resource_handler.h" | 9 #include "chrome/browser/renderer_host/resource_handler.h" |
10 | 10 |
11 // Ensures that cross-site responses are delayed until the onunload handler of | 11 // Ensures that cross-site responses are delayed until the onunload handler of |
12 // the previous page is allowed to run. This handler wraps an | 12 // the previous page is allowed to run. This handler wraps an |
13 // AsyncEventHandler, and it sits inside SafeBrowsing and Buffered event | 13 // AsyncEventHandler, and it sits inside SafeBrowsing and Buffered event |
14 // handlers. This is important, so that it can intercept OnResponseStarted | 14 // handlers. This is important, so that it can intercept OnResponseStarted |
15 // after we determine that a response is safe and not a download. | 15 // after we determine that a response is safe and not a download. |
16 class CrossSiteResourceHandler : public ResourceHandler { | 16 class CrossSiteResourceHandler : public ResourceHandler { |
17 public: | 17 public: |
18 CrossSiteResourceHandler(ResourceHandler* handler, | 18 CrossSiteResourceHandler(ResourceHandler* handler, |
19 int render_process_host_id, | 19 int render_process_host_id, |
20 int render_view_id, | 20 int render_view_id, |
21 ResourceDispatcherHost* resource_dispatcher_host); | 21 ResourceDispatcherHost* resource_dispatcher_host); |
22 | 22 |
23 // ResourceHandler implementation: | 23 // ResourceHandler implementation: |
24 bool OnRequestRedirected(int request_id, const GURL& new_url); | 24 bool OnRequestRedirected(int request_id, const GURL& new_url); |
25 bool OnResponseStarted(int request_id, | 25 bool OnResponseStarted(int request_id, |
26 ResourceResponse* response); | 26 ResourceResponse* response); |
27 bool OnWillRead(int request_id, char** buf, int* buf_size, int min_size); | 27 bool OnWillRead(int request_id, net::IOBuffer** buf, int* buf_size, |
| 28 int min_size); |
28 bool OnReadCompleted(int request_id, int* bytes_read); | 29 bool OnReadCompleted(int request_id, int* bytes_read); |
29 bool OnResponseCompleted(int request_id, const URLRequestStatus& status); | 30 bool OnResponseCompleted(int request_id, const URLRequestStatus& status); |
30 | 31 |
31 // We can now send the response to the new renderer, which will cause | 32 // We can now send the response to the new renderer, which will cause |
32 // WebContents to swap in the new renderer and destroy the old one. | 33 // WebContents to swap in the new renderer and destroy the old one. |
33 void ResumeResponse(); | 34 void ResumeResponse(); |
34 | 35 |
35 private: | 36 private: |
36 // Prepare to render the cross-site response in a new RenderViewHost, by | 37 // Prepare to render the cross-site response in a new RenderViewHost, by |
37 // telling the old RenderViewHost to run its onunload handler. | 38 // telling the old RenderViewHost to run its onunload handler. |
(...skipping 10 matching lines...) Expand all Loading... |
48 int request_id_; | 49 int request_id_; |
49 bool completed_during_transition_; | 50 bool completed_during_transition_; |
50 URLRequestStatus completed_status_; | 51 URLRequestStatus completed_status_; |
51 ResourceResponse* response_; | 52 ResourceResponse* response_; |
52 ResourceDispatcherHost* rdh_; | 53 ResourceDispatcherHost* rdh_; |
53 | 54 |
54 DISALLOW_COPY_AND_ASSIGN(CrossSiteResourceHandler); | 55 DISALLOW_COPY_AND_ASSIGN(CrossSiteResourceHandler); |
55 }; | 56 }; |
56 | 57 |
57 #endif // CHROME_BROWSER_RENDERER_HOST_CROSS_SITE_RESOURCE_HANDLER_H_ | 58 #endif // CHROME_BROWSER_RENDERER_HOST_CROSS_SITE_RESOURCE_HANDLER_H_ |
OLD | NEW |