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

Side by Side Diff: content/browser/frame_host/render_frame_host_impl.cc

Issue 423393008: Keep a copy of page id in RenderViewHost. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: comment Created 6 years, 4 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
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/browser/frame_host/render_frame_host_impl.h" 5 #include "content/browser/frame_host/render_frame_host_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/containers/hash_tables.h" 8 #include "base/containers/hash_tables.h"
9 #include "base/lazy_instance.h" 9 #include "base/lazy_instance.h"
10 #include "base/metrics/user_metrics_action.h" 10 #include "base/metrics/user_metrics_action.h"
(...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after
545 GetProcess()->FilterURL(false, &validated_url); 545 GetProcess()->FilterURL(false, &validated_url);
546 546
547 frame_tree_node_->navigator()->DidFailLoadWithError( 547 frame_tree_node_->navigator()->DidFailLoadWithError(
548 this, validated_url, error_code, error_description); 548 this, validated_url, error_code, error_description);
549 } 549 }
550 550
551 void RenderFrameHostImpl::OnDidRedirectProvisionalLoad( 551 void RenderFrameHostImpl::OnDidRedirectProvisionalLoad(
552 int32 page_id, 552 int32 page_id,
553 const GURL& source_url, 553 const GURL& source_url,
554 const GURL& target_url) { 554 const GURL& target_url) {
555 CHECK_EQ(render_view_host_->page_id_, page_id);
555 frame_tree_node_->navigator()->DidRedirectProvisionalLoad( 556 frame_tree_node_->navigator()->DidRedirectProvisionalLoad(
556 this, page_id, source_url, target_url); 557 this, render_view_host_->page_id_, source_url, target_url);
557 } 558 }
558 559
559 // Called when the renderer navigates. For every frame loaded, we'll get this 560 // Called when the renderer navigates. For every frame loaded, we'll get this
560 // notification containing parameters identifying the navigation. 561 // notification containing parameters identifying the navigation.
561 // 562 //
562 // Subframes are identified by the page transition type. For subframes loaded 563 // Subframes are identified by the page transition type. For subframes loaded
563 // as part of a wider page load, the page_id will be the same as for the top 564 // as part of a wider page load, the page_id will be the same as for the top
564 // level frame. If the user explicitly requests a subframe navigation, we will 565 // level frame. If the user explicitly requests a subframe navigation, we will
565 // get a new page_id because we need to create a new navigation entry for that 566 // get a new page_id because we need to create a new navigation entry for that
566 // action. 567 // action.
567 void RenderFrameHostImpl::OnNavigate(const IPC::Message& msg) { 568 void RenderFrameHostImpl::OnNavigate(const IPC::Message& msg) {
568 // Read the parameters out of the IPC message directly to avoid making another 569 // Read the parameters out of the IPC message directly to avoid making another
569 // copy when we filter the URLs. 570 // copy when we filter the URLs.
570 PickleIterator iter(msg); 571 PickleIterator iter(msg);
571 FrameHostMsg_DidCommitProvisionalLoad_Params validated_params; 572 FrameHostMsg_DidCommitProvisionalLoad_Params validated_params;
572 if (!IPC::ParamTraits<FrameHostMsg_DidCommitProvisionalLoad_Params>:: 573 if (!IPC::ParamTraits<FrameHostMsg_DidCommitProvisionalLoad_Params>::
573 Read(&msg, &iter, &validated_params)) 574 Read(&msg, &iter, &validated_params))
574 return; 575 return;
575 576
577 // Update the RVH's current page ID so that future IPCs from the renderer
578 // correspond to the new page.
579 render_view_host_->page_id_ = validated_params.page_id;
580
576 // If we're waiting for a cross-site beforeunload ack from this renderer and 581 // If we're waiting for a cross-site beforeunload ack from this renderer and
577 // we receive a Navigate message from the main frame, then the renderer was 582 // we receive a Navigate message from the main frame, then the renderer was
578 // navigating already and sent it before hearing the ViewMsg_Stop message. 583 // navigating already and sent it before hearing the ViewMsg_Stop message.
579 // We do not want to cancel the pending navigation in this case, since the 584 // We do not want to cancel the pending navigation in this case, since the
580 // old page will soon be stopped. Instead, treat this as a beforeunload ack 585 // old page will soon be stopped. Instead, treat this as a beforeunload ack
581 // to allow the pending navigation to continue. 586 // to allow the pending navigation to continue.
582 if (render_view_host_->is_waiting_for_beforeunload_ack_ && 587 if (render_view_host_->is_waiting_for_beforeunload_ack_ &&
583 render_view_host_->unload_ack_is_for_cross_site_transition_ && 588 render_view_host_->unload_ack_is_for_cross_site_transition_ &&
584 PageTransitionIsMainFrame(validated_params.transition)) { 589 PageTransitionIsMainFrame(validated_params.transition)) {
585 OnBeforeUnloadACK(true, send_before_unload_start_time_, 590 OnBeforeUnloadACK(true, send_before_unload_start_time_,
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
878 void RenderFrameHostImpl::OnDidDisownOpener() { 883 void RenderFrameHostImpl::OnDidDisownOpener() {
879 // This message is only sent for top-level frames. TODO(avi): when frame tree 884 // This message is only sent for top-level frames. TODO(avi): when frame tree
880 // mirroring works correctly, add a check here to enforce it. 885 // mirroring works correctly, add a check here to enforce it.
881 delegate_->DidDisownOpener(this); 886 delegate_->DidDisownOpener(this);
882 } 887 }
883 888
884 void RenderFrameHostImpl::OnUpdateTitle( 889 void RenderFrameHostImpl::OnUpdateTitle(
885 int32 page_id, 890 int32 page_id,
886 const base::string16& title, 891 const base::string16& title,
887 blink::WebTextDirection title_direction) { 892 blink::WebTextDirection title_direction) {
893 CHECK_EQ(render_view_host_->page_id_, page_id);
888 // This message is only sent for top-level frames. TODO(avi): when frame tree 894 // This message is only sent for top-level frames. TODO(avi): when frame tree
889 // mirroring works correctly, add a check here to enforce it. 895 // mirroring works correctly, add a check here to enforce it.
890 if (title.length() > kMaxTitleChars) { 896 if (title.length() > kMaxTitleChars) {
891 NOTREACHED() << "Renderer sent too many characters in title."; 897 NOTREACHED() << "Renderer sent too many characters in title.";
892 return; 898 return;
893 } 899 }
894 900
895 delegate_->UpdateTitle(this, page_id, title, 901 delegate_->UpdateTitle(this, render_view_host_->page_id_, title,
896 WebTextDirectionToChromeTextDirection( 902 WebTextDirectionToChromeTextDirection(
897 title_direction)); 903 title_direction));
898 } 904 }
899 905
900 void RenderFrameHostImpl::OnUpdateEncoding(const std::string& encoding_name) { 906 void RenderFrameHostImpl::OnUpdateEncoding(const std::string& encoding_name) {
901 // This message is only sent for top-level frames. TODO(avi): when frame tree 907 // This message is only sent for top-level frames. TODO(avi): when frame tree
902 // mirroring works correctly, add a check here to enforce it. 908 // mirroring works correctly, add a check here to enforce it.
903 delegate_->UpdateEncoding(this, encoding_name); 909 delegate_->UpdateEncoding(this, encoding_name);
904 } 910 }
905 911
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
1195 FROM_HERE, 1201 FROM_HERE,
1196 base::Bind( 1202 base::Bind(
1197 &TransitionRequestManager::SetHasPendingTransitionRequest, 1203 &TransitionRequestManager::SetHasPendingTransitionRequest,
1198 base::Unretained(TransitionRequestManager::GetInstance()), 1204 base::Unretained(TransitionRequestManager::GetInstance()),
1199 GetProcess()->GetID(), 1205 GetProcess()->GetID(),
1200 routing_id_, 1206 routing_id_,
1201 has_pending_request)); 1207 has_pending_request));
1202 } 1208 }
1203 1209
1204 } // namespace content 1210 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698