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

Side by Side Diff: content/renderer/render_frame_impl.cc

Issue 1002953004: Ensure we properly set PageTransition for iframes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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
« no previous file with comments | « content/browser/frame_host/navigation_controller_impl.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/renderer/render_frame_impl.h" 5 #include "content/renderer/render_frame_impl.h"
6 6
7 #include <map> 7 #include <map>
8 #include <string> 8 #include <string>
9 9
10 #include "base/auto_reset.h" 10 #include "base/auto_reset.h"
(...skipping 1045 matching lines...) Expand 10 before | Expand all | Expand 10 after
1056 1056
1057 WebFrame* frame = frame_; 1057 WebFrame* frame = frame_;
1058 if (!commit_params.frame_to_navigate.empty()) { 1058 if (!commit_params.frame_to_navigate.empty()) {
1059 // TODO(nasko): Move this lookup to the browser process. 1059 // TODO(nasko): Move this lookup to the browser process.
1060 frame = render_view_->webview()->findFrameByName( 1060 frame = render_view_->webview()->findFrameByName(
1061 WebString::fromUTF8(commit_params.frame_to_navigate)); 1061 WebString::fromUTF8(commit_params.frame_to_navigate));
1062 CHECK(frame) << "Invalid frame name passed: " 1062 CHECK(frame) << "Invalid frame name passed: "
1063 << commit_params.frame_to_navigate; 1063 << commit_params.frame_to_navigate;
1064 } 1064 }
1065 1065
1066 // If this frame isn't in the same process as its parent, it will naively
1067 // assume that this is the first navigation in the iframe, but this may not
1068 // actually be the case. The PageTransition differentiates between the first
1069 // navigation in a subframe and subsequent navigations, so if this is a
1070 // subsequent navigation, force the frame's state machine forward.
1071 if (ui::PageTransitionCoreTypeIs(common_params.transition,
1072 ui::PAGE_TRANSITION_MANUAL_SUBFRAME)) {
1073 CHECK(frame_->parent());
1074 if (frame_->parent()->isWebRemoteFrame()) {
1075 CHECK_EQ(frame, frame_);
1076 frame_->setCommittedFirstRealLoad();
1077 }
1078 }
1079
1066 if (is_reload && !render_view_->history_controller()->GetCurrentEntry()) { 1080 if (is_reload && !render_view_->history_controller()->GetCurrentEntry()) {
1067 // We cannot reload if we do not have any history state. This happens, for 1081 // We cannot reload if we do not have any history state. This happens, for
1068 // example, when recovering from a crash. 1082 // example, when recovering from a crash.
1069 is_reload = false; 1083 is_reload = false;
1070 cache_policy = WebURLRequest::ReloadIgnoringCacheData; 1084 cache_policy = WebURLRequest::ReloadIgnoringCacheData;
1071 } 1085 }
1072 1086
1073 render_view_->pending_navigation_params_.reset(new NavigationParams( 1087 render_view_->pending_navigation_params_.reset(new NavigationParams(
1074 common_params, start_params, commit_params, history_params)); 1088 common_params, start_params, commit_params, history_params));
1075 1089
(...skipping 1260 matching lines...) Expand 10 before | Expand all | Expand 10 after
2336 if (is_top_most) { 2350 if (is_top_most) {
2337 render_view_->set_navigation_gesture( 2351 render_view_->set_navigation_gesture(
2338 WebUserGestureIndicator::isProcessingUserGesture() ? 2352 WebUserGestureIndicator::isProcessingUserGesture() ?
2339 NavigationGestureUser : NavigationGestureAuto); 2353 NavigationGestureUser : NavigationGestureAuto);
2340 } else if (ds->replacesCurrentHistoryItem()) { 2354 } else if (ds->replacesCurrentHistoryItem()) {
2341 // Subframe navigations that don't add session history items must be 2355 // Subframe navigations that don't add session history items must be
2342 // marked with AUTO_SUBFRAME. See also didFailProvisionalLoad for how we 2356 // marked with AUTO_SUBFRAME. See also didFailProvisionalLoad for how we
2343 // handle loading of error pages. 2357 // handle loading of error pages.
2344 document_state->navigation_state()->set_transition_type( 2358 document_state->navigation_state()->set_transition_type(
2345 ui::PAGE_TRANSITION_AUTO_SUBFRAME); 2359 ui::PAGE_TRANSITION_AUTO_SUBFRAME);
2360 } else if (ui::PageTransitionCoreTypeIs(
2361 document_state->navigation_state()->transition_type(),
2362 ui::PAGE_TRANSITION_LINK)) {
Charlie Reis 2015/03/13 23:22:14 Why is PAGE_TRANSITION_LINK the right way to detec
Nate Chapin 2015/03/13 23:28:38 This is the initial classification of a navigation
Charlie Reis 2015/03/14 00:03:49 Ah! It makes so much more sense now. :) Can you
2363 // Subframe navigations that are creating a new history item should be
2364 // marked MANUAL_SUBFRAME, unless it has already been marked as a
2365 // FORM_SUBMIT.
2366 document_state->navigation_state()->set_transition_type(
2367 ui::PAGE_TRANSITION_MANUAL_SUBFRAME);
2346 } 2368 }
2347 2369
2348 FOR_EACH_OBSERVER(RenderViewObserver, render_view_->observers(), 2370 FOR_EACH_OBSERVER(RenderViewObserver, render_view_->observers(),
2349 DidStartProvisionalLoad(frame)); 2371 DidStartProvisionalLoad(frame));
2350 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, DidStartProvisionalLoad()); 2372 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, DidStartProvisionalLoad());
2351 2373
2352 Send(new FrameHostMsg_DidStartProvisionalLoadForFrame( 2374 Send(new FrameHostMsg_DidStartProvisionalLoadForFrame(
2353 routing_id_, ds->request().url(), is_transition_navigation)); 2375 routing_id_, ds->request().url(), is_transition_navigation));
2354 } 2376 }
2355 2377
(...skipping 612 matching lines...) Expand 10 before | Expand all | Expand 10 after
2968 // TODO(nasko): When the top-level frame is remote, there is no document. 2990 // TODO(nasko): When the top-level frame is remote, there is no document.
2969 // This is broken and should be fixed to propagate the first party. 2991 // This is broken and should be fixed to propagate the first party.
2970 WebFrame* top = frame->top(); 2992 WebFrame* top = frame->top();
2971 if (top->isWebLocalFrame()) { 2993 if (top->isWebLocalFrame()) {
2972 request.setFirstPartyForCookies( 2994 request.setFirstPartyForCookies(
2973 frame->top()->document().firstPartyForCookies()); 2995 frame->top()->document().firstPartyForCookies());
2974 } 2996 }
2975 } 2997 }
2976 } 2998 }
2977 2999
2978 WebFrame* top_frame = frame->top(); 3000 WebDataSource* provisional_data_source = frame->provisionalDataSource();
2979 // TODO(nasko): Hack around asking about top-frame data source. This means
2980 // for out-of-process iframes we are treating the current frame as the
2981 // top-level frame, which is wrong.
2982 if (!top_frame || top_frame->isWebRemoteFrame())
2983 top_frame = frame;
2984 WebDataSource* provisional_data_source = top_frame->provisionalDataSource();
2985 WebDataSource* top_data_source = top_frame->dataSource();
2986 WebDataSource* data_source = 3001 WebDataSource* data_source =
2987 provisional_data_source ? provisional_data_source : top_data_source; 3002 provisional_data_source ? provisional_data_source : frame->dataSource();
2988 3003
2989 DocumentState* document_state = DocumentState::FromDataSource(data_source); 3004 DocumentState* document_state = DocumentState::FromDataSource(data_source);
2990 DCHECK(document_state); 3005 DCHECK(document_state);
2991 InternalDocumentStateData* internal_data = 3006 InternalDocumentStateData* internal_data =
2992 InternalDocumentStateData::FromDocumentState(document_state); 3007 InternalDocumentStateData::FromDocumentState(document_state);
2993 NavigationState* navigation_state = document_state->navigation_state(); 3008 NavigationState* navigation_state = document_state->navigation_state();
2994 ui::PageTransition transition_type = navigation_state->transition_type(); 3009 ui::PageTransition transition_type = navigation_state->transition_type();
2995 WebDataSource* frame_ds = frame->provisionalDataSource(); 3010 WebDataSource* frame_ds = frame->provisionalDataSource();
2996 if (frame_ds && frame_ds->isClientRedirect()) { 3011 if (frame_ds && frame_ds->isClientRedirect()) {
2997 transition_type = ui::PageTransitionFromInt( 3012 transition_type = ui::PageTransitionFromInt(
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
3114 extra_data->set_transition_type(transition_type); 3129 extra_data->set_transition_type(transition_type);
3115 extra_data->set_should_replace_current_entry(should_replace_current_entry); 3130 extra_data->set_should_replace_current_entry(should_replace_current_entry);
3116 extra_data->set_transferred_request_child_id( 3131 extra_data->set_transferred_request_child_id(
3117 navigation_state->transferred_request_child_id()); 3132 navigation_state->transferred_request_child_id());
3118 extra_data->set_transferred_request_request_id( 3133 extra_data->set_transferred_request_request_id(
3119 navigation_state->transferred_request_request_id()); 3134 navigation_state->transferred_request_request_id());
3120 extra_data->set_service_worker_provider_id(provider_id); 3135 extra_data->set_service_worker_provider_id(provider_id);
3121 extra_data->set_stream_override(stream_override.Pass()); 3136 extra_data->set_stream_override(stream_override.Pass());
3122 request.setExtraData(extra_data); 3137 request.setExtraData(extra_data);
3123 3138
3139 WebFrame* top_frame = frame->top();
3140 // TODO(nasko): Hack around asking about top-frame data source. This means
3141 // for out-of-process iframes we are treating the current frame as the
3142 // top-level frame, which is wrong.
3143 if (!top_frame || top_frame->isWebRemoteFrame())
3144 top_frame = frame;
3124 DocumentState* top_document_state = 3145 DocumentState* top_document_state =
3125 DocumentState::FromDataSource(top_data_source); 3146 DocumentState::FromDataSource(top_frame->dataSource());
3126 if (top_document_state) { 3147 if (top_document_state) {
3127 // TODO(gavinp): separate out prefetching and prerender field trials 3148 // TODO(gavinp): separate out prefetching and prerender field trials
3128 // if the rel=prerender rel type is sticking around. 3149 // if the rel=prerender rel type is sticking around.
3129 if (request.requestContext() == WebURLRequest::RequestContextPrefetch) 3150 if (request.requestContext() == WebURLRequest::RequestContextPrefetch)
3130 top_document_state->set_was_prefetcher(true); 3151 top_document_state->set_was_prefetcher(true);
Charlie Reis 2015/03/13 23:22:14 Ah, sad that we still need this hack. No worries
3131 } 3152 }
3132 3153
3133 // This is an instance where we embed a copy of the routing id 3154 // This is an instance where we embed a copy of the routing id
3134 // into the data portion of the message. This can cause problems if we 3155 // into the data portion of the message. This can cause problems if we
3135 // don't register this id on the browser side, since the download manager 3156 // don't register this id on the browser side, since the download manager
3136 // expects to find a RenderViewHost based off the id. 3157 // expects to find a RenderViewHost based off the id.
3137 request.setRequestorID(render_view_->GetRoutingID()); 3158 request.setRequestorID(render_view_->GetRoutingID());
3138 request.setHasUserGesture(WebUserGestureIndicator::isProcessingUserGesture()); 3159 request.setHasUserGesture(WebUserGestureIndicator::isProcessingUserGesture());
3139 3160
3140 if (!navigation_state->extra_headers().empty()) { 3161 if (!navigation_state->extra_headers().empty()) {
(...skipping 1382 matching lines...) Expand 10 before | Expand all | Expand 10 after
4523 4544
4524 #if defined(ENABLE_BROWSER_CDMS) 4545 #if defined(ENABLE_BROWSER_CDMS)
4525 RendererCdmManager* RenderFrameImpl::GetCdmManager() { 4546 RendererCdmManager* RenderFrameImpl::GetCdmManager() {
4526 if (!cdm_manager_) 4547 if (!cdm_manager_)
4527 cdm_manager_ = new RendererCdmManager(this); 4548 cdm_manager_ = new RendererCdmManager(this);
4528 return cdm_manager_; 4549 return cdm_manager_;
4529 } 4550 }
4530 #endif // defined(ENABLE_BROWSER_CDMS) 4551 #endif // defined(ENABLE_BROWSER_CDMS)
4531 4552
4532 } // namespace content 4553 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/frame_host/navigation_controller_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698