| 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 "content/browser/frame_host/frame_tree_node.h" | 9 #include "content/browser/frame_host/frame_tree_node.h" |
| 10 #include "content/browser/frame_host/navigator.h" | 10 #include "content/browser/frame_host/navigator.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 NavigationThrottle::ThrottleCheckResult result) { | 26 NavigationThrottle::ThrottleCheckResult result) { |
| 27 *to_update = result; | 27 *to_update = result; |
| 28 } | 28 } |
| 29 | 29 |
| 30 } // namespace | 30 } // namespace |
| 31 | 31 |
| 32 // static | 32 // static |
| 33 scoped_ptr<NavigationHandleImpl> NavigationHandleImpl::Create( | 33 scoped_ptr<NavigationHandleImpl> NavigationHandleImpl::Create( |
| 34 const GURL& url, | 34 const GURL& url, |
| 35 FrameTreeNode* frame_tree_node, | 35 FrameTreeNode* frame_tree_node, |
| 36 bool is_synchronous, |
| 37 bool is_srcdoc, |
| 36 const base::TimeTicks& navigation_start) { | 38 const base::TimeTicks& navigation_start) { |
| 37 return scoped_ptr<NavigationHandleImpl>( | 39 return scoped_ptr<NavigationHandleImpl>(new NavigationHandleImpl( |
| 38 new NavigationHandleImpl(url, frame_tree_node, navigation_start)); | 40 url, frame_tree_node, is_synchronous, is_srcdoc, navigation_start)); |
| 39 } | 41 } |
| 40 | 42 |
| 41 NavigationHandleImpl::NavigationHandleImpl( | 43 NavigationHandleImpl::NavigationHandleImpl( |
| 42 const GURL& url, | 44 const GURL& url, |
| 43 FrameTreeNode* frame_tree_node, | 45 FrameTreeNode* frame_tree_node, |
| 46 bool is_synchronous, |
| 47 bool is_srcdoc, |
| 44 const base::TimeTicks& navigation_start) | 48 const base::TimeTicks& navigation_start) |
| 45 : url_(url), | 49 : url_(url), |
| 46 is_post_(false), | 50 is_post_(false), |
| 47 has_user_gesture_(false), | 51 has_user_gesture_(false), |
| 48 transition_(ui::PAGE_TRANSITION_LINK), | 52 transition_(ui::PAGE_TRANSITION_LINK), |
| 49 is_external_protocol_(false), | 53 is_external_protocol_(false), |
| 50 net_error_code_(net::OK), | 54 net_error_code_(net::OK), |
| 51 render_frame_host_(nullptr), | 55 render_frame_host_(nullptr), |
| 52 is_same_page_(false), | 56 is_same_page_(false), |
| 57 is_synchronous_(is_synchronous), |
| 58 is_srcdoc_(is_srcdoc), |
| 59 was_redirected_(false), |
| 53 state_(INITIAL), | 60 state_(INITIAL), |
| 54 is_transferring_(false), | 61 is_transferring_(false), |
| 55 frame_tree_node_(frame_tree_node), | 62 frame_tree_node_(frame_tree_node), |
| 56 next_index_(0), | 63 next_index_(0), |
| 57 navigation_start_(navigation_start) { | 64 navigation_start_(navigation_start) { |
| 58 DCHECK(!navigation_start.is_null()); | 65 DCHECK(!navigation_start.is_null()); |
| 59 GetDelegate()->DidStartNavigation(this); | 66 GetDelegate()->DidStartNavigation(this); |
| 60 } | 67 } |
| 61 | 68 |
| 62 NavigationHandleImpl::~NavigationHandleImpl() { | 69 NavigationHandleImpl::~NavigationHandleImpl() { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 73 } | 80 } |
| 74 | 81 |
| 75 const GURL& NavigationHandleImpl::GetURL() { | 82 const GURL& NavigationHandleImpl::GetURL() { |
| 76 return url_; | 83 return url_; |
| 77 } | 84 } |
| 78 | 85 |
| 79 bool NavigationHandleImpl::IsInMainFrame() { | 86 bool NavigationHandleImpl::IsInMainFrame() { |
| 80 return frame_tree_node_->IsMainFrame(); | 87 return frame_tree_node_->IsMainFrame(); |
| 81 } | 88 } |
| 82 | 89 |
| 90 bool NavigationHandleImpl::IsParentMainFrame() { |
| 91 if (frame_tree_node_->parent()) |
| 92 return frame_tree_node_->parent()->IsMainFrame(); |
| 93 |
| 94 return false; |
| 95 } |
| 96 |
| 97 bool NavigationHandleImpl::IsSynchronousNavigation() { |
| 98 return is_synchronous_; |
| 99 } |
| 100 |
| 101 bool NavigationHandleImpl::IsSrcdoc() { |
| 102 return is_srcdoc_; |
| 103 } |
| 104 |
| 105 bool NavigationHandleImpl::WasServerRedirect() { |
| 106 return was_redirected_; |
| 107 } |
| 108 |
| 109 int NavigationHandleImpl::GetFrameTreeNodeId() { |
| 110 return frame_tree_node_->frame_tree_node_id(); |
| 111 } |
| 112 |
| 113 int NavigationHandleImpl::GetParentFrameTreeNodeId() { |
| 114 if (frame_tree_node_->IsMainFrame()) |
| 115 return FrameTreeNode::kFrameTreeNodeInvalidId; |
| 116 |
| 117 return frame_tree_node_->parent()->frame_tree_node_id(); |
| 118 } |
| 119 |
| 83 const base::TimeTicks& NavigationHandleImpl::NavigationStart() { | 120 const base::TimeTicks& NavigationHandleImpl::NavigationStart() { |
| 84 return navigation_start_; | 121 return navigation_start_; |
| 85 } | 122 } |
| 86 | 123 |
| 87 bool NavigationHandleImpl::IsPost() { | 124 bool NavigationHandleImpl::IsPost() { |
| 88 CHECK_NE(INITIAL, state_) | 125 CHECK_NE(INITIAL, state_) |
| 89 << "This accessor should not be called before the request is started."; | 126 << "This accessor should not be called before the request is started."; |
| 90 return is_post_; | 127 return is_post_; |
| 91 } | 128 } |
| 92 | 129 |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 bool new_is_external_protocol, | 298 bool new_is_external_protocol, |
| 262 scoped_refptr<net::HttpResponseHeaders> response_headers, | 299 scoped_refptr<net::HttpResponseHeaders> response_headers, |
| 263 const ThrottleChecksFinishedCallback& callback) { | 300 const ThrottleChecksFinishedCallback& callback) { |
| 264 // Update the navigation parameters. | 301 // Update the navigation parameters. |
| 265 url_ = new_url; | 302 url_ = new_url; |
| 266 is_post_ = new_method_is_post; | 303 is_post_ = new_method_is_post; |
| 267 sanitized_referrer_.url = new_referrer_url; | 304 sanitized_referrer_.url = new_referrer_url; |
| 268 sanitized_referrer_ = Referrer::SanitizeForRequest(url_, sanitized_referrer_); | 305 sanitized_referrer_ = Referrer::SanitizeForRequest(url_, sanitized_referrer_); |
| 269 is_external_protocol_ = new_is_external_protocol; | 306 is_external_protocol_ = new_is_external_protocol; |
| 270 response_headers_ = response_headers; | 307 response_headers_ = response_headers; |
| 308 was_redirected_ = true; |
| 271 | 309 |
| 272 state_ = WILL_REDIRECT_REQUEST; | 310 state_ = WILL_REDIRECT_REQUEST; |
| 273 complete_callback_ = callback; | 311 complete_callback_ = callback; |
| 274 | 312 |
| 275 // Notify each throttle of the request. | 313 // Notify each throttle of the request. |
| 276 NavigationThrottle::ThrottleCheckResult result = CheckWillRedirectRequest(); | 314 NavigationThrottle::ThrottleCheckResult result = CheckWillRedirectRequest(); |
| 277 | 315 |
| 278 // If the navigation is not deferred, run the callback. | 316 // If the navigation is not deferred, run the callback. |
| 279 if (result != NavigationThrottle::DEFER) | 317 if (result != NavigationThrottle::DEFER) |
| 280 RunCompleteCallback(result); | 318 RunCompleteCallback(result); |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 381 void NavigationHandleImpl::RunCompleteCallback( | 419 void NavigationHandleImpl::RunCompleteCallback( |
| 382 NavigationThrottle::ThrottleCheckResult result) { | 420 NavigationThrottle::ThrottleCheckResult result) { |
| 383 DCHECK(result != NavigationThrottle::DEFER); | 421 DCHECK(result != NavigationThrottle::DEFER); |
| 384 if (!complete_callback_.is_null()) | 422 if (!complete_callback_.is_null()) |
| 385 complete_callback_.Run(result); | 423 complete_callback_.Run(result); |
| 386 | 424 |
| 387 complete_callback_.Reset(); | 425 complete_callback_.Reset(); |
| 388 } | 426 } |
| 389 | 427 |
| 390 } // namespace content | 428 } // namespace content |
| OLD | NEW |