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

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, 8 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/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 1079 matching lines...) Expand 10 before | Expand all | Expand 10 after
1090 1090
1091 WebFrame* frame = frame_; 1091 WebFrame* frame = frame_;
1092 if (!request_params.frame_to_navigate.empty()) { 1092 if (!request_params.frame_to_navigate.empty()) {
1093 // TODO(nasko): Move this lookup to the browser process. 1093 // TODO(nasko): Move this lookup to the browser process.
1094 frame = render_view_->webview()->findFrameByName( 1094 frame = render_view_->webview()->findFrameByName(
1095 WebString::fromUTF8(request_params.frame_to_navigate)); 1095 WebString::fromUTF8(request_params.frame_to_navigate));
1096 CHECK(frame) << "Invalid frame name passed: " 1096 CHECK(frame) << "Invalid frame name passed: "
1097 << request_params.frame_to_navigate; 1097 << request_params.frame_to_navigate;
1098 } 1098 }
1099 1099
1100 // If this frame isn't in the same process as its parent, it will naively
1101 // assume that this is the first navigation in the iframe, but this may not
1102 // actually be the case. The PageTransition differentiates between the first
1103 // navigation in a subframe and subsequent navigations, so if this is a
1104 // subsequent navigation, force the frame's state machine forward.
1105 if (ui::PageTransitionCoreTypeIs(common_params.transition,
1106 ui::PAGE_TRANSITION_MANUAL_SUBFRAME)) {
1107 CHECK(frame_->parent());
1108 if (frame_->parent()->isWebRemoteFrame()) {
1109 CHECK_EQ(frame, frame_);
Charlie Reis 2015/04/15 22:46:11 Is the assumption here that frame_to_navigate is o
Nate Chapin 2015/04/17 21:48:18 Uhh, now that I trace through this, it looks like
Charlie Reis 2015/04/22 20:44:56 Hmm, ok. We can leave it as is, and I'll try to c
1110 frame_->setCommittedFirstRealLoad();
1111 }
1112 }
1113
1100 if (is_reload && !render_view_->history_controller()->GetCurrentEntry()) { 1114 if (is_reload && !render_view_->history_controller()->GetCurrentEntry()) {
1101 // We cannot reload if we do not have any history state. This happens, for 1115 // We cannot reload if we do not have any history state. This happens, for
1102 // example, when recovering from a crash. 1116 // example, when recovering from a crash.
1103 is_reload = false; 1117 is_reload = false;
1104 cache_policy = WebURLRequest::ReloadIgnoringCacheData; 1118 cache_policy = WebURLRequest::ReloadIgnoringCacheData;
1105 } 1119 }
1106 1120
1107 pending_navigation_params_.reset( 1121 pending_navigation_params_.reset(
1108 new NavigationParams(common_params, start_params, request_params)); 1122 new NavigationParams(common_params, start_params, request_params));
1109 1123
(...skipping 1427 matching lines...) Expand 10 before | Expand all | Expand 10 after
2537 // Update the request time if WebKit has better knowledge of it. 2551 // Update the request time if WebKit has better knowledge of it.
2538 if (document_state->request_time().is_null() && 2552 if (document_state->request_time().is_null() &&
2539 triggering_event_time != 0.0) { 2553 triggering_event_time != 0.0) {
2540 document_state->set_request_time(Time::FromDoubleT(triggering_event_time)); 2554 document_state->set_request_time(Time::FromDoubleT(triggering_event_time));
2541 } 2555 }
2542 2556
2543 // Start time is only set after request time. 2557 // Start time is only set after request time.
2544 document_state->set_start_load_time(Time::Now()); 2558 document_state->set_start_load_time(Time::Now());
2545 2559
2546 bool is_top_most = !frame->parent(); 2560 bool is_top_most = !frame->parent();
2561 NavigationStateImpl* navigation_state =
2562 static_cast<NavigationStateImpl*>(document_state->navigation_state());
2547 if (is_top_most) { 2563 if (is_top_most) {
2548 render_view_->set_navigation_gesture( 2564 render_view_->set_navigation_gesture(
2549 WebUserGestureIndicator::isProcessingUserGesture() ? 2565 WebUserGestureIndicator::isProcessingUserGesture() ?
2550 NavigationGestureUser : NavigationGestureAuto); 2566 NavigationGestureUser : NavigationGestureAuto);
2551 } else if (ds->replacesCurrentHistoryItem()) { 2567 } else if (ds->replacesCurrentHistoryItem()) {
2552 // Subframe navigations that don't add session history items must be 2568 // Subframe navigations that don't add session history items must be
2553 // marked with AUTO_SUBFRAME. See also didFailProvisionalLoad for how we 2569 // marked with AUTO_SUBFRAME. See also didFailProvisionalLoad for how we
2554 // handle loading of error pages. 2570 // handle loading of error pages.
2555 static_cast<NavigationStateImpl*>(document_state->navigation_state()) 2571 navigation_state->set_transition_type(ui::PAGE_TRANSITION_AUTO_SUBFRAME);
2556 ->set_transition_type(ui::PAGE_TRANSITION_AUTO_SUBFRAME); 2572 } else if (ui::PageTransitionCoreTypeIs(
2573 navigation_state->GetTransitionType(),
2574 ui::PAGE_TRANSITION_LINK)) {
2575 // Subframe navigations that are creating a new history item should be
2576 // marked MANUAL_SUBFRAME, unless it has already been marked as a
2577 // FORM_SUBMIT. This state will be attached to a main resouce request
Charlie Reis 2015/04/15 22:46:11 nit: resource
Nate Chapin 2015/04/17 21:48:18 Done.
2578 // in the process that began the request. If the request is transferred
2579 // to a different process, this state will be used in
2580 // RenderFrameImpl::OnNavigate() in the new process (as well as in the
2581 // browser process).
2582 navigation_state->set_transition_type(ui::PAGE_TRANSITION_MANUAL_SUBFRAME);
2557 } 2583 }
2558 2584
2559 FOR_EACH_OBSERVER(RenderViewObserver, render_view_->observers(), 2585 FOR_EACH_OBSERVER(RenderViewObserver, render_view_->observers(),
2560 DidStartProvisionalLoad(frame)); 2586 DidStartProvisionalLoad(frame));
2561 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, DidStartProvisionalLoad()); 2587 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, DidStartProvisionalLoad());
2562 2588
2563 Send(new FrameHostMsg_DidStartProvisionalLoadForFrame( 2589 Send(new FrameHostMsg_DidStartProvisionalLoadForFrame(
2564 routing_id_, ds->request().url(), is_transition_navigation)); 2590 routing_id_, ds->request().url(), is_transition_navigation));
2565 } 2591 }
2566 2592
(...skipping 598 matching lines...) Expand 10 before | Expand all | Expand 10 after
3165 // TODO(nasko): When the top-level frame is remote, there is no document. 3191 // TODO(nasko): When the top-level frame is remote, there is no document.
3166 // This is broken and should be fixed to propagate the first party. 3192 // This is broken and should be fixed to propagate the first party.
3167 WebFrame* top = frame->top(); 3193 WebFrame* top = frame->top();
3168 if (top->isWebLocalFrame()) { 3194 if (top->isWebLocalFrame()) {
3169 request.setFirstPartyForCookies( 3195 request.setFirstPartyForCookies(
3170 frame->top()->document().firstPartyForCookies()); 3196 frame->top()->document().firstPartyForCookies());
3171 } 3197 }
3172 } 3198 }
3173 } 3199 }
3174 3200
3175 WebFrame* top_frame = frame->top(); 3201 WebDataSource* provisional_data_source = frame->provisionalDataSource();
3176 // TODO(nasko): Hack around asking about top-frame data source. This means
3177 // for out-of-process iframes we are treating the current frame as the
3178 // top-level frame, which is wrong.
3179 if (!top_frame || top_frame->isWebRemoteFrame())
3180 top_frame = frame;
3181 WebDataSource* provisional_data_source = top_frame->provisionalDataSource();
3182 WebDataSource* top_data_source = top_frame->dataSource();
3183 WebDataSource* data_source = 3202 WebDataSource* data_source =
3184 provisional_data_source ? provisional_data_source : top_data_source; 3203 provisional_data_source ? provisional_data_source : frame->dataSource();
3185 3204
3186 DocumentState* document_state = DocumentState::FromDataSource(data_source); 3205 DocumentState* document_state = DocumentState::FromDataSource(data_source);
3187 DCHECK(document_state); 3206 DCHECK(document_state);
3188 InternalDocumentStateData* internal_data = 3207 InternalDocumentStateData* internal_data =
3189 InternalDocumentStateData::FromDocumentState(document_state); 3208 InternalDocumentStateData::FromDocumentState(document_state);
3190 NavigationStateImpl* navigation_state = 3209 NavigationStateImpl* navigation_state =
3191 static_cast<NavigationStateImpl*>(document_state->navigation_state()); 3210 static_cast<NavigationStateImpl*>(document_state->navigation_state());
3192 ui::PageTransition transition_type = navigation_state->GetTransitionType(); 3211 ui::PageTransition transition_type = navigation_state->GetTransitionType();
3193 WebDataSource* frame_ds = frame->provisionalDataSource(); 3212 WebDataSource* frame_ds = frame->provisionalDataSource();
3194 if (frame_ds && frame_ds->isClientRedirect()) { 3213 if (frame_ds && frame_ds->isClientRedirect()) {
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
3313 extra_data->set_transition_type(transition_type); 3332 extra_data->set_transition_type(transition_type);
3314 extra_data->set_should_replace_current_entry(should_replace_current_entry); 3333 extra_data->set_should_replace_current_entry(should_replace_current_entry);
3315 extra_data->set_transferred_request_child_id( 3334 extra_data->set_transferred_request_child_id(
3316 navigation_state->start_params().transferred_request_child_id); 3335 navigation_state->start_params().transferred_request_child_id);
3317 extra_data->set_transferred_request_request_id( 3336 extra_data->set_transferred_request_request_id(
3318 navigation_state->start_params().transferred_request_request_id); 3337 navigation_state->start_params().transferred_request_request_id);
3319 extra_data->set_service_worker_provider_id(provider_id); 3338 extra_data->set_service_worker_provider_id(provider_id);
3320 extra_data->set_stream_override(stream_override.Pass()); 3339 extra_data->set_stream_override(stream_override.Pass());
3321 request.setExtraData(extra_data); 3340 request.setExtraData(extra_data);
3322 3341
3342 WebFrame* top_frame = frame->top();
3343 // TODO(nasko): Hack around asking about top-frame data source. This means
3344 // for out-of-process iframes we are treating the current frame as the
3345 // top-level frame, which is wrong.
3346 if (!top_frame || top_frame->isWebRemoteFrame())
3347 top_frame = frame;
3323 DocumentState* top_document_state = 3348 DocumentState* top_document_state =
3324 DocumentState::FromDataSource(top_data_source); 3349 DocumentState::FromDataSource(top_frame->dataSource());
3325 if (top_document_state) { 3350 if (top_document_state) {
3326 // TODO(gavinp): separate out prefetching and prerender field trials 3351 // TODO(gavinp): separate out prefetching and prerender field trials
3327 // if the rel=prerender rel type is sticking around. 3352 // if the rel=prerender rel type is sticking around.
3328 if (request.requestContext() == WebURLRequest::RequestContextPrefetch) 3353 if (request.requestContext() == WebURLRequest::RequestContextPrefetch)
3329 top_document_state->set_was_prefetcher(true); 3354 top_document_state->set_was_prefetcher(true);
3330 } 3355 }
3331 3356
3332 // This is an instance where we embed a copy of the routing id 3357 // This is an instance where we embed a copy of the routing id
3333 // into the data portion of the message. This can cause problems if we 3358 // into the data portion of the message. This can cause problems if we
3334 // don't register this id on the browser side, since the download manager 3359 // don't register this id on the browser side, since the download manager
(...skipping 1447 matching lines...) Expand 10 before | Expand all | Expand 10 after
4782 #elif defined(ENABLE_BROWSER_CDMS) 4807 #elif defined(ENABLE_BROWSER_CDMS)
4783 cdm_manager_, 4808 cdm_manager_,
4784 #endif 4809 #endif
4785 this); 4810 this);
4786 } 4811 }
4787 4812
4788 return cdm_factory_; 4813 return cdm_factory_;
4789 } 4814 }
4790 4815
4791 } // namespace content 4816 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698