Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(213)

Side by Side Diff: content/browser/frame_host/navigator_impl.cc

Issue 2879853002: PlzNavigate: Fix form submission to OOPIF frame. (Closed)
Patch Set: Nits. Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <utility> 7 #include <utility>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/metrics/histogram_macros.h" 10 #include "base/metrics/histogram_macros.h"
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 ->last_navigation_previews_state(); 363 ->last_navigation_previews_state();
364 } else if (reload_type == ReloadType::DISABLE_LOFI_MODE) { 364 } else if (reload_type == ReloadType::DISABLE_LOFI_MODE) {
365 // Disable LoFi when asked for it explicitly. 365 // Disable LoFi when asked for it explicitly.
366 previews_state = PREVIEWS_NO_TRANSFORM; 366 previews_state = PREVIEWS_NO_TRANSFORM;
367 } 367 }
368 368
369 // PlzNavigate: the RenderFrameHosts are no longer asked to navigate. 369 // PlzNavigate: the RenderFrameHosts are no longer asked to navigate.
370 if (IsBrowserSideNavigationEnabled()) { 370 if (IsBrowserSideNavigationEnabled()) {
371 navigation_data_.reset(new NavigationMetricsData(navigation_start, dest_url, 371 navigation_data_.reset(new NavigationMetricsData(navigation_start, dest_url,
372 entry.restore_type())); 372 entry.restore_type()));
373 RequestNavigation(frame_tree_node, dest_url, dest_referrer, frame_entry, 373 RequestNavigation(
374 entry, reload_type, previews_state, 374 frame_tree_node, dest_url, dest_referrer, frame_entry, entry,
375 is_same_document_history_load, 375 reload_type, previews_state, is_same_document_history_load,
376 is_history_navigation_in_new_child, navigation_start); 376 is_history_navigation_in_new_child, post_body, navigation_start);
377 if (frame_tree_node->IsMainFrame() && 377 if (frame_tree_node->IsMainFrame() &&
378 frame_tree_node->navigation_request()) { 378 frame_tree_node->navigation_request()) {
379 // TODO(carlosk): extend these traces to support subframes and 379 // TODO(carlosk): extend these traces to support subframes and
380 // non-PlzNavigate navigations. 380 // non-PlzNavigate navigations.
381 // For the trace below we're using the navigation handle as the async 381 // For the trace below we're using the navigation handle as the async
382 // trace id, |navigation_start| as the timestamp and reporting the 382 // trace id, |navigation_start| as the timestamp and reporting the
383 // FrameTreeNode id as a parameter. For navigations where no network 383 // FrameTreeNode id as a parameter. For navigations where no network
384 // request is made (data URLs, JavaScript URLs, etc) there is no handle 384 // request is made (data URLs, JavaScript URLs, etc) there is no handle
385 // and so no tracing is done. 385 // and so no tracing is done.
386 TRACE_EVENT_ASYNC_BEGIN_WITH_TIMESTAMP1( 386 TRACE_EVENT_ASYNC_BEGIN_WITH_TIMESTAMP1(
(...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after
882 // have a new NavigationEntry. 882 // have a new NavigationEntry.
883 // TODO(creis): Make this unnecessary by creating (and validating) the params 883 // TODO(creis): Make this unnecessary by creating (and validating) the params
884 // directly, passing them to the destination RenderFrameHost. See 884 // directly, passing them to the destination RenderFrameHost. See
885 // https://crbug.com/536906. 885 // https://crbug.com/536906.
886 std::unique_ptr<NavigationEntryImpl> entry; 886 std::unique_ptr<NavigationEntryImpl> entry;
887 if (!node->IsMainFrame()) { 887 if (!node->IsMainFrame()) {
888 // Subframe case: create FrameNavigationEntry. 888 // Subframe case: create FrameNavigationEntry.
889 if (controller_->GetLastCommittedEntry()) { 889 if (controller_->GetLastCommittedEntry()) {
890 entry = controller_->GetLastCommittedEntry()->Clone(); 890 entry = controller_->GetLastCommittedEntry()->Clone();
891 entry->set_extra_headers(extra_headers); 891 entry->set_extra_headers(extra_headers);
892 // TODO(arthursonzogni): What about |is_renderer_initiated|?
893 // Renderer-initiated navigation that target a remote frame are currently
894 // classified as browser-initiated when this one has already navigated.
895 // See https://crbug.com/722251.
892 } else { 896 } else {
893 // If there's no last committed entry, create an entry for about:blank 897 // If there's no last committed entry, create an entry for about:blank
894 // with a subframe entry for our destination. 898 // with a subframe entry for our destination.
895 // TODO(creis): Ensure this case can't exist in https://crbug.com/524208. 899 // TODO(creis): Ensure this case can't exist in https://crbug.com/524208.
896 entry = NavigationEntryImpl::FromNavigationEntry( 900 entry = NavigationEntryImpl::FromNavigationEntry(
897 controller_->CreateNavigationEntry( 901 controller_->CreateNavigationEntry(
898 GURL(url::kAboutBlankURL), referrer_to_use, page_transition, 902 GURL(url::kAboutBlankURL), referrer_to_use, page_transition,
899 is_renderer_initiated, extra_headers, 903 is_renderer_initiated, extra_headers,
900 controller_->GetBrowserContext())); 904 controller_->GetBrowserContext()));
901 } 905 }
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
1112 if (pending_entry != controller_->GetVisibleEntry() || 1116 if (pending_entry != controller_->GetVisibleEntry() ||
1113 !should_preserve_entry) { 1117 !should_preserve_entry) {
1114 controller_->DiscardPendingEntry(true); 1118 controller_->DiscardPendingEntry(true);
1115 1119
1116 // Also force the UI to refresh. 1120 // Also force the UI to refresh.
1117 controller_->delegate()->NotifyNavigationStateChanged(INVALIDATE_TYPE_URL); 1121 controller_->delegate()->NotifyNavigationStateChanged(INVALIDATE_TYPE_URL);
1118 } 1122 }
1119 } 1123 }
1120 1124
1121 // PlzNavigate 1125 // PlzNavigate
1122 void NavigatorImpl::RequestNavigation(FrameTreeNode* frame_tree_node, 1126 void NavigatorImpl::RequestNavigation(
1123 const GURL& dest_url, 1127 FrameTreeNode* frame_tree_node,
1124 const Referrer& dest_referrer, 1128 const GURL& dest_url,
1125 const FrameNavigationEntry& frame_entry, 1129 const Referrer& dest_referrer,
1126 const NavigationEntryImpl& entry, 1130 const FrameNavigationEntry& frame_entry,
1127 ReloadType reload_type, 1131 const NavigationEntryImpl& entry,
1128 PreviewsState previews_state, 1132 ReloadType reload_type,
1129 bool is_same_document_history_load, 1133 PreviewsState previews_state,
1130 bool is_history_navigation_in_new_child, 1134 bool is_same_document_history_load,
1131 base::TimeTicks navigation_start) { 1135 bool is_history_navigation_in_new_child,
1136 const scoped_refptr<ResourceRequestBodyImpl>& post_body,
1137 base::TimeTicks navigation_start) {
1132 CHECK(IsBrowserSideNavigationEnabled()); 1138 CHECK(IsBrowserSideNavigationEnabled());
1133 DCHECK(frame_tree_node); 1139 DCHECK(frame_tree_node);
1134 1140
1135 // This value must be set here because creating a NavigationRequest might 1141 // This value must be set here because creating a NavigationRequest might
1136 // change the renderer live/non-live status and change this result. 1142 // change the renderer live/non-live status and change this result.
1137 // We don't want to dispatch a beforeunload handler if 1143 // We don't want to dispatch a beforeunload handler if
1138 // is_history_navigation_in_new_child is true. This indicates a newly created 1144 // is_history_navigation_in_new_child is true. This indicates a newly created
1139 // child frame which does not have a beforunload handler. 1145 // child frame which does not have a beforunload handler.
1140 bool should_dispatch_beforeunload = 1146 bool should_dispatch_beforeunload =
1141 !is_same_document_history_load && 1147 !is_same_document_history_load &&
1142 !is_history_navigation_in_new_child && 1148 !is_history_navigation_in_new_child &&
1143 frame_tree_node->current_frame_host()->ShouldDispatchBeforeUnload(); 1149 frame_tree_node->current_frame_host()->ShouldDispatchBeforeUnload();
1144 FrameMsg_Navigate_Type::Value navigation_type = GetNavigationType( 1150 FrameMsg_Navigate_Type::Value navigation_type = GetNavigationType(
1145 frame_tree_node->current_url(), // old_url 1151 frame_tree_node->current_url(), // old_url
1146 dest_url, // new_url 1152 dest_url, // new_url
1147 reload_type, // reload_type 1153 reload_type, // reload_type
1148 entry, // entry 1154 entry, // entry
1149 frame_entry, // frame_entry 1155 frame_entry, // frame_entry
1150 is_same_document_history_load); // is_same_document_history_load 1156 is_same_document_history_load); // is_same_document_history_load
1151 std::unique_ptr<NavigationRequest> scoped_request = 1157 std::unique_ptr<NavigationRequest> scoped_request =
1152 NavigationRequest::CreateBrowserInitiated( 1158 NavigationRequest::CreateBrowserInitiated(
1153 frame_tree_node, dest_url, dest_referrer, frame_entry, entry, 1159 frame_tree_node, dest_url, dest_referrer, frame_entry, entry,
1154 navigation_type, previews_state, is_same_document_history_load, 1160 navigation_type, previews_state, is_same_document_history_load,
1155 is_history_navigation_in_new_child, navigation_start, controller_); 1161 is_history_navigation_in_new_child, post_body, navigation_start,
1162 controller_);
1156 1163
1157 // Navigation to a javascript URL is not a "real" navigation so there is no 1164 // Navigation to a javascript URL is not a "real" navigation so there is no
1158 // need to create a NavigationHandle. The navigation commits immediately and 1165 // need to create a NavigationHandle. The navigation commits immediately and
1159 // the NavigationRequest is not assigned to the FrameTreeNode as navigating to 1166 // the NavigationRequest is not assigned to the FrameTreeNode as navigating to
1160 // a Javascript URL should not interrupt a previous navigation. 1167 // a Javascript URL should not interrupt a previous navigation.
1161 // Note: The scoped_request will be destroyed at the end of this function. 1168 // Note: The scoped_request will be destroyed at the end of this function.
1162 if (dest_url.SchemeIs(url::kJavaScriptScheme)) { 1169 if (dest_url.SchemeIs(url::kJavaScriptScheme)) {
1163 RenderFrameHostImpl* render_frame_host = 1170 RenderFrameHostImpl* render_frame_host =
1164 frame_tree_node->render_manager()->GetFrameHostForNavigation( 1171 frame_tree_node->render_manager()->GetFrameHostForNavigation(
1165 *scoped_request.get()); 1172 *scoped_request.get());
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
1296 if (navigation_handle) 1303 if (navigation_handle)
1297 navigation_handle->update_entry_id_for_transfer(entry->GetUniqueID()); 1304 navigation_handle->update_entry_id_for_transfer(entry->GetUniqueID());
1298 1305
1299 controller_->SetPendingEntry(std::move(entry)); 1306 controller_->SetPendingEntry(std::move(entry));
1300 if (delegate_) 1307 if (delegate_)
1301 delegate_->NotifyChangedNavigationState(content::INVALIDATE_TYPE_URL); 1308 delegate_->NotifyChangedNavigationState(content::INVALIDATE_TYPE_URL);
1302 } 1309 }
1303 } 1310 }
1304 1311
1305 } // namespace content 1312 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/frame_host/navigator_impl.h ('k') | content/browser/frame_host/render_frame_host_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698