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

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 1082 matching lines...) Expand 10 before | Expand all | Expand 10 after
1093 1093
1094 WebFrame* frame = frame_; 1094 WebFrame* frame = frame_;
1095 if (!request_params.frame_to_navigate.empty()) { 1095 if (!request_params.frame_to_navigate.empty()) {
1096 // TODO(nasko): Move this lookup to the browser process. 1096 // TODO(nasko): Move this lookup to the browser process.
1097 frame = render_view_->webview()->findFrameByName( 1097 frame = render_view_->webview()->findFrameByName(
1098 WebString::fromUTF8(request_params.frame_to_navigate)); 1098 WebString::fromUTF8(request_params.frame_to_navigate));
1099 CHECK(frame) << "Invalid frame name passed: " 1099 CHECK(frame) << "Invalid frame name passed: "
1100 << request_params.frame_to_navigate; 1100 << request_params.frame_to_navigate;
1101 } 1101 }
1102 1102
1103 // If this frame isn't in the same process as its parent, it will naively
1104 // assume that this is the first navigation in the iframe, but this may not
1105 // actually be the case. The PageTransition differentiates between the first
1106 // navigation in a subframe and subsequent navigations, so if this is a
1107 // subsequent navigation, force the frame's state machine forward.
1108 if (ui::PageTransitionCoreTypeIs(common_params.transition,
1109 ui::PAGE_TRANSITION_MANUAL_SUBFRAME)) {
1110 CHECK(frame_->parent());
1111 if (frame_->parent()->isWebRemoteFrame()) {
1112 CHECK_EQ(frame, frame_);
1113 frame_->setCommittedFirstRealLoad();
1114 }
1115 }
1116
1103 if (is_reload && !render_view_->history_controller()->GetCurrentEntry()) { 1117 if (is_reload && !render_view_->history_controller()->GetCurrentEntry()) {
1104 // We cannot reload if we do not have any history state. This happens, for 1118 // We cannot reload if we do not have any history state. This happens, for
1105 // example, when recovering from a crash. 1119 // example, when recovering from a crash.
1106 is_reload = false; 1120 is_reload = false;
1107 cache_policy = WebURLRequest::ReloadIgnoringCacheData; 1121 cache_policy = WebURLRequest::ReloadIgnoringCacheData;
1108 } 1122 }
1109 1123
1110 pending_navigation_params_.reset( 1124 pending_navigation_params_.reset(
1111 new NavigationParams(common_params, start_params, request_params)); 1125 new NavigationParams(common_params, start_params, request_params));
1112 1126
(...skipping 1434 matching lines...) Expand 10 before | Expand all | Expand 10 after
2547 // Update the request time if WebKit has better knowledge of it. 2561 // Update the request time if WebKit has better knowledge of it.
2548 if (document_state->request_time().is_null() && 2562 if (document_state->request_time().is_null() &&
2549 triggering_event_time != 0.0) { 2563 triggering_event_time != 0.0) {
2550 document_state->set_request_time(Time::FromDoubleT(triggering_event_time)); 2564 document_state->set_request_time(Time::FromDoubleT(triggering_event_time));
2551 } 2565 }
2552 2566
2553 // Start time is only set after request time. 2567 // Start time is only set after request time.
2554 document_state->set_start_load_time(Time::Now()); 2568 document_state->set_start_load_time(Time::Now());
2555 2569
2556 bool is_top_most = !frame->parent(); 2570 bool is_top_most = !frame->parent();
2571 NavigationStateImpl* navigation_state =
2572 static_cast<NavigationStateImpl*>(document_state->navigation_state());
2557 if (is_top_most) { 2573 if (is_top_most) {
2558 render_view_->set_navigation_gesture( 2574 render_view_->set_navigation_gesture(
2559 WebUserGestureIndicator::isProcessingUserGesture() ? 2575 WebUserGestureIndicator::isProcessingUserGesture() ?
2560 NavigationGestureUser : NavigationGestureAuto); 2576 NavigationGestureUser : NavigationGestureAuto);
2561 } else if (ds->replacesCurrentHistoryItem()) { 2577 } else if (ds->replacesCurrentHistoryItem()) {
2562 // Subframe navigations that don't add session history items must be 2578 // Subframe navigations that don't add session history items must be
2563 // marked with AUTO_SUBFRAME. See also didFailProvisionalLoad for how we 2579 // marked with AUTO_SUBFRAME. See also didFailProvisionalLoad for how we
2564 // handle loading of error pages. 2580 // handle loading of error pages.
2565 static_cast<NavigationStateImpl*>(document_state->navigation_state()) 2581 navigation_state->set_transition_type(ui::PAGE_TRANSITION_AUTO_SUBFRAME);
2566 ->set_transition_type(ui::PAGE_TRANSITION_AUTO_SUBFRAME); 2582 } else if (ui::PageTransitionCoreTypeIs(
2583 navigation_state->GetTransitionType(),
Charlie Reis 2015/04/22 20:44:57 Style nit: This indent looks odd. git cl format m
Nate Chapin 2015/04/22 21:59:23 Done.
Charlie Reis 2015/04/22 22:04:29 Thanks. (I don't see the new patch uploaded yet.)
2584 ui::PAGE_TRANSITION_LINK)) {
2585 // Subframe navigations that are creating a new history item should be
2586 // marked MANUAL_SUBFRAME, unless it has already been marked as a
2587 // FORM_SUBMIT. This state will be attached to a main resource request
2588 // in the process that began the request. If the request is transferred
2589 // to a different process, this state will be used in
2590 // RenderFrameImpl::OnNavigate() in the new process (as well as in the
2591 // browser process).
2592 navigation_state->set_transition_type(ui::PAGE_TRANSITION_MANUAL_SUBFRAME);
2567 } 2593 }
2568 2594
2569 FOR_EACH_OBSERVER(RenderViewObserver, render_view_->observers(), 2595 FOR_EACH_OBSERVER(RenderViewObserver, render_view_->observers(),
2570 DidStartProvisionalLoad(frame)); 2596 DidStartProvisionalLoad(frame));
2571 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, DidStartProvisionalLoad()); 2597 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, DidStartProvisionalLoad());
2572 2598
2573 Send(new FrameHostMsg_DidStartProvisionalLoadForFrame( 2599 Send(new FrameHostMsg_DidStartProvisionalLoadForFrame(
2574 routing_id_, ds->request().url(), is_transition_navigation)); 2600 routing_id_, ds->request().url(), is_transition_navigation));
2575 } 2601 }
2576 2602
(...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after
3140 // TODO(nasko): When the top-level frame is remote, there is no document. 3166 // TODO(nasko): When the top-level frame is remote, there is no document.
3141 // This is broken and should be fixed to propagate the first party. 3167 // This is broken and should be fixed to propagate the first party.
3142 WebFrame* top = frame->top(); 3168 WebFrame* top = frame->top();
3143 if (top->isWebLocalFrame()) { 3169 if (top->isWebLocalFrame()) {
3144 request.setFirstPartyForCookies( 3170 request.setFirstPartyForCookies(
3145 frame->top()->document().firstPartyForCookies()); 3171 frame->top()->document().firstPartyForCookies());
3146 } 3172 }
3147 } 3173 }
3148 } 3174 }
3149 3175
3150 WebFrame* top_frame = frame->top(); 3176 WebDataSource* provisional_data_source = frame->provisionalDataSource();
3151 // TODO(nasko): Hack around asking about top-frame data source. This means
3152 // for out-of-process iframes we are treating the current frame as the
3153 // top-level frame, which is wrong.
3154 if (!top_frame || top_frame->isWebRemoteFrame())
3155 top_frame = frame;
3156 WebDataSource* provisional_data_source = top_frame->provisionalDataSource();
3157 WebDataSource* top_data_source = top_frame->dataSource();
3158 WebDataSource* data_source = 3177 WebDataSource* data_source =
3159 provisional_data_source ? provisional_data_source : top_data_source; 3178 provisional_data_source ? provisional_data_source : frame->dataSource();
3160 3179
3161 DocumentState* document_state = DocumentState::FromDataSource(data_source); 3180 DocumentState* document_state = DocumentState::FromDataSource(data_source);
3162 DCHECK(document_state); 3181 DCHECK(document_state);
3163 InternalDocumentStateData* internal_data = 3182 InternalDocumentStateData* internal_data =
3164 InternalDocumentStateData::FromDocumentState(document_state); 3183 InternalDocumentStateData::FromDocumentState(document_state);
3165 NavigationStateImpl* navigation_state = 3184 NavigationStateImpl* navigation_state =
3166 static_cast<NavigationStateImpl*>(document_state->navigation_state()); 3185 static_cast<NavigationStateImpl*>(document_state->navigation_state());
3167 ui::PageTransition transition_type = navigation_state->GetTransitionType(); 3186 ui::PageTransition transition_type = navigation_state->GetTransitionType();
3168 WebDataSource* frame_ds = frame->provisionalDataSource(); 3187 WebDataSource* frame_ds = frame->provisionalDataSource();
3169 if (frame_ds && frame_ds->isClientRedirect()) { 3188 if (frame_ds && frame_ds->isClientRedirect()) {
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
3288 extra_data->set_transition_type(transition_type); 3307 extra_data->set_transition_type(transition_type);
3289 extra_data->set_should_replace_current_entry(should_replace_current_entry); 3308 extra_data->set_should_replace_current_entry(should_replace_current_entry);
3290 extra_data->set_transferred_request_child_id( 3309 extra_data->set_transferred_request_child_id(
3291 navigation_state->start_params().transferred_request_child_id); 3310 navigation_state->start_params().transferred_request_child_id);
3292 extra_data->set_transferred_request_request_id( 3311 extra_data->set_transferred_request_request_id(
3293 navigation_state->start_params().transferred_request_request_id); 3312 navigation_state->start_params().transferred_request_request_id);
3294 extra_data->set_service_worker_provider_id(provider_id); 3313 extra_data->set_service_worker_provider_id(provider_id);
3295 extra_data->set_stream_override(stream_override.Pass()); 3314 extra_data->set_stream_override(stream_override.Pass());
3296 request.setExtraData(extra_data); 3315 request.setExtraData(extra_data);
3297 3316
3317 WebFrame* top_frame = frame->top();
3318 // TODO(nasko): Hack around asking about top-frame data source. This means
3319 // for out-of-process iframes we are treating the current frame as the
3320 // top-level frame, which is wrong.
3321 if (!top_frame || top_frame->isWebRemoteFrame())
3322 top_frame = frame;
3298 DocumentState* top_document_state = 3323 DocumentState* top_document_state =
3299 DocumentState::FromDataSource(top_data_source); 3324 DocumentState::FromDataSource(top_frame->dataSource());
3300 if (top_document_state) { 3325 if (top_document_state) {
3301 // TODO(gavinp): separate out prefetching and prerender field trials 3326 // TODO(gavinp): separate out prefetching and prerender field trials
3302 // if the rel=prerender rel type is sticking around. 3327 // if the rel=prerender rel type is sticking around.
3303 if (request.requestContext() == WebURLRequest::RequestContextPrefetch) 3328 if (request.requestContext() == WebURLRequest::RequestContextPrefetch)
3304 top_document_state->set_was_prefetcher(true); 3329 top_document_state->set_was_prefetcher(true);
3305 } 3330 }
3306 3331
3307 // This is an instance where we embed a copy of the routing id 3332 // This is an instance where we embed a copy of the routing id
3308 // into the data portion of the message. This can cause problems if we 3333 // into the data portion of the message. This can cause problems if we
3309 // don't register this id on the browser side, since the download manager 3334 // don't register this id on the browser side, since the download manager
(...skipping 1543 matching lines...) Expand 10 before | Expand all | Expand 10 after
4853 #elif defined(ENABLE_BROWSER_CDMS) 4878 #elif defined(ENABLE_BROWSER_CDMS)
4854 cdm_manager_, 4879 cdm_manager_,
4855 #endif 4880 #endif
4856 this); 4881 this);
4857 } 4882 }
4858 4883
4859 return cdm_factory_; 4884 return cdm_factory_;
4860 } 4885 }
4861 4886
4862 } // namespace content 4887 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698