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

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

Issue 2628133002: When a proxy is detached, immediately delete its associated provisional frame. (Closed)
Patch Set: Remove (hopefully unnecessary) null check Created 3 years, 11 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 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 980 matching lines...) Expand 10 before | Expand all | Expand 10 after
991 // The RenderFrame is created and inserted into the frame tree in the above 991 // The RenderFrame is created and inserted into the frame tree in the above
992 // call to createLocalChild. 992 // call to createLocalChild.
993 render_frame->in_frame_tree_ = true; 993 render_frame->in_frame_tree_ = true;
994 } else { 994 } else {
995 RenderFrameProxy* proxy = 995 RenderFrameProxy* proxy =
996 RenderFrameProxy::FromRoutingID(proxy_routing_id); 996 RenderFrameProxy::FromRoutingID(proxy_routing_id);
997 // The remote frame could've been detached while the remote-to-local 997 // The remote frame could've been detached while the remote-to-local
998 // navigation was being initiated in the browser process. Drop the 998 // navigation was being initiated in the browser process. Drop the
999 // navigation and don't create the frame in that case. See 999 // navigation and don't create the frame in that case. See
1000 // https://crbug.com/526304. 1000 // https://crbug.com/526304.
1001 if (!proxy) 1001 if (!proxy)
alexmos 2017/01/13 02:26:54 This one is still necessary: if the proxy was deta
Charlie Reis 2017/01/18 00:18:41 Yes, since this is a static method. Agreed.
1002 return; 1002 return;
1003 1003
1004 render_frame = RenderFrameImpl::Create(proxy->render_view(), routing_id); 1004 render_frame = RenderFrameImpl::Create(proxy->render_view(), routing_id);
1005 render_frame->InitializeBlameContext(nullptr); 1005 render_frame->InitializeBlameContext(nullptr);
1006 render_frame->proxy_routing_id_ = proxy_routing_id; 1006 render_frame->proxy_routing_id_ = proxy_routing_id;
1007 proxy->set_provisional_frame_routing_id(routing_id);
1007 web_frame = blink::WebLocalFrame::createProvisional( 1008 web_frame = blink::WebLocalFrame::createProvisional(
1008 render_frame, proxy->web_frame(), replicated_state.sandbox_flags); 1009 render_frame, proxy->web_frame(), replicated_state.sandbox_flags);
1009 } 1010 }
1010 render_frame->BindToWebFrame(web_frame); 1011 render_frame->BindToWebFrame(web_frame);
1011 CHECK(parent_routing_id != MSG_ROUTING_NONE || !web_frame->parent()); 1012 CHECK(parent_routing_id != MSG_ROUTING_NONE || !web_frame->parent());
1012 1013
1013 if (widget_params.routing_id != MSG_ROUTING_NONE) { 1014 if (widget_params.routing_id != MSG_ROUTING_NONE) {
1014 CHECK(!web_frame->parent() || 1015 CHECK(!web_frame->parent() ||
1015 SiteIsolationPolicy::AreCrossProcessFramesPossible()); 1016 SiteIsolationPolicy::AreCrossProcessFramesPossible());
1016 render_frame->render_widget_ = RenderWidget::CreateForFrame( 1017 render_frame->render_widget_ = RenderWidget::CreateForFrame(
(...skipping 586 matching lines...) Expand 10 before | Expand all | Expand 10 after
1603 void RenderFrameImpl::OnAssociatedInterfaceRequest( 1604 void RenderFrameImpl::OnAssociatedInterfaceRequest(
1604 const std::string& interface_name, 1605 const std::string& interface_name,
1605 mojo::ScopedInterfaceEndpointHandle handle) { 1606 mojo::ScopedInterfaceEndpointHandle handle) {
1606 associated_interfaces_.BindRequest(interface_name, std::move(handle)); 1607 associated_interfaces_.BindRequest(interface_name, std::move(handle));
1607 } 1608 }
1608 1609
1609 void RenderFrameImpl::OnNavigate( 1610 void RenderFrameImpl::OnNavigate(
1610 const CommonNavigationParams& common_params, 1611 const CommonNavigationParams& common_params,
1611 const StartNavigationParams& start_params, 1612 const StartNavigationParams& start_params,
1612 const RequestNavigationParams& request_params) { 1613 const RequestNavigationParams& request_params) {
1613 // If this RenderFrame is going to replace a RenderFrameProxy, it is possible
1614 // that the proxy was detached before this navigation request was received.
1615 // In that case, abort the navigation. See https://crbug.com/526304 and
1616 // https://crbug.com/568676.
1617 // TODO(nasko, alexmos): Eventually, the browser process will send an IPC to
1618 // clean this frame up after https://crbug.com/548275 is fixed.
1619 if (proxy_routing_id_ != MSG_ROUTING_NONE) {
1620 RenderFrameProxy* proxy =
1621 RenderFrameProxy::FromRoutingID(proxy_routing_id_);
1622 if (!proxy)
1623 return;
1624 }
1625
1626 RenderThreadImpl* render_thread_impl = RenderThreadImpl::current(); 1614 RenderThreadImpl* render_thread_impl = RenderThreadImpl::current();
1627 // Can be NULL in tests. 1615 // Can be NULL in tests.
1628 if (render_thread_impl) 1616 if (render_thread_impl)
1629 render_thread_impl->GetRendererScheduler()->OnNavigationStarted(); 1617 render_thread_impl->GetRendererScheduler()->OnNavigationStarted();
1630 DCHECK(!IsBrowserSideNavigationEnabled()); 1618 DCHECK(!IsBrowserSideNavigationEnabled());
1631 TRACE_EVENT2("navigation,rail", "RenderFrameImpl::OnNavigate", "id", 1619 TRACE_EVENT2("navigation,rail", "RenderFrameImpl::OnNavigate", "id",
1632 routing_id_, "url", common_params.url.possibly_invalid_spec()); 1620 routing_id_, "url", common_params.url.possibly_invalid_spec());
1633 NavigateInternal(common_params, start_params, request_params, 1621 NavigateInternal(common_params, start_params, request_params,
1634 std::unique_ptr<StreamOverrideParameters>()); 1622 std::unique_ptr<StreamOverrideParameters>());
1635 } 1623 }
(...skipping 1495 matching lines...) Expand 10 before | Expand all | Expand 10 after
3131 type == DetachType::Remove) { 3119 type == DetachType::Remove) {
3132 frame->parent()->removeChild(frame); 3120 frame->parent()->removeChild(frame);
3133 } 3121 }
3134 3122
3135 // |frame| is invalid after here. Be sure to clear frame_ as well, since this 3123 // |frame| is invalid after here. Be sure to clear frame_ as well, since this
3136 // object may not be deleted immediately and other methods may try to access 3124 // object may not be deleted immediately and other methods may try to access
3137 // it. 3125 // it.
3138 frame->close(); 3126 frame->close();
3139 frame_ = nullptr; 3127 frame_ = nullptr;
3140 3128
3129 // If this was a provisional frame with an associated proxy, tell the proxy
3130 // that it's no longer associated with this frame.
3131 if (proxy_routing_id_ != MSG_ROUTING_NONE) {
3132 RenderFrameProxy* proxy =
3133 RenderFrameProxy::FromRoutingID(proxy_routing_id_);
3134
3135 // |proxy| should always exist. Detaching the proxy would've also detached
3136 // this provisional frame. The proxy should also not be associated with
3137 // another provisional frame at this point.
3138 CHECK(proxy);
3139 CHECK_EQ(proxy->provisional_frame_routing_id(), routing_id_);
Charlie Reis 2017/01/18 00:18:41 I'm ok with these checks-- I agree with the reason
alexmos 2017/01/23 22:20:59 Done.
3140
3141 proxy->set_provisional_frame_routing_id(MSG_ROUTING_NONE);
3142 }
3143
3141 delete this; 3144 delete this;
3142 // Object is invalid after this point. 3145 // Object is invalid after this point.
3143 } 3146 }
3144 3147
3145 void RenderFrameImpl::frameFocused() { 3148 void RenderFrameImpl::frameFocused() {
3146 Send(new FrameHostMsg_FrameFocused(routing_id_)); 3149 Send(new FrameHostMsg_FrameFocused(routing_id_));
3147 } 3150 }
3148 3151
3149 void RenderFrameImpl::willCommitProvisionalLoad(blink::WebLocalFrame* frame) { 3152 void RenderFrameImpl::willCommitProvisionalLoad(blink::WebLocalFrame* frame) {
3150 DCHECK_EQ(frame_, frame); 3153 DCHECK_EQ(frame_, frame);
(...skipping 1836 matching lines...) Expand 10 before | Expand all | Expand 10 after
4987 Send(new FrameHostMsg_DidCommitProvisionalLoad(routing_id_, params)); 4990 Send(new FrameHostMsg_DidCommitProvisionalLoad(routing_id_, params));
4988 4991
4989 // If we end up reusing this WebRequest (for example, due to a #ref click), 4992 // If we end up reusing this WebRequest (for example, due to a #ref click),
4990 // we don't want the transition type to persist. Just clear it. 4993 // we don't want the transition type to persist. Just clear it.
4991 navigation_state->set_transition_type(ui::PAGE_TRANSITION_LINK); 4994 navigation_state->set_transition_type(ui::PAGE_TRANSITION_LINK);
4992 } 4995 }
4993 4996
4994 bool RenderFrameImpl::SwapIn() { 4997 bool RenderFrameImpl::SwapIn() {
4995 CHECK_NE(proxy_routing_id_, MSG_ROUTING_NONE); 4998 CHECK_NE(proxy_routing_id_, MSG_ROUTING_NONE);
4996 CHECK(!in_frame_tree_); 4999 CHECK(!in_frame_tree_);
5000
5001 // The proxy should always exist. If it was detached while the provisional
5002 // LocalFrame was being navigated, the provisional frame would've been
5003 // cleaned up by RenderFrameProxy::frameDetached. See
5004 // https://crbug.com/526304 and https://crbug.com/568676 for context.
4997 RenderFrameProxy* proxy = RenderFrameProxy::FromRoutingID(proxy_routing_id_); 5005 RenderFrameProxy* proxy = RenderFrameProxy::FromRoutingID(proxy_routing_id_);
4998 5006 CHECK(proxy);
4999 // The proxy might have been detached while the provisional LocalFrame was
5000 // being navigated. In that case, don't swap the frame back in the tree
5001 // and return early (to avoid sending confusing IPCs to the browser
5002 // process). See https://crbug.com/526304 and https://crbug.com/568676.
5003 if (!proxy)
5004 return false;
5005 5007
5006 int proxy_routing_id = proxy_routing_id_; 5008 int proxy_routing_id = proxy_routing_id_;
5007 if (!proxy->web_frame()->swap(frame_)) 5009 if (!proxy->web_frame()->swap(frame_))
5008 return false; 5010 return false;
5009 5011
5010 proxy_routing_id_ = MSG_ROUTING_NONE; 5012 proxy_routing_id_ = MSG_ROUTING_NONE;
5011 in_frame_tree_ = true; 5013 in_frame_tree_ = true;
5012 5014
5013 // If this is the main frame going from a remote frame to a local frame, 5015 // If this is the main frame going from a remote frame to a local frame,
5014 // it needs to set RenderViewImpl's pointer for the main frame to itself 5016 // it needs to set RenderViewImpl's pointer for the main frame to itself
(...skipping 1775 matching lines...) Expand 10 before | Expand all | Expand 10 after
6790 // event target. Potentially a Pepper plugin will receive the event. 6792 // event target. Potentially a Pepper plugin will receive the event.
6791 // In order to tell whether a plugin gets the last mouse event and which it 6793 // In order to tell whether a plugin gets the last mouse event and which it
6792 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets 6794 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets
6793 // the event, it will notify us via DidReceiveMouseEvent() and set itself as 6795 // the event, it will notify us via DidReceiveMouseEvent() and set itself as
6794 // |pepper_last_mouse_event_target_|. 6796 // |pepper_last_mouse_event_target_|.
6795 pepper_last_mouse_event_target_ = nullptr; 6797 pepper_last_mouse_event_target_ = nullptr;
6796 #endif 6798 #endif
6797 } 6799 }
6798 6800
6799 } // namespace content 6801 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698