Chromium Code Reviews| 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/debug/dump_without_crashing.h" | 9 #include "base/debug/dump_without_crashing.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 68 : url_(url), | 68 : url_(url), |
| 69 has_user_gesture_(false), | 69 has_user_gesture_(false), |
| 70 transition_(ui::PAGE_TRANSITION_LINK), | 70 transition_(ui::PAGE_TRANSITION_LINK), |
| 71 is_external_protocol_(false), | 71 is_external_protocol_(false), |
| 72 net_error_code_(net::OK), | 72 net_error_code_(net::OK), |
| 73 render_frame_host_(nullptr), | 73 render_frame_host_(nullptr), |
| 74 is_renderer_initiated_(is_renderer_initiated), | 74 is_renderer_initiated_(is_renderer_initiated), |
| 75 is_same_page_(is_same_page), | 75 is_same_page_(is_same_page), |
| 76 is_srcdoc_(is_srcdoc), | 76 is_srcdoc_(is_srcdoc), |
| 77 was_redirected_(false), | 77 was_redirected_(false), |
| 78 connection_info_(net::HttpResponseInfo::CONNECTION_INFO_UNKNOWN), | |
| 78 original_url_(url), | 79 original_url_(url), |
| 79 state_(INITIAL), | 80 state_(INITIAL), |
| 80 is_transferring_(false), | 81 is_transferring_(false), |
| 81 frame_tree_node_(frame_tree_node), | 82 frame_tree_node_(frame_tree_node), |
| 82 next_index_(0), | 83 next_index_(0), |
| 83 navigation_start_(navigation_start), | 84 navigation_start_(navigation_start), |
| 84 pending_nav_entry_id_(pending_nav_entry_id), | 85 pending_nav_entry_id_(pending_nav_entry_id), |
| 85 request_context_type_(REQUEST_CONTEXT_TYPE_UNSPECIFIED), | 86 request_context_type_(REQUEST_CONTEXT_TYPE_UNSPECIFIED), |
| 86 should_replace_current_entry_(false), | 87 should_replace_current_entry_(false), |
| 87 is_download_(false), | 88 is_download_(false), |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 218 } | 219 } |
| 219 | 220 |
| 220 bool NavigationHandleImpl::IsSamePage() { | 221 bool NavigationHandleImpl::IsSamePage() { |
| 221 return is_same_page_; | 222 return is_same_page_; |
| 222 } | 223 } |
| 223 | 224 |
| 224 const net::HttpResponseHeaders* NavigationHandleImpl::GetResponseHeaders() { | 225 const net::HttpResponseHeaders* NavigationHandleImpl::GetResponseHeaders() { |
| 225 return response_headers_.get(); | 226 return response_headers_.get(); |
| 226 } | 227 } |
| 227 | 228 |
| 229 net::HttpResponseInfo::ConnectionInfo | |
| 230 NavigationHandleImpl::GetConnectionInfo() { | |
| 231 return connection_info_; | |
|
Charlie Harrison
2016/10/31 15:27:17
Hm it seems strange that we will get something unk
jkarlin
2016/10/31 16:50:06
Thanks. I've documented the behavior in the header
Charlie Harrison
2016/10/31 16:54:58
It is unfortunate to add more things to Navigation
| |
| 232 } | |
| 233 | |
| 228 bool NavigationHandleImpl::HasCommitted() { | 234 bool NavigationHandleImpl::HasCommitted() { |
| 229 return state_ == DID_COMMIT || state_ == DID_COMMIT_ERROR_PAGE; | 235 return state_ == DID_COMMIT || state_ == DID_COMMIT_ERROR_PAGE; |
| 230 } | 236 } |
| 231 | 237 |
| 232 bool NavigationHandleImpl::IsErrorPage() { | 238 bool NavigationHandleImpl::IsErrorPage() { |
| 233 return state_ == DID_COMMIT_ERROR_PAGE; | 239 return state_ == DID_COMMIT_ERROR_PAGE; |
| 234 } | 240 } |
| 235 | 241 |
| 236 void NavigationHandleImpl::Resume() { | 242 void NavigationHandleImpl::Resume() { |
| 237 if (state_ != DEFERRING_START && state_ != DEFERRING_REDIRECT && | 243 if (state_ != DEFERRING_START && state_ != DEFERRING_REDIRECT && |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 307 NavigationThrottle::ThrottleCheckResult | 313 NavigationThrottle::ThrottleCheckResult |
| 308 NavigationHandleImpl::CallWillRedirectRequestForTesting( | 314 NavigationHandleImpl::CallWillRedirectRequestForTesting( |
| 309 const GURL& new_url, | 315 const GURL& new_url, |
| 310 bool new_method_is_post, | 316 bool new_method_is_post, |
| 311 const GURL& new_referrer_url, | 317 const GURL& new_referrer_url, |
| 312 bool new_is_external_protocol) { | 318 bool new_is_external_protocol) { |
| 313 NavigationThrottle::ThrottleCheckResult result = NavigationThrottle::DEFER; | 319 NavigationThrottle::ThrottleCheckResult result = NavigationThrottle::DEFER; |
| 314 WillRedirectRequest(new_url, new_method_is_post ? "POST" : "GET", | 320 WillRedirectRequest(new_url, new_method_is_post ? "POST" : "GET", |
| 315 new_referrer_url, new_is_external_protocol, | 321 new_referrer_url, new_is_external_protocol, |
| 316 scoped_refptr<net::HttpResponseHeaders>(), | 322 scoped_refptr<net::HttpResponseHeaders>(), |
| 323 net::HttpResponseInfo::CONNECTION_INFO_UNKNOWN, | |
| 317 base::Bind(&UpdateThrottleCheckResult, &result)); | 324 base::Bind(&UpdateThrottleCheckResult, &result)); |
| 318 | 325 |
| 319 // Reset the callback to ensure it will not be called later. | 326 // Reset the callback to ensure it will not be called later. |
| 320 complete_callback_.Reset(); | 327 complete_callback_.Reset(); |
| 321 return result; | 328 return result; |
| 322 } | 329 } |
| 323 | 330 |
| 324 NavigationThrottle::ThrottleCheckResult | 331 NavigationThrottle::ThrottleCheckResult |
| 325 NavigationHandleImpl::CallWillProcessResponseForTesting( | 332 NavigationHandleImpl::CallWillProcessResponseForTesting( |
| 326 content::RenderFrameHost* render_frame_host, | 333 content::RenderFrameHost* render_frame_host, |
| 327 const std::string& raw_response_headers) { | 334 const std::string& raw_response_headers) { |
| 328 scoped_refptr<net::HttpResponseHeaders> headers = | 335 scoped_refptr<net::HttpResponseHeaders> headers = |
| 329 new net::HttpResponseHeaders(raw_response_headers); | 336 new net::HttpResponseHeaders(raw_response_headers); |
| 330 NavigationThrottle::ThrottleCheckResult result = NavigationThrottle::DEFER; | 337 NavigationThrottle::ThrottleCheckResult result = NavigationThrottle::DEFER; |
| 331 WillProcessResponse(static_cast<RenderFrameHostImpl*>(render_frame_host), | 338 WillProcessResponse(static_cast<RenderFrameHostImpl*>(render_frame_host), |
| 332 headers, SSLStatus(), GlobalRequestID(), false, false, | 339 headers, net::HttpResponseInfo::CONNECTION_INFO_UNKNOWN, |
| 333 false, base::Closure(), | 340 SSLStatus(), GlobalRequestID(), false, false, false, |
| 341 base::Closure(), | |
| 334 base::Bind(&UpdateThrottleCheckResult, &result)); | 342 base::Bind(&UpdateThrottleCheckResult, &result)); |
| 335 | 343 |
| 336 // Reset the callback to ensure it will not be called later. | 344 // Reset the callback to ensure it will not be called later. |
| 337 complete_callback_.Reset(); | 345 complete_callback_.Reset(); |
| 338 return result; | 346 return result; |
| 339 } | 347 } |
| 340 | 348 |
| 341 void NavigationHandleImpl::CallDidCommitNavigationForTesting(const GURL& url) { | 349 void NavigationHandleImpl::CallDidCommitNavigationForTesting(const GURL& url) { |
| 342 FrameHostMsg_DidCommitProvisionalLoad_Params params; | 350 FrameHostMsg_DidCommitProvisionalLoad_Params params; |
| 343 | 351 |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 409 if (result != NavigationThrottle::DEFER) | 417 if (result != NavigationThrottle::DEFER) |
| 410 RunCompleteCallback(result); | 418 RunCompleteCallback(result); |
| 411 } | 419 } |
| 412 | 420 |
| 413 void NavigationHandleImpl::WillRedirectRequest( | 421 void NavigationHandleImpl::WillRedirectRequest( |
| 414 const GURL& new_url, | 422 const GURL& new_url, |
| 415 const std::string& new_method, | 423 const std::string& new_method, |
| 416 const GURL& new_referrer_url, | 424 const GURL& new_referrer_url, |
| 417 bool new_is_external_protocol, | 425 bool new_is_external_protocol, |
| 418 scoped_refptr<net::HttpResponseHeaders> response_headers, | 426 scoped_refptr<net::HttpResponseHeaders> response_headers, |
| 427 net::HttpResponseInfo::ConnectionInfo connection_info, | |
| 419 const ThrottleChecksFinishedCallback& callback) { | 428 const ThrottleChecksFinishedCallback& callback) { |
| 420 // Update the navigation parameters. | 429 // Update the navigation parameters. |
| 421 url_ = new_url; | 430 url_ = new_url; |
| 422 method_ = new_method; | 431 method_ = new_method; |
| 423 sanitized_referrer_.url = new_referrer_url; | 432 sanitized_referrer_.url = new_referrer_url; |
| 424 sanitized_referrer_ = Referrer::SanitizeForRequest(url_, sanitized_referrer_); | 433 sanitized_referrer_ = Referrer::SanitizeForRequest(url_, sanitized_referrer_); |
| 425 is_external_protocol_ = new_is_external_protocol; | 434 is_external_protocol_ = new_is_external_protocol; |
| 426 response_headers_ = response_headers; | 435 response_headers_ = response_headers; |
| 436 connection_info_ = connection_info; | |
| 427 was_redirected_ = true; | 437 was_redirected_ = true; |
| 428 redirect_chain_.push_back(new_url); | 438 redirect_chain_.push_back(new_url); |
| 429 if (new_method != "POST") | 439 if (new_method != "POST") |
| 430 resource_request_body_ = nullptr; | 440 resource_request_body_ = nullptr; |
| 431 | 441 |
| 432 state_ = WILL_REDIRECT_REQUEST; | 442 state_ = WILL_REDIRECT_REQUEST; |
| 433 complete_callback_ = callback; | 443 complete_callback_ = callback; |
| 434 | 444 |
| 435 // Notify each throttle of the request. | 445 // Notify each throttle of the request. |
| 436 NavigationThrottle::ThrottleCheckResult result = CheckWillRedirectRequest(); | 446 NavigationThrottle::ThrottleCheckResult result = CheckWillRedirectRequest(); |
| 437 | 447 |
| 438 // If the navigation is not deferred, run the callback. | 448 // If the navigation is not deferred, run the callback. |
| 439 if (result != NavigationThrottle::DEFER) | 449 if (result != NavigationThrottle::DEFER) |
| 440 RunCompleteCallback(result); | 450 RunCompleteCallback(result); |
| 441 } | 451 } |
| 442 | 452 |
| 443 void NavigationHandleImpl::WillProcessResponse( | 453 void NavigationHandleImpl::WillProcessResponse( |
| 444 RenderFrameHostImpl* render_frame_host, | 454 RenderFrameHostImpl* render_frame_host, |
| 445 scoped_refptr<net::HttpResponseHeaders> response_headers, | 455 scoped_refptr<net::HttpResponseHeaders> response_headers, |
| 456 net::HttpResponseInfo::ConnectionInfo connection_info, | |
| 446 const SSLStatus& ssl_status, | 457 const SSLStatus& ssl_status, |
| 447 const GlobalRequestID& request_id, | 458 const GlobalRequestID& request_id, |
| 448 bool should_replace_current_entry, | 459 bool should_replace_current_entry, |
| 449 bool is_download, | 460 bool is_download, |
| 450 bool is_stream, | 461 bool is_stream, |
| 451 const base::Closure& transfer_callback, | 462 const base::Closure& transfer_callback, |
| 452 const ThrottleChecksFinishedCallback& callback) { | 463 const ThrottleChecksFinishedCallback& callback) { |
| 453 DCHECK(!render_frame_host_ || render_frame_host_ == render_frame_host); | 464 DCHECK(!render_frame_host_ || render_frame_host_ == render_frame_host); |
| 454 render_frame_host_ = render_frame_host; | 465 render_frame_host_ = render_frame_host; |
| 455 response_headers_ = response_headers; | 466 response_headers_ = response_headers; |
| 467 connection_info_ = connection_info; | |
| 456 request_id_ = request_id; | 468 request_id_ = request_id; |
| 457 should_replace_current_entry_ = should_replace_current_entry; | 469 should_replace_current_entry_ = should_replace_current_entry; |
| 458 is_download_ = is_download; | 470 is_download_ = is_download; |
| 459 is_stream_ = is_stream; | 471 is_stream_ = is_stream; |
| 460 state_ = WILL_PROCESS_RESPONSE; | 472 state_ = WILL_PROCESS_RESPONSE; |
| 461 ssl_status_ = ssl_status; | 473 ssl_status_ = ssl_status; |
| 462 complete_callback_ = callback; | 474 complete_callback_ = callback; |
| 463 transfer_callback_ = transfer_callback; | 475 transfer_callback_ = transfer_callback; |
| 464 | 476 |
| 465 // Notify each throttle of the response. | 477 // Notify each throttle of the response. |
| (...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 743 throttles_to_register.end()); | 755 throttles_to_register.end()); |
| 744 throttles_to_register.weak_clear(); | 756 throttles_to_register.weak_clear(); |
| 745 } | 757 } |
| 746 } | 758 } |
| 747 | 759 |
| 748 bool NavigationHandleImpl::WasStartedFromContextMenu() const { | 760 bool NavigationHandleImpl::WasStartedFromContextMenu() const { |
| 749 return started_from_context_menu_; | 761 return started_from_context_menu_; |
| 750 } | 762 } |
| 751 | 763 |
| 752 } // namespace content | 764 } // namespace content |
| OLD | NEW |