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

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

Issue 281653003: DRAFT CL: Add FrameNavigationEntry and track subframe session histories. Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase 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 | Annotate | Revision Log
« no previous file with comments | « content/renderer/render_frame_impl.h ('k') | content/renderer/render_frame_proxy.cc » ('j') | 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 1110 matching lines...) Expand 10 before | Expand all | Expand 10 after
1121 frame->reload(ignore_cache); 1121 frame->reload(ignore_cache);
1122 } else if (is_history_navigation) { 1122 } else if (is_history_navigation) {
1123 // We must know the page ID of the page we are navigating back to. 1123 // We must know the page ID of the page we are navigating back to.
1124 DCHECK_NE(history_params.page_id, -1); 1124 DCHECK_NE(history_params.page_id, -1);
1125 scoped_ptr<HistoryEntry> entry = 1125 scoped_ptr<HistoryEntry> entry =
1126 PageStateToHistoryEntry(history_params.page_state); 1126 PageStateToHistoryEntry(history_params.page_state);
1127 if (entry) { 1127 if (entry) {
1128 // Ensure we didn't save the swapped out URL in UpdateState, since the 1128 // Ensure we didn't save the swapped out URL in UpdateState, since the
1129 // browser should never be telling us to navigate to swappedout://. 1129 // browser should never be telling us to navigate to swappedout://.
1130 CHECK(entry->root().urlString() != WebString::fromUTF8(kSwappedOutURL)); 1130 CHECK(entry->root().urlString() != WebString::fromUTF8(kSwappedOutURL));
1131 render_view_->history_controller()->GoToEntry(entry.Pass(), cache_policy); 1131
1132 // TODO(creis): Remove this HistoryEntry hack. We need it to find the
1133 // frame sequence number when swapping a remote frame back to local.
1134 RenderFrameProxy* proxy =
1135 RenderFrameProxy::FromRoutingID(proxy_routing_id_);
1136 if (proxy)
1137 HistoryEntry::UpdateFrameMap(proxy_routing_id_, routing_id_);
1138
1139 // TODO(creis): Same vs different document load.
1140 // TODO(creis): Change PageState to FrameState. In the meantime, we store
1141 // the relevant frame's HistoryItem in the root of the PageState.
1142 blink::WebHistoryItem history_item = entry->root();
1143 frame->loadHistoryItem(history_item,
1144 blink::WebHistoryDifferentDocumentLoad,
1145 cache_policy);
1132 } 1146 }
1133 } else if (!common_params.base_url_for_data_url.is_empty()) { 1147 } else if (!common_params.base_url_for_data_url.is_empty()) {
1134 LoadDataURL(common_params, frame); 1148 LoadDataURL(common_params, frame);
1135 } else { 1149 } else {
1136 // Navigate to the given URL. 1150 // Navigate to the given URL.
1137 WebURLRequest request = CreateURLRequestForNavigation( 1151 WebURLRequest request = CreateURLRequestForNavigation(
1138 common_params, scoped_ptr<StreamOverrideParameters>(), 1152 common_params, scoped_ptr<StreamOverrideParameters>(),
1139 frame->isViewSourceModeEnabled()); 1153 frame->isViewSourceModeEnabled());
1140 1154
1141 if (!start_params.extra_headers.empty()) { 1155 if (!start_params.extra_headers.empty()) {
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
1292 if (is_main_frame) 1306 if (is_main_frame)
1293 render_view_->suppress_dialogs_until_swap_out_ = false; 1307 render_view_->suppress_dialogs_until_swap_out_ = false;
1294 1308
1295 Send(new FrameHostMsg_SwapOut_ACK(routing_id_)); 1309 Send(new FrameHostMsg_SwapOut_ACK(routing_id_));
1296 1310
1297 // Now that all of the cleanup is complete and the browser side is notified, 1311 // Now that all of the cleanup is complete and the browser side is notified,
1298 // start using the RenderFrameProxy, if one is created. 1312 // start using the RenderFrameProxy, if one is created.
1299 if (proxy) { 1313 if (proxy) {
1300 if (!is_main_frame) { 1314 if (!is_main_frame) {
1301 frame_->swap(proxy->web_frame()); 1315 frame_->swap(proxy->web_frame());
1316 // TODO(creis): Remove this HistoryEntry hack.
1317 HistoryEntry::UpdateFrameMap(routing_id_, proxy_routing_id);
1302 1318
1303 if (is_loading) 1319 if (is_loading)
1304 proxy->OnDidStartLoading(); 1320 proxy->OnDidStartLoading();
1305 1321
1306 if (is_site_per_process) { 1322 if (is_site_per_process) {
1307 // TODO(nasko): delete the frame here, since we've replaced it with a 1323 // TODO(nasko): delete the frame here, since we've replaced it with a
1308 // proxy. 1324 // proxy.
1309 } 1325 }
1310 } else { 1326 } else {
1311 set_render_frame_proxy(proxy); 1327 set_render_frame_proxy(proxy);
(...skipping 1216 matching lines...) Expand 10 before | Expand all | Expand 10 after
2528 2544
2529 if (internal_data->must_reset_scroll_and_scale_state()) { 2545 if (internal_data->must_reset_scroll_and_scale_state()) {
2530 render_view_->webview()->resetScrollAndScaleState(); 2546 render_view_->webview()->resetScrollAndScaleState();
2531 internal_data->set_must_reset_scroll_and_scale_state(false); 2547 internal_data->set_must_reset_scroll_and_scale_state(false);
2532 } 2548 }
2533 internal_data->set_use_error_page(false); 2549 internal_data->set_use_error_page(false);
2534 2550
2535 bool is_new_navigation = commit_type == blink::WebStandardCommit; 2551 bool is_new_navigation = commit_type == blink::WebStandardCommit;
2536 if (is_new_navigation) { 2552 if (is_new_navigation) {
2537 // We bump our Page ID to correspond with the new session history entry. 2553 // We bump our Page ID to correspond with the new session history entry.
2538 render_view_->page_id_ = render_view_->next_page_id_++; 2554 // TODO(creis): Update this.
2555 //render_view_->page_id_ = render_view_->next_page_id_++;
2556 render_view_->page_id_ = -1;
2539 2557
2540 // Don't update history list values for kSwappedOutURL, since 2558 // Don't update history list values for kSwappedOutURL, since
2541 // we don't want to forget the entry that was there, and since we will 2559 // we don't want to forget the entry that was there, and since we will
2542 // never come back to kSwappedOutURL. Note that we have to call 2560 // never come back to kSwappedOutURL. Note that we have to call
2543 // UpdateSessionHistory and update page_id_ even in this case, so that 2561 // UpdateSessionHistory and update page_id_ even in this case, so that
2544 // the current entry gets a state update and so that we don't send a 2562 // the current entry gets a state update and so that we don't send a
2545 // state update to the wrong entry when we swap back in. 2563 // state update to the wrong entry when we swap back in.
2546 DCHECK_IMPLIES( 2564 DCHECK_IMPLIES(
2547 navigation_state->start_params().should_replace_current_entry, 2565 navigation_state->start_params().should_replace_current_entry,
2548 render_view_->history_list_length_ > 0); 2566 render_view_->history_list_length_ > 0);
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
2598 } 2616 }
2599 } 2617 }
2600 2618
2601 // Remember that we've already processed this request, so we don't update 2619 // Remember that we've already processed this request, so we don't update
2602 // the session history again. We do this regardless of whether this is 2620 // the session history again. We do this regardless of whether this is
2603 // a session history navigation, because if we attempted a session history 2621 // a session history navigation, because if we attempted a session history
2604 // navigation without valid HistoryItem state, WebCore will think it is a 2622 // navigation without valid HistoryItem state, WebCore will think it is a
2605 // new navigation. 2623 // new navigation.
2606 navigation_state->set_request_committed(true); 2624 navigation_state->set_request_committed(true);
2607 2625
2608 SendDidCommitProvisionalLoad(frame, commit_type); 2626 SendDidCommitProvisionalLoad(frame, commit_type, item);
2609 2627
2610 // Check whether we have new encoding name. 2628 // Check whether we have new encoding name.
2611 UpdateEncoding(frame, frame->view()->pageEncoding().utf8()); 2629 UpdateEncoding(frame, frame->view()->pageEncoding().utf8());
2612 } 2630 }
2613 2631
2614 void RenderFrameImpl::didCreateNewDocument(blink::WebLocalFrame* frame) { 2632 void RenderFrameImpl::didCreateNewDocument(blink::WebLocalFrame* frame) {
2615 DCHECK(!frame_ || frame_ == frame); 2633 DCHECK(!frame_ || frame_ == frame);
2616 2634
2617 FOR_EACH_OBSERVER(RenderViewObserver, render_view_->observers(), 2635 FOR_EACH_OBSERVER(RenderViewObserver, render_view_->observers(),
2618 DidCreateNewDocument(frame)); 2636 DidCreateNewDocument(frame));
(...skipping 1098 matching lines...) Expand 10 before | Expand all | Expand 10 after
3717 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, WasShown()); 3735 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, WasShown());
3718 } 3736 }
3719 3737
3720 bool RenderFrameImpl::IsHidden() { 3738 bool RenderFrameImpl::IsHidden() {
3721 return GetRenderWidget()->is_hidden(); 3739 return GetRenderWidget()->is_hidden();
3722 } 3740 }
3723 3741
3724 // Tell the embedding application that the URL of the active page has changed. 3742 // Tell the embedding application that the URL of the active page has changed.
3725 void RenderFrameImpl::SendDidCommitProvisionalLoad( 3743 void RenderFrameImpl::SendDidCommitProvisionalLoad(
3726 blink::WebFrame* frame, 3744 blink::WebFrame* frame,
3727 blink::WebHistoryCommitType commit_type) { 3745 blink::WebHistoryCommitType commit_type,
3746 const blink::WebHistoryItem& item) {
3728 DCHECK(!frame_ || frame_ == frame); 3747 DCHECK(!frame_ || frame_ == frame);
3729 WebDataSource* ds = frame->dataSource(); 3748 WebDataSource* ds = frame->dataSource();
3730 DCHECK(ds); 3749 DCHECK(ds);
3731 3750
3732 const WebURLRequest& request = ds->request(); 3751 const WebURLRequest& request = ds->request();
3733 const WebURLResponse& response = ds->response(); 3752 const WebURLResponse& response = ds->response();
3734 3753
3735 DocumentState* document_state = DocumentState::FromDataSource(ds); 3754 DocumentState* document_state = DocumentState::FromDataSource(ds);
3736 NavigationStateImpl* navigation_state = 3755 NavigationStateImpl* navigation_state =
3737 static_cast<NavigationStateImpl*>(document_state->navigation_state()); 3756 static_cast<NavigationStateImpl*>(document_state->navigation_state());
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
3783 3802
3784 params.searchable_form_url = internal_data->searchable_form_url(); 3803 params.searchable_form_url = internal_data->searchable_form_url();
3785 params.searchable_form_encoding = internal_data->searchable_form_encoding(); 3804 params.searchable_form_encoding = internal_data->searchable_form_encoding();
3786 3805
3787 params.gesture = render_view_->navigation_gesture_; 3806 params.gesture = render_view_->navigation_gesture_;
3788 render_view_->navigation_gesture_ = NavigationGestureUnknown; 3807 render_view_->navigation_gesture_ = NavigationGestureUnknown;
3789 3808
3790 // Make navigation state a part of the DidCommitProvisionalLoad message so 3809 // Make navigation state a part of the DidCommitProvisionalLoad message so
3791 // that committed entry has it at all times. 3810 // that committed entry has it at all times.
3792 HistoryEntry* entry = render_view_->history_controller()->GetCurrentEntry(); 3811 HistoryEntry* entry = render_view_->history_controller()->GetCurrentEntry();
3793 if (entry) 3812 // TODO(creis): Change PageState to FrameState.
3794 params.page_state = HistoryEntryToPageState(entry); 3813 params.page_state = SingleHistoryItemToPageState(item);
3795 else 3814 params.item_sequence_number = item.itemSequenceNumber();
3796 params.page_state = PageState::CreateFromURL(request.url()); 3815 params.document_sequence_number = item.documentSequenceNumber();
3797 3816
3798 if (!frame->parent()) { 3817 if (!frame->parent()) {
3799 // Top-level navigation. 3818 // Top-level navigation.
3800 3819
3801 // Reset the zoom limits in case a plugin had changed them previously. This 3820 // Reset the zoom limits in case a plugin had changed them previously. This
3802 // will also call us back which will cause us to send a message to 3821 // will also call us back which will cause us to send a message to
3803 // update WebContentsImpl. 3822 // update WebContentsImpl.
3804 render_view_->webview()->zoomLimitsChanged( 3823 render_view_->webview()->zoomLimitsChanged(
3805 ZoomFactorToZoomLevel(kMinimumZoomFactor), 3824 ZoomFactorToZoomLevel(kMinimumZoomFactor),
3806 ZoomFactorToZoomLevel(kMaximumZoomFactor)); 3825 ZoomFactorToZoomLevel(kMaximumZoomFactor));
(...skipping 594 matching lines...) Expand 10 before | Expand all | Expand 10 after
4401 MaybeHandleDebugURL(url); 4420 MaybeHandleDebugURL(url);
4402 if (!render_view_->webview()) 4421 if (!render_view_->webview())
4403 return false; 4422 return false;
4404 4423
4405 FOR_EACH_OBSERVER( 4424 FOR_EACH_OBSERVER(
4406 RenderViewObserver, render_view_->observers_, Navigate(url)); 4425 RenderViewObserver, render_view_->observers_, Navigate(url));
4407 4426
4408 // If this is a stale back/forward (due to a recent navigation the browser 4427 // If this is a stale back/forward (due to a recent navigation the browser
4409 // didn't know about), ignore it. Only check if swapped in because if the 4428 // didn't know about), ignore it. Only check if swapped in because if the
4410 // frame is swapped out, it won't commit before asking the browser. 4429 // frame is swapped out, it won't commit before asking the browser.
4430 // TODO(creis): Make this check work for OOPIF.
4411 if (!render_view_->is_swapped_out() && is_history_navigation && 4431 if (!render_view_->is_swapped_out() && is_history_navigation &&
4412 render_view_->history_list_offset_ != 4432 render_view_->history_list_offset_ !=
4413 history_params.current_history_list_offset) { 4433 history_params.current_history_list_offset) {
4414 return false; 4434 return false;
4415 } 4435 }
4416 4436
4417 render_view_->history_list_offset_ = 4437 render_view_->history_list_offset_ =
4418 history_params.current_history_list_offset; 4438 history_params.current_history_list_offset;
4419 render_view_->history_list_length_ = 4439 render_view_->history_list_length_ =
4420 history_params.current_history_list_length; 4440 history_params.current_history_list_length;
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
4564 4584
4565 #if defined(ENABLE_BROWSER_CDMS) 4585 #if defined(ENABLE_BROWSER_CDMS)
4566 RendererCdmManager* RenderFrameImpl::GetCdmManager() { 4586 RendererCdmManager* RenderFrameImpl::GetCdmManager() {
4567 if (!cdm_manager_) 4587 if (!cdm_manager_)
4568 cdm_manager_ = new RendererCdmManager(this); 4588 cdm_manager_ = new RendererCdmManager(this);
4569 return cdm_manager_; 4589 return cdm_manager_;
4570 } 4590 }
4571 #endif // defined(ENABLE_BROWSER_CDMS) 4591 #endif // defined(ENABLE_BROWSER_CDMS)
4572 4592
4573 } // namespace content 4593 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/render_frame_impl.h ('k') | content/renderer/render_frame_proxy.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698