| 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, net::IOBuffer** buf, int* buf_size, | 27 bool OnWillRead(int request_id, net::IOBuffer** buf, int* buf_size, |
| 28 int min_size); | 28 int min_size); |
| 29 bool OnReadCompleted(int request_id, int* bytes_read); | 29 bool OnReadCompleted(int request_id, int* bytes_read); |
| 30 bool OnResponseCompleted(int request_id, const URLRequestStatus& status); | 30 bool OnResponseCompleted(int request_id, |
| 31 const URLRequestStatus& status, |
| 32 const std::string& security_info); |
| 31 | 33 |
| 32 // We can now send the response to the new renderer, which will cause | 34 // We can now send the response to the new renderer, which will cause |
| 33 // WebContents to swap in the new renderer and destroy the old one. | 35 // WebContents to swap in the new renderer and destroy the old one. |
| 34 void ResumeResponse(); | 36 void ResumeResponse(); |
| 35 | 37 |
| 36 private: | 38 private: |
| 37 // Prepare to render the cross-site response in a new RenderViewHost, by | 39 // Prepare to render the cross-site response in a new RenderViewHost, by |
| 38 // telling the old RenderViewHost to run its onunload handler. | 40 // telling the old RenderViewHost to run its onunload handler. |
| 39 void StartCrossSiteTransition( | 41 void StartCrossSiteTransition( |
| 40 int request_id, | 42 int request_id, |
| 41 ResourceResponse* response, | 43 ResourceResponse* response, |
| 42 ResourceDispatcherHost::GlobalRequestID global_id); | 44 ResourceDispatcherHost::GlobalRequestID global_id); |
| 43 | 45 |
| 44 scoped_refptr<ResourceHandler> next_handler_; | 46 scoped_refptr<ResourceHandler> next_handler_; |
| 45 int render_process_host_id_; | 47 int render_process_host_id_; |
| 46 int render_view_id_; | 48 int render_view_id_; |
| 47 bool has_started_response_; | 49 bool has_started_response_; |
| 48 bool in_cross_site_transition_; | 50 bool in_cross_site_transition_; |
| 49 int request_id_; | 51 int request_id_; |
| 50 bool completed_during_transition_; | 52 bool completed_during_transition_; |
| 51 URLRequestStatus completed_status_; | 53 URLRequestStatus completed_status_; |
| 54 std::string completed_security_info_; |
| 52 ResourceResponse* response_; | 55 ResourceResponse* response_; |
| 53 ResourceDispatcherHost* rdh_; | 56 ResourceDispatcherHost* rdh_; |
| 54 | 57 |
| 55 DISALLOW_COPY_AND_ASSIGN(CrossSiteResourceHandler); | 58 DISALLOW_COPY_AND_ASSIGN(CrossSiteResourceHandler); |
| 56 }; | 59 }; |
| 57 | 60 |
| 58 #endif // CHROME_BROWSER_RENDERER_HOST_CROSS_SITE_RESOURCE_HANDLER_H_ | 61 #endif // CHROME_BROWSER_RENDERER_HOST_CROSS_SITE_RESOURCE_HANDLER_H_ |
| OLD | NEW |