OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/navigator_impl.h" | 5 #include "content/browser/frame_host/navigator_impl.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
9 #include "base/time/time.h" | 9 #include "base/time/time.h" |
10 #include "content/browser/frame_host/frame_tree.h" | 10 #include "content/browser/frame_host/frame_tree.h" |
(...skipping 655 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
666 // PlzNavigate | 666 // PlzNavigate |
667 void NavigatorImpl::CommitNavigation(FrameTreeNode* frame_tree_node, | 667 void NavigatorImpl::CommitNavigation(FrameTreeNode* frame_tree_node, |
668 ResourceResponse* response, | 668 ResourceResponse* response, |
669 scoped_ptr<StreamHandle> body) { | 669 scoped_ptr<StreamHandle> body) { |
670 CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch( | 670 CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch( |
671 switches::kEnableBrowserSideNavigation)); | 671 switches::kEnableBrowserSideNavigation)); |
672 | 672 |
673 NavigationRequest* navigation_request = frame_tree_node->navigation_request(); | 673 NavigationRequest* navigation_request = frame_tree_node->navigation_request(); |
674 DCHECK(navigation_request); | 674 DCHECK(navigation_request); |
675 DCHECK(response || | 675 DCHECK(response || |
676 !NavigationRequest::ShouldMakeNetworkRequest( | 676 !ShouldMakeNetworkRequestForURL( |
677 navigation_request->common_params().url)); | 677 navigation_request->common_params().url)); |
678 | 678 |
679 // HTTP 204 (No Content) and HTTP 205 (Reset Content) responses should not | 679 // HTTP 204 (No Content) and HTTP 205 (Reset Content) responses should not |
680 // commit; they leave the frame showing the previous page. | 680 // commit; they leave the frame showing the previous page. |
681 if (response && response->head.headers.get() && | 681 if (response && response->head.headers.get() && |
682 (response->head.headers->response_code() == 204 || | 682 (response->head.headers->response_code() == 204 || |
683 response->head.headers->response_code() == 205)) { | 683 response->head.headers->response_code() == 205)) { |
684 CancelNavigation(frame_tree_node); | 684 CancelNavigation(frame_tree_node); |
685 return; | 685 return; |
686 } | 686 } |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
807 NavigationRequest::CreateBrowserInitiated( | 807 NavigationRequest::CreateBrowserInitiated( |
808 frame_tree_node, frame_entry, entry, navigation_type, | 808 frame_tree_node, frame_entry, entry, navigation_type, |
809 is_same_document_history_load, navigation_start, controller_)); | 809 is_same_document_history_load, navigation_start, controller_)); |
810 NavigationRequest* navigation_request = frame_tree_node->navigation_request(); | 810 NavigationRequest* navigation_request = frame_tree_node->navigation_request(); |
811 | 811 |
812 // Have the current renderer execute its beforeunload event if needed. If it | 812 // Have the current renderer execute its beforeunload event if needed. If it |
813 // is not needed (when beforeunload dispatch is not needed or this navigation | 813 // is not needed (when beforeunload dispatch is not needed or this navigation |
814 // is synchronous and same-site) then NavigationRequest::BeginNavigation | 814 // is synchronous and same-site) then NavigationRequest::BeginNavigation |
815 // should be directly called instead. | 815 // should be directly called instead. |
816 if (should_dispatch_beforeunload && | 816 if (should_dispatch_beforeunload && |
817 NavigationRequest::ShouldMakeNetworkRequest( | 817 ShouldMakeNetworkRequestForURL( |
818 navigation_request->common_params().url)) { | 818 navigation_request->common_params().url)) { |
819 navigation_request->SetWaitingForRendererResponse(); | 819 navigation_request->SetWaitingForRendererResponse(); |
820 frame_tree_node->current_frame_host()->DispatchBeforeUnload(true); | 820 frame_tree_node->current_frame_host()->DispatchBeforeUnload(true); |
821 } else { | 821 } else { |
822 navigation_request->BeginNavigation(); | 822 navigation_request->BeginNavigation(); |
823 } | 823 } |
824 } | 824 } |
825 | 825 |
826 void NavigatorImpl::RecordNavigationMetrics( | 826 void NavigatorImpl::RecordNavigationMetrics( |
827 const LoadCommittedDetails& details, | 827 const LoadCommittedDetails& details, |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
904 entry->set_should_replace_entry(pending_entry->should_replace_entry()); | 904 entry->set_should_replace_entry(pending_entry->should_replace_entry()); |
905 entry->SetRedirectChain(pending_entry->GetRedirectChain()); | 905 entry->SetRedirectChain(pending_entry->GetRedirectChain()); |
906 } | 906 } |
907 controller_->SetPendingEntry(entry.Pass()); | 907 controller_->SetPendingEntry(entry.Pass()); |
908 if (delegate_) | 908 if (delegate_) |
909 delegate_->NotifyChangedNavigationState(content::INVALIDATE_TYPE_URL); | 909 delegate_->NotifyChangedNavigationState(content::INVALIDATE_TYPE_URL); |
910 } | 910 } |
911 } | 911 } |
912 | 912 |
913 } // namespace content | 913 } // namespace content |
OLD | NEW |