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

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: Fix style 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(navigation_state->GetTransitionType(),
2583 ui::PAGE_TRANSITION_LINK)) {
2584 // Subframe navigations that are creating a new history item should be
2585 // marked MANUAL_SUBFRAME, unless it has already been marked as a
2586 // FORM_SUBMIT. This state will be attached to a main resource request
2587 // in the process that began the request. If the request is transferred
2588 // to a different process, this state will be used in
2589 // RenderFrameImpl::OnNavigate() in the new process (as well as in the
2590 // browser process).
2591 navigation_state->set_transition_type(ui::PAGE_TRANSITION_MANUAL_SUBFRAME);
2567 } 2592 }
2568 2593
2569 FOR_EACH_OBSERVER(RenderViewObserver, render_view_->observers(), 2594 FOR_EACH_OBSERVER(RenderViewObserver, render_view_->observers(),
2570 DidStartProvisionalLoad(frame)); 2595 DidStartProvisionalLoad(frame));
2571 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, DidStartProvisionalLoad()); 2596 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, DidStartProvisionalLoad());
2572 2597
2573 Send(new FrameHostMsg_DidStartProvisionalLoadForFrame( 2598 Send(new FrameHostMsg_DidStartProvisionalLoadForFrame(
2574 routing_id_, ds->request().url(), is_transition_navigation)); 2599 routing_id_, ds->request().url(), is_transition_navigation));
2575 } 2600 }
2576 2601
(...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. 3165 // 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. 3166 // This is broken and should be fixed to propagate the first party.
3142 WebFrame* top = frame->top(); 3167 WebFrame* top = frame->top();
3143 if (top->isWebLocalFrame()) { 3168 if (top->isWebLocalFrame()) {
3144 request.setFirstPartyForCookies( 3169 request.setFirstPartyForCookies(
3145 frame->top()->document().firstPartyForCookies()); 3170 frame->top()->document().firstPartyForCookies());
3146 } 3171 }
3147 } 3172 }
3148 } 3173 }
3149 3174
3150 WebFrame* top_frame = frame->top(); 3175 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 = 3176 WebDataSource* data_source =
3159 provisional_data_source ? provisional_data_source : top_data_source; 3177 provisional_data_source ? provisional_data_source : frame->dataSource();
3160 3178
3161 DocumentState* document_state = DocumentState::FromDataSource(data_source); 3179 DocumentState* document_state = DocumentState::FromDataSource(data_source);
3162 DCHECK(document_state); 3180 DCHECK(document_state);
3163 InternalDocumentStateData* internal_data = 3181 InternalDocumentStateData* internal_data =
3164 InternalDocumentStateData::FromDocumentState(document_state); 3182 InternalDocumentStateData::FromDocumentState(document_state);
3165 NavigationStateImpl* navigation_state = 3183 NavigationStateImpl* navigation_state =
3166 static_cast<NavigationStateImpl*>(document_state->navigation_state()); 3184 static_cast<NavigationStateImpl*>(document_state->navigation_state());
3167 ui::PageTransition transition_type = navigation_state->GetTransitionType(); 3185 ui::PageTransition transition_type = navigation_state->GetTransitionType();
3168 WebDataSource* frame_ds = frame->provisionalDataSource(); 3186 WebDataSource* frame_ds = frame->provisionalDataSource();
3169 if (frame_ds && frame_ds->isClientRedirect()) { 3187 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); 3306 extra_data->set_transition_type(transition_type);
3289 extra_data->set_should_replace_current_entry(should_replace_current_entry); 3307 extra_data->set_should_replace_current_entry(should_replace_current_entry);
3290 extra_data->set_transferred_request_child_id( 3308 extra_data->set_transferred_request_child_id(
3291 navigation_state->start_params().transferred_request_child_id); 3309 navigation_state->start_params().transferred_request_child_id);
3292 extra_data->set_transferred_request_request_id( 3310 extra_data->set_transferred_request_request_id(
3293 navigation_state->start_params().transferred_request_request_id); 3311 navigation_state->start_params().transferred_request_request_id);
3294 extra_data->set_service_worker_provider_id(provider_id); 3312 extra_data->set_service_worker_provider_id(provider_id);
3295 extra_data->set_stream_override(stream_override.Pass()); 3313 extra_data->set_stream_override(stream_override.Pass());
3296 request.setExtraData(extra_data); 3314 request.setExtraData(extra_data);
3297 3315
3316 WebFrame* top_frame = frame->top();
3317 // TODO(nasko): Hack around asking about top-frame data source. This means
3318 // for out-of-process iframes we are treating the current frame as the
3319 // top-level frame, which is wrong.
3320 if (!top_frame || top_frame->isWebRemoteFrame())
3321 top_frame = frame;
3298 DocumentState* top_document_state = 3322 DocumentState* top_document_state =
3299 DocumentState::FromDataSource(top_data_source); 3323 DocumentState::FromDataSource(top_frame->dataSource());
3300 if (top_document_state) { 3324 if (top_document_state) {
3301 // TODO(gavinp): separate out prefetching and prerender field trials 3325 // TODO(gavinp): separate out prefetching and prerender field trials
3302 // if the rel=prerender rel type is sticking around. 3326 // if the rel=prerender rel type is sticking around.
3303 if (request.requestContext() == WebURLRequest::RequestContextPrefetch) 3327 if (request.requestContext() == WebURLRequest::RequestContextPrefetch)
3304 top_document_state->set_was_prefetcher(true); 3328 top_document_state->set_was_prefetcher(true);
3305 } 3329 }
3306 3330
3307 // This is an instance where we embed a copy of the routing id 3331 // 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 3332 // 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 3333 // don't register this id on the browser side, since the download manager
(...skipping 1547 matching lines...) Expand 10 before | Expand all | Expand 10 after
4857 #elif defined(ENABLE_BROWSER_CDMS) 4881 #elif defined(ENABLE_BROWSER_CDMS)
4858 cdm_manager_, 4882 cdm_manager_,
4859 #endif 4883 #endif
4860 this); 4884 this);
4861 } 4885 }
4862 4886
4863 return cdm_factory_; 4887 return cdm_factory_;
4864 } 4888 }
4865 4889
4866 } // namespace content 4890 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/site_per_process_browsertest.cc ('k') | content/test/test_frame_navigation_observer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698