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/browsing_data/clear_site_data_throttle.h" | 10 #include "content/browser/browsing_data/clear_site_data_throttle.h" |
(...skipping 22 matching lines...) Expand all Loading... |
33 *to_update = result; | 33 *to_update = result; |
34 } | 34 } |
35 | 35 |
36 } // namespace | 36 } // namespace |
37 | 37 |
38 // static | 38 // static |
39 std::unique_ptr<NavigationHandleImpl> NavigationHandleImpl::Create( | 39 std::unique_ptr<NavigationHandleImpl> NavigationHandleImpl::Create( |
40 const GURL& url, | 40 const GURL& url, |
41 FrameTreeNode* frame_tree_node, | 41 FrameTreeNode* frame_tree_node, |
42 bool is_renderer_initiated, | 42 bool is_renderer_initiated, |
43 bool is_synchronous, | 43 bool is_same_page, |
44 bool is_srcdoc, | 44 bool is_srcdoc, |
45 const base::TimeTicks& navigation_start, | 45 const base::TimeTicks& navigation_start, |
46 int pending_nav_entry_id) { | 46 int pending_nav_entry_id) { |
47 return std::unique_ptr<NavigationHandleImpl>( | 47 return std::unique_ptr<NavigationHandleImpl>(new NavigationHandleImpl( |
48 new NavigationHandleImpl(url, frame_tree_node, is_renderer_initiated, | 48 url, frame_tree_node, is_renderer_initiated, is_same_page, is_srcdoc, |
49 is_synchronous, is_srcdoc, navigation_start, | 49 navigation_start, pending_nav_entry_id)); |
50 pending_nav_entry_id)); | |
51 } | 50 } |
52 | 51 |
53 NavigationHandleImpl::NavigationHandleImpl( | 52 NavigationHandleImpl::NavigationHandleImpl( |
54 const GURL& url, | 53 const GURL& url, |
55 FrameTreeNode* frame_tree_node, | 54 FrameTreeNode* frame_tree_node, |
56 bool is_renderer_initiated, | 55 bool is_renderer_initiated, |
57 bool is_synchronous, | 56 bool is_same_page, |
58 bool is_srcdoc, | 57 bool is_srcdoc, |
59 const base::TimeTicks& navigation_start, | 58 const base::TimeTicks& navigation_start, |
60 int pending_nav_entry_id) | 59 int pending_nav_entry_id) |
61 : url_(url), | 60 : url_(url), |
62 has_user_gesture_(false), | 61 has_user_gesture_(false), |
63 transition_(ui::PAGE_TRANSITION_LINK), | 62 transition_(ui::PAGE_TRANSITION_LINK), |
64 is_external_protocol_(false), | 63 is_external_protocol_(false), |
65 net_error_code_(net::OK), | 64 net_error_code_(net::OK), |
66 render_frame_host_(nullptr), | 65 render_frame_host_(nullptr), |
67 is_renderer_initiated_(is_renderer_initiated), | 66 is_renderer_initiated_(is_renderer_initiated), |
68 is_same_page_(false), | 67 is_same_page_(is_same_page), |
69 is_synchronous_(is_synchronous), | |
70 is_srcdoc_(is_srcdoc), | 68 is_srcdoc_(is_srcdoc), |
71 was_redirected_(false), | 69 was_redirected_(false), |
72 state_(INITIAL), | 70 state_(INITIAL), |
73 is_transferring_(false), | 71 is_transferring_(false), |
74 frame_tree_node_(frame_tree_node), | 72 frame_tree_node_(frame_tree_node), |
75 next_index_(0), | 73 next_index_(0), |
76 navigation_start_(navigation_start), | 74 navigation_start_(navigation_start), |
77 pending_nav_entry_id_(pending_nav_entry_id), | 75 pending_nav_entry_id_(pending_nav_entry_id), |
78 request_context_type_(REQUEST_CONTEXT_TYPE_UNSPECIFIED) { | 76 request_context_type_(REQUEST_CONTEXT_TYPE_UNSPECIFIED) { |
79 DCHECK(!navigation_start.is_null()); | 77 DCHECK(!navigation_start.is_null()); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 if (frame_tree_node_->parent()) | 120 if (frame_tree_node_->parent()) |
123 return frame_tree_node_->parent()->IsMainFrame(); | 121 return frame_tree_node_->parent()->IsMainFrame(); |
124 | 122 |
125 return false; | 123 return false; |
126 } | 124 } |
127 | 125 |
128 bool NavigationHandleImpl::IsRendererInitiated() { | 126 bool NavigationHandleImpl::IsRendererInitiated() { |
129 return is_renderer_initiated_; | 127 return is_renderer_initiated_; |
130 } | 128 } |
131 | 129 |
132 bool NavigationHandleImpl::IsSynchronousNavigation() { | |
133 return is_synchronous_; | |
134 } | |
135 | |
136 bool NavigationHandleImpl::IsSrcdoc() { | 130 bool NavigationHandleImpl::IsSrcdoc() { |
137 return is_srcdoc_; | 131 return is_srcdoc_; |
138 } | 132 } |
139 | 133 |
140 bool NavigationHandleImpl::WasServerRedirect() { | 134 bool NavigationHandleImpl::WasServerRedirect() { |
141 return was_redirected_; | 135 return was_redirected_; |
142 } | 136 } |
143 | 137 |
144 int NavigationHandleImpl::GetFrameTreeNodeId() { | 138 int NavigationHandleImpl::GetFrameTreeNodeId() { |
145 return frame_tree_node_->frame_tree_node_id(); | 139 return frame_tree_node_->frame_tree_node_id(); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 // TODO(mkwst): Change this to check against 'READY_TO_COMMIT' once | 188 // TODO(mkwst): Change this to check against 'READY_TO_COMMIT' once |
195 // ReadyToCommitNavigation is available whether or not PlzNavigate is | 189 // ReadyToCommitNavigation is available whether or not PlzNavigate is |
196 // enabled. https://crbug.com/621856 | 190 // enabled. https://crbug.com/621856 |
197 CHECK_GE(state_, WILL_PROCESS_RESPONSE) | 191 CHECK_GE(state_, WILL_PROCESS_RESPONSE) |
198 << "This accessor should only be called after a response has been " | 192 << "This accessor should only be called after a response has been " |
199 "delivered for processing."; | 193 "delivered for processing."; |
200 return render_frame_host_; | 194 return render_frame_host_; |
201 } | 195 } |
202 | 196 |
203 bool NavigationHandleImpl::IsSamePage() { | 197 bool NavigationHandleImpl::IsSamePage() { |
204 DCHECK(state_ == DID_COMMIT || state_ == DID_COMMIT_ERROR_PAGE) | |
205 << "This accessor should not be called before the navigation has " | |
206 "committed."; | |
207 return is_same_page_; | 198 return is_same_page_; |
208 } | 199 } |
209 | 200 |
210 const net::HttpResponseHeaders* NavigationHandleImpl::GetResponseHeaders() { | 201 const net::HttpResponseHeaders* NavigationHandleImpl::GetResponseHeaders() { |
211 DCHECK_GE(state_, WILL_REDIRECT_REQUEST); | 202 DCHECK_GE(state_, WILL_REDIRECT_REQUEST); |
212 return response_headers_.get(); | 203 return response_headers_.get(); |
213 } | 204 } |
214 | 205 |
215 bool NavigationHandleImpl::HasCommitted() { | 206 bool NavigationHandleImpl::HasCommitted() { |
216 return state_ == DID_COMMIT || state_ == DID_COMMIT_ERROR_PAGE; | 207 return state_ == DID_COMMIT || state_ == DID_COMMIT_ERROR_PAGE; |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
447 if (IsBrowserSideNavigationEnabled()) | 438 if (IsBrowserSideNavigationEnabled()) |
448 GetDelegate()->ReadyToCommitNavigation(this); | 439 GetDelegate()->ReadyToCommitNavigation(this); |
449 } | 440 } |
450 | 441 |
451 void NavigationHandleImpl::DidCommitNavigation( | 442 void NavigationHandleImpl::DidCommitNavigation( |
452 const FrameHostMsg_DidCommitProvisionalLoad_Params& params, | 443 const FrameHostMsg_DidCommitProvisionalLoad_Params& params, |
453 bool same_page, | 444 bool same_page, |
454 RenderFrameHostImpl* render_frame_host) { | 445 RenderFrameHostImpl* render_frame_host) { |
455 DCHECK(!render_frame_host_ || render_frame_host_ == render_frame_host); | 446 DCHECK(!render_frame_host_ || render_frame_host_ == render_frame_host); |
456 DCHECK_EQ(frame_tree_node_, render_frame_host->frame_tree_node()); | 447 DCHECK_EQ(frame_tree_node_, render_frame_host->frame_tree_node()); |
| 448 DCHECK_EQ(same_page, IsSamePage()); |
457 CHECK_EQ(url_, params.url); | 449 CHECK_EQ(url_, params.url); |
458 | 450 |
459 method_ = params.method; | 451 method_ = params.method; |
460 has_user_gesture_ = (params.gesture == NavigationGestureUser); | 452 has_user_gesture_ = (params.gesture == NavigationGestureUser); |
461 transition_ = params.transition; | 453 transition_ = params.transition; |
462 render_frame_host_ = render_frame_host; | 454 render_frame_host_ = render_frame_host; |
463 is_same_page_ = same_page; | |
464 | 455 |
465 // If an error page reloads, net_error_code might be 200 but we still want to | 456 // If an error page reloads, net_error_code might be 200 but we still want to |
466 // count it as an error page. | 457 // count it as an error page. |
467 if (params.base_url.spec() == kUnreachableWebDataURL || | 458 if (params.base_url.spec() == kUnreachableWebDataURL || |
468 net_error_code_ != net::OK) { | 459 net_error_code_ != net::OK) { |
469 state_ = DID_COMMIT_ERROR_PAGE; | 460 state_ = DID_COMMIT_ERROR_PAGE; |
470 } else { | 461 } else { |
471 state_ = DID_COMMIT; | 462 state_ = DID_COMMIT; |
472 } | 463 } |
473 } | 464 } |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
600 throttles_to_register.push_back(std::move(clear_site_data_throttle)); | 591 throttles_to_register.push_back(std::move(clear_site_data_throttle)); |
601 | 592 |
602 if (throttles_to_register.size() > 0) { | 593 if (throttles_to_register.size() > 0) { |
603 throttles_.insert(throttles_.begin(), throttles_to_register.begin(), | 594 throttles_.insert(throttles_.begin(), throttles_to_register.begin(), |
604 throttles_to_register.end()); | 595 throttles_to_register.end()); |
605 throttles_to_register.weak_clear(); | 596 throttles_to_register.weak_clear(); |
606 } | 597 } |
607 } | 598 } |
608 | 599 |
609 } // namespace content | 600 } // namespace content |
OLD | NEW |