OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "content/browser/loader/navigation_resource_throttle.h" | 5 #include "content/browser/loader/navigation_resource_throttle.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 UIChecksPerformedCallback callback, | 92 UIChecksPerformedCallback callback, |
93 int render_process_id, | 93 int render_process_id, |
94 int render_frame_host_id, | 94 int render_frame_host_id, |
95 const std::string& method, | 95 const std::string& method, |
96 const scoped_refptr<content::ResourceRequestBodyImpl>& | 96 const scoped_refptr<content::ResourceRequestBodyImpl>& |
97 resource_request_body, | 97 resource_request_body, |
98 const Referrer& sanitized_referrer, | 98 const Referrer& sanitized_referrer, |
99 bool has_user_gesture, | 99 bool has_user_gesture, |
100 ui::PageTransition transition, | 100 ui::PageTransition transition, |
101 bool is_external_protocol, | 101 bool is_external_protocol, |
102 RequestContextType request_context_type) { | 102 RequestContextType request_context_type, |
| 103 blink::WebMixedContent::ContextType mixed_content_context_type) { |
103 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 104 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
104 NavigationHandleImpl* navigation_handle = | 105 NavigationHandleImpl* navigation_handle = |
105 FindNavigationHandle(render_process_id, render_frame_host_id, callback); | 106 FindNavigationHandle(render_process_id, render_frame_host_id, callback); |
106 if (!navigation_handle) | 107 if (!navigation_handle) |
107 return; | 108 return; |
108 | 109 |
109 navigation_handle->WillStartRequest( | 110 navigation_handle->WillStartRequest( |
110 method, resource_request_body, sanitized_referrer, has_user_gesture, | 111 method, resource_request_body, sanitized_referrer, has_user_gesture, |
111 transition, is_external_protocol, request_context_type, | 112 transition, is_external_protocol, request_context_type, |
| 113 mixed_content_context_type, |
112 base::Bind(&SendCheckResultToIOThread, callback)); | 114 base::Bind(&SendCheckResultToIOThread, callback)); |
113 } | 115 } |
114 | 116 |
115 void CheckWillRedirectRequestOnUIThread( | 117 void CheckWillRedirectRequestOnUIThread( |
116 UIChecksPerformedCallback callback, | 118 UIChecksPerformedCallback callback, |
117 int render_process_id, | 119 int render_process_id, |
118 int render_frame_host_id, | 120 int render_frame_host_id, |
119 const GURL& new_url, | 121 const GURL& new_url, |
120 const std::string& new_method, | 122 const std::string& new_method, |
121 const GURL& new_referrer_url, | 123 const GURL& new_referrer_url, |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 render_frame_host, headers, connection_info, ssl_status, request_id, | 173 render_frame_host, headers, connection_info, ssl_status, request_id, |
172 should_replace_current_entry, is_download, is_stream, transfer_callback, | 174 should_replace_current_entry, is_download, is_stream, transfer_callback, |
173 base::Bind(&SendCheckResultToIOThread, callback)); | 175 base::Bind(&SendCheckResultToIOThread, callback)); |
174 } | 176 } |
175 | 177 |
176 } // namespace | 178 } // namespace |
177 | 179 |
178 NavigationResourceThrottle::NavigationResourceThrottle( | 180 NavigationResourceThrottle::NavigationResourceThrottle( |
179 net::URLRequest* request, | 181 net::URLRequest* request, |
180 ResourceDispatcherHostDelegate* resource_dispatcher_host_delegate, | 182 ResourceDispatcherHostDelegate* resource_dispatcher_host_delegate, |
181 RequestContextType request_context_type) | 183 RequestContextType request_context_type, |
| 184 blink::WebMixedContent::ContextType mixed_content_context_type) |
182 : request_(request), | 185 : request_(request), |
183 resource_dispatcher_host_delegate_(resource_dispatcher_host_delegate), | 186 resource_dispatcher_host_delegate_(resource_dispatcher_host_delegate), |
184 request_context_type_(request_context_type), | 187 request_context_type_(request_context_type), |
| 188 mixed_content_context_type_(mixed_content_context_type), |
185 in_cross_site_transition_(false), | 189 in_cross_site_transition_(false), |
186 on_transfer_done_result_(NavigationThrottle::DEFER), | 190 on_transfer_done_result_(NavigationThrottle::DEFER), |
187 weak_ptr_factory_(this) {} | 191 weak_ptr_factory_(this) {} |
188 | 192 |
189 NavigationResourceThrottle::~NavigationResourceThrottle() {} | 193 NavigationResourceThrottle::~NavigationResourceThrottle() {} |
190 | 194 |
191 void NavigationResourceThrottle::WillStartRequest(bool* defer) { | 195 void NavigationResourceThrottle::WillStartRequest(bool* defer) { |
192 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 196 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
193 const ResourceRequestInfoImpl* info = | 197 const ResourceRequestInfoImpl* info = |
194 ResourceRequestInfoImpl::ForRequest(request_); | 198 ResourceRequestInfoImpl::ForRequest(request_); |
(...skipping 12 matching lines...) Expand all Loading... |
207 weak_ptr_factory_.GetWeakPtr()); | 211 weak_ptr_factory_.GetWeakPtr()); |
208 DCHECK(request_->method() == "POST" || request_->method() == "GET"); | 212 DCHECK(request_->method() == "POST" || request_->method() == "GET"); |
209 BrowserThread::PostTask( | 213 BrowserThread::PostTask( |
210 BrowserThread::UI, FROM_HERE, | 214 BrowserThread::UI, FROM_HERE, |
211 base::Bind(&CheckWillStartRequestOnUIThread, callback, render_process_id, | 215 base::Bind(&CheckWillStartRequestOnUIThread, callback, render_process_id, |
212 render_frame_id, request_->method(), info->body(), | 216 render_frame_id, request_->method(), info->body(), |
213 Referrer::SanitizeForRequest( | 217 Referrer::SanitizeForRequest( |
214 request_->url(), Referrer(GURL(request_->referrer()), | 218 request_->url(), Referrer(GURL(request_->referrer()), |
215 info->GetReferrerPolicy())), | 219 info->GetReferrerPolicy())), |
216 info->HasUserGesture(), info->GetPageTransition(), | 220 info->HasUserGesture(), info->GetPageTransition(), |
217 is_external_protocol, request_context_type_)); | 221 is_external_protocol, request_context_type_, |
| 222 mixed_content_context_type_)); |
218 *defer = true; | 223 *defer = true; |
219 } | 224 } |
220 | 225 |
221 void NavigationResourceThrottle::WillRedirectRequest( | 226 void NavigationResourceThrottle::WillRedirectRequest( |
222 const net::RedirectInfo& redirect_info, | 227 const net::RedirectInfo& redirect_info, |
223 bool* defer) { | 228 bool* defer) { |
224 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 229 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
225 ResourceRequestInfoImpl* info = ResourceRequestInfoImpl::ForRequest(request_); | 230 ResourceRequestInfoImpl* info = ResourceRequestInfoImpl::ForRequest(request_); |
226 if (!info) | 231 if (!info) |
227 return; | 232 return; |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
378 | 383 |
379 // If the results of the checks on the UI thread are known, unblock the | 384 // If the results of the checks on the UI thread are known, unblock the |
380 // navigation. Otherwise, wait until the callback has executed. | 385 // navigation. Otherwise, wait until the callback has executed. |
381 if (on_transfer_done_result_ != NavigationThrottle::DEFER) { | 386 if (on_transfer_done_result_ != NavigationThrottle::DEFER) { |
382 OnUIChecksPerformed(on_transfer_done_result_); | 387 OnUIChecksPerformed(on_transfer_done_result_); |
383 on_transfer_done_result_ = NavigationThrottle::DEFER; | 388 on_transfer_done_result_ = NavigationThrottle::DEFER; |
384 } | 389 } |
385 } | 390 } |
386 | 391 |
387 } // namespace content | 392 } // namespace content |
OLD | NEW |