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/frame_host/navigation_handle_impl.h" | 5 #include "content/browser/frame_host/navigation_handle_impl.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "content/browser/frame_host/frame_tree_node.h" | 10 #include "content/browser/frame_host/frame_tree_node.h" |
| 11 #include "content/browser/frame_host/mixed_content_navigation_throttle.h" |
11 #include "content/browser/frame_host/navigator.h" | 12 #include "content/browser/frame_host/navigator.h" |
12 #include "content/browser/frame_host/navigator_delegate.h" | 13 #include "content/browser/frame_host/navigator_delegate.h" |
13 #include "content/browser/service_worker/service_worker_context_wrapper.h" | 14 #include "content/browser/service_worker/service_worker_context_wrapper.h" |
14 #include "content/common/frame_messages.h" | 15 #include "content/common/frame_messages.h" |
15 #include "content/common/resource_request_body_impl.h" | 16 #include "content/common/resource_request_body_impl.h" |
16 #include "content/public/browser/content_browser_client.h" | 17 #include "content/public/browser/content_browser_client.h" |
17 #include "content/public/common/browser_side_navigation_policy.h" | 18 #include "content/public/common/browser_side_navigation_policy.h" |
18 #include "content/public/common/content_client.h" | 19 #include "content/public/common/content_client.h" |
19 #include "net/url_request/redirect_info.h" | 20 #include "net/url_request/redirect_info.h" |
20 #include "url/gurl.h" | 21 #include "url/gurl.h" |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
262 if (is_post) { | 263 if (is_post) { |
263 method = "POST"; | 264 method = "POST"; |
264 | 265 |
265 std::string body = "test=body"; | 266 std::string body = "test=body"; |
266 resource_request_body = new ResourceRequestBodyImpl(); | 267 resource_request_body = new ResourceRequestBodyImpl(); |
267 resource_request_body->AppendBytes(body.data(), body.size()); | 268 resource_request_body->AppendBytes(body.data(), body.size()); |
268 } | 269 } |
269 | 270 |
270 WillStartRequest(method, resource_request_body, sanitized_referrer, | 271 WillStartRequest(method, resource_request_body, sanitized_referrer, |
271 has_user_gesture, transition, is_external_protocol, | 272 has_user_gesture, transition, is_external_protocol, |
| 273 REQUEST_CONTEXT_TYPE_LOCATION, |
272 base::Bind(&UpdateThrottleCheckResult, &result)); | 274 base::Bind(&UpdateThrottleCheckResult, &result)); |
273 | 275 |
274 // Reset the callback to ensure it will not be called later. | 276 // Reset the callback to ensure it will not be called later. |
275 complete_callback_.Reset(); | 277 complete_callback_.Reset(); |
276 return result; | 278 return result; |
277 } | 279 } |
278 | 280 |
279 NavigationThrottle::ThrottleCheckResult | 281 NavigationThrottle::ThrottleCheckResult |
280 NavigationHandleImpl::CallWillRedirectRequestForTesting( | 282 NavigationHandleImpl::CallWillRedirectRequestForTesting( |
281 const GURL& new_url, | 283 const GURL& new_url, |
(...skipping 15 matching lines...) Expand all Loading... |
297 return navigation_data_.get(); | 299 return navigation_data_.get(); |
298 } | 300 } |
299 | 301 |
300 void NavigationHandleImpl::WillStartRequest( | 302 void NavigationHandleImpl::WillStartRequest( |
301 const std::string& method, | 303 const std::string& method, |
302 scoped_refptr<content::ResourceRequestBodyImpl> resource_request_body, | 304 scoped_refptr<content::ResourceRequestBodyImpl> resource_request_body, |
303 const Referrer& sanitized_referrer, | 305 const Referrer& sanitized_referrer, |
304 bool has_user_gesture, | 306 bool has_user_gesture, |
305 ui::PageTransition transition, | 307 ui::PageTransition transition, |
306 bool is_external_protocol, | 308 bool is_external_protocol, |
| 309 RequestContextType fetch_request_context_type, |
307 const ThrottleChecksFinishedCallback& callback) { | 310 const ThrottleChecksFinishedCallback& callback) { |
308 // |method != "POST"| should imply absence of |resource_request_body|. | 311 // |method != "POST"| should imply absence of |resource_request_body|. |
309 if (method != "POST" && resource_request_body) { | 312 if (method != "POST" && resource_request_body) { |
310 NOTREACHED(); | 313 NOTREACHED(); |
311 resource_request_body = nullptr; | 314 resource_request_body = nullptr; |
312 } | 315 } |
313 | 316 |
314 // Update the navigation parameters. | 317 // Update the navigation parameters. |
315 method_ = method; | 318 method_ = method; |
316 if (method_ == "POST") | 319 if (method_ == "POST") |
317 resource_request_body_ = resource_request_body; | 320 resource_request_body_ = resource_request_body; |
318 sanitized_referrer_ = sanitized_referrer; | 321 sanitized_referrer_ = sanitized_referrer; |
319 has_user_gesture_ = has_user_gesture; | 322 has_user_gesture_ = has_user_gesture; |
320 transition_ = transition; | 323 transition_ = transition; |
321 is_external_protocol_ = is_external_protocol; | 324 is_external_protocol_ = is_external_protocol; |
322 | 325 fetch_request_context_type_ = fetch_request_context_type; |
323 state_ = WILL_SEND_REQUEST; | 326 state_ = WILL_SEND_REQUEST; |
324 complete_callback_ = callback; | 327 complete_callback_ = callback; |
325 | 328 |
| 329 throttles_.insert(throttles_.end(), new MixedContentNavigationThrottle(this)); |
| 330 |
326 // Register the navigation throttles. The ScopedVector returned by | 331 // Register the navigation throttles. The ScopedVector returned by |
327 // GetNavigationThrottles is not assigned to throttles_ directly because it | 332 // GetNavigationThrottles is not assigned to throttles_ directly because it |
328 // would overwrite any throttle previously added with | 333 // would overwrite any throttle previously added with |
329 // RegisterThrottleForTesting. | 334 // RegisterThrottleForTesting. |
330 ScopedVector<NavigationThrottle> throttles_to_register = | 335 ScopedVector<NavigationThrottle> throttles_to_register = |
331 GetContentClient()->browser()->CreateThrottlesForNavigation(this); | 336 GetContentClient()->browser()->CreateThrottlesForNavigation(this); |
332 if (throttles_to_register.size() > 0) { | 337 if (throttles_to_register.size() > 0) { |
333 throttles_.insert(throttles_.end(), throttles_to_register.begin(), | 338 throttles_.insert(throttles_.end(), throttles_to_register.begin(), |
334 throttles_to_register.end()); | 339 throttles_to_register.end()); |
335 throttles_to_register.weak_clear(); | 340 throttles_to_register.weak_clear(); |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
527 complete_callback_.Reset(); | 532 complete_callback_.Reset(); |
528 | 533 |
529 if (!callback.is_null()) | 534 if (!callback.is_null()) |
530 callback.Run(result); | 535 callback.Run(result); |
531 | 536 |
532 // No code after running the callback, as it might have resulted in our | 537 // No code after running the callback, as it might have resulted in our |
533 // destruction. | 538 // destruction. |
534 } | 539 } |
535 | 540 |
536 } // namespace content | 541 } // namespace content |
OLD | NEW |