| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "chrome/browser/renderer_host/intercept_navigation_resource_throttle.h" | 5 #include "chrome/browser/renderer_host/intercept_navigation_resource_throttle.h" |
| 6 | 6 |
| 7 #include "content/public/browser/browser_thread.h" | 7 #include "content/public/browser/browser_thread.h" |
| 8 #include "content/public/browser/child_process_security_policy.h" | 8 #include "content/public/browser/child_process_security_policy.h" |
| 9 #include "content/public/browser/render_view_host.h" | 9 #include "content/public/browser/render_view_host.h" |
| 10 #include "content/public/browser/render_process_host.h" | 10 #include "content/public/browser/render_process_host.h" |
| 11 #include "content/public/browser/resource_request_info.h" | 11 #include "content/public/browser/resource_request_info.h" |
| 12 #include "content/public/browser/resource_controller.h" | 12 #include "content/public/browser/resource_controller.h" |
| 13 #include "content/public/browser/web_contents.h" | |
| 14 #include "content/public/browser/web_contents_delegate.h" | |
| 15 #include "content/public/common/referrer.h" | 13 #include "content/public/common/referrer.h" |
| 14 #include "net/base/net_errors.h" |
| 16 #include "net/url_request/url_request.h" | 15 #include "net/url_request/url_request.h" |
| 17 | 16 |
| 18 using content::BrowserThread; | 17 using content::BrowserThread; |
| 19 using content::ChildProcessSecurityPolicy; | 18 using content::ChildProcessSecurityPolicy; |
| 20 using content::Referrer; | 19 using content::Referrer; |
| 21 using content::RenderViewHost; | 20 using content::RenderViewHost; |
| 22 using content::ResourceRequestInfo; | 21 using content::ResourceRequestInfo; |
| 23 using content::WebContents; | |
| 24 using content::WebContentsDelegate; | |
| 25 | 22 |
| 26 namespace { | 23 namespace { |
| 27 | 24 |
| 28 void CheckIfShouldIgnoreNavigationOnUIThread( | 25 void CheckIfShouldIgnoreNavigationOnUIThread( |
| 29 int render_process_id, | 26 int render_process_id, |
| 30 int render_view_id, | 27 int render_view_id, |
| 31 const GURL& url, | 28 const GURL& url, |
| 32 const Referrer& referrer, | 29 const Referrer& referrer, |
| 33 bool is_content_initiated, | 30 bool is_content_initiated, |
| 34 InterceptNavigationResourceThrottle::CheckOnUIThreadCallback | 31 InterceptNavigationResourceThrottle::CheckOnUIThreadCallback |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 // Defer request while we wait for the UI thread to check if the navigation | 108 // Defer request while we wait for the UI thread to check if the navigation |
| 112 // should be ignored. | 109 // should be ignored. |
| 113 return true; | 110 return true; |
| 114 } | 111 } |
| 115 | 112 |
| 116 void InterceptNavigationResourceThrottle::OnResultObtained( | 113 void InterceptNavigationResourceThrottle::OnResultObtained( |
| 117 bool should_ignore_navigation) { | 114 bool should_ignore_navigation) { |
| 118 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 115 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 119 | 116 |
| 120 if (should_ignore_navigation) { | 117 if (should_ignore_navigation) { |
| 121 // TODO(mkosiba): Cancel() results in a CANCELLED status but what we really | 118 controller()->CancelWithError(net::OK_HANDLED_EXTERNALLY); |
| 122 // want is a HANDLED_EXTERNALLY status. | |
| 123 controller()->Cancel(); | |
| 124 } else { | 119 } else { |
| 125 controller()->Resume(); | 120 controller()->Resume(); |
| 126 } | 121 } |
| 127 } | 122 } |
| OLD | NEW |