OLD | NEW |
---|---|
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 712 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
723 | 723 |
724 RenderFrameImpl::~RenderFrameImpl() { | 724 RenderFrameImpl::~RenderFrameImpl() { |
725 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, RenderFrameGone()); | 725 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, RenderFrameGone()); |
726 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, OnDestruct()); | 726 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, OnDestruct()); |
727 | 727 |
728 #if defined(VIDEO_HOLE) | 728 #if defined(VIDEO_HOLE) |
729 if (contains_media_player_) | 729 if (contains_media_player_) |
730 render_view_->UnregisterVideoHoleFrame(this); | 730 render_view_->UnregisterVideoHoleFrame(this); |
731 #endif | 731 #endif |
732 | 732 |
733 // RenderFrameProxy is only "owned" by RenderFrameImpl in the case it is the | 733 if (!is_subframe_) { |
734 // main frame. Ensure it is deleted along with this object. | 734 // RenderFrameProxy is "owned" by RenderFrameImpl in the case it is |
735 if (!is_subframe_ && render_frame_proxy_) { | 735 // the main frame. Ensure it is deleted along with this object. |
736 // The following method calls back into this object and clears | 736 if (render_frame_proxy_) { |
737 // |render_frame_proxy_|. | 737 // The following method calls back into this object and clears |
738 render_frame_proxy_->frameDetached(); | 738 // |render_frame_proxy_|. |
739 render_frame_proxy_->frameDetached(); | |
740 } | |
741 | |
742 // Since this is the main frame, the RenderViewImpl pointer to this object | |
743 // must be cleared, otherwise it will result in use-after-free bugs. | |
744 render_view_->main_render_frame_ = nullptr; | |
739 } | 745 } |
740 | 746 |
741 render_view_->UnregisterRenderFrame(this); | 747 render_view_->UnregisterRenderFrame(this); |
742 g_routing_id_frame_map.Get().erase(routing_id_); | 748 g_routing_id_frame_map.Get().erase(routing_id_); |
743 RenderThread::Get()->RemoveRoute(routing_id_); | 749 RenderThread::Get()->RemoveRoute(routing_id_); |
744 } | 750 } |
745 | 751 |
746 void RenderFrameImpl::SetWebFrame(blink::WebLocalFrame* web_frame) { | 752 void RenderFrameImpl::SetWebFrame(blink::WebLocalFrame* web_frame) { |
747 DCHECK(!frame_); | 753 DCHECK(!frame_); |
748 | 754 |
(...skipping 1475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2224 } | 2230 } |
2225 frame->parent()->removeChild(frame); | 2231 frame->parent()->removeChild(frame); |
2226 } | 2232 } |
2227 | 2233 |
2228 // |frame| is invalid after here. Be sure to clear frame_ as well, since this | 2234 // |frame| is invalid after here. Be sure to clear frame_ as well, since this |
2229 // object may not be deleted immediately and other methods may try to access | 2235 // object may not be deleted immediately and other methods may try to access |
2230 // it. | 2236 // it. |
2231 frame->close(); | 2237 frame->close(); |
2232 frame_ = nullptr; | 2238 frame_ = nullptr; |
2233 | 2239 |
2234 if (is_subframe_) { | 2240 delete this; |
2235 delete this; | 2241 // Object is invalid after this point. |
2236 // Object is invalid after this point. | |
2237 } | |
2238 } | 2242 } |
2239 | 2243 |
2240 void RenderFrameImpl::frameFocused() { | 2244 void RenderFrameImpl::frameFocused() { |
2241 Send(new FrameHostMsg_FrameFocused(routing_id_)); | 2245 Send(new FrameHostMsg_FrameFocused(routing_id_)); |
2242 } | 2246 } |
2243 | 2247 |
2244 void RenderFrameImpl::willClose(blink::WebFrame* frame) { | 2248 void RenderFrameImpl::willClose(blink::WebFrame* frame) { |
2245 DCHECK(!frame_ || frame_ == frame); | 2249 DCHECK(!frame_ || frame_ == frame); |
2246 | 2250 |
2247 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, FrameWillClose()); | 2251 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, FrameWillClose()); |
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2636 DocumentState::FromDataSource(frame->dataSource()); | 2640 DocumentState::FromDataSource(frame->dataSource()); |
2637 NavigationStateImpl* navigation_state = | 2641 NavigationStateImpl* navigation_state = |
2638 static_cast<NavigationStateImpl*>(document_state->navigation_state()); | 2642 static_cast<NavigationStateImpl*>(document_state->navigation_state()); |
2639 | 2643 |
2640 if (proxy_routing_id_ != MSG_ROUTING_NONE) { | 2644 if (proxy_routing_id_ != MSG_ROUTING_NONE) { |
2641 RenderFrameProxy* proxy = | 2645 RenderFrameProxy* proxy = |
2642 RenderFrameProxy::FromRoutingID(proxy_routing_id_); | 2646 RenderFrameProxy::FromRoutingID(proxy_routing_id_); |
2643 CHECK(proxy); | 2647 CHECK(proxy); |
2644 proxy->web_frame()->swap(frame_); | 2648 proxy->web_frame()->swap(frame_); |
2645 proxy_routing_id_ = MSG_ROUTING_NONE; | 2649 proxy_routing_id_ = MSG_ROUTING_NONE; |
2650 | |
2651 // If this is the main frame going from a remote frame to a local frame, | |
2652 // it needs to set RenderViewImpl's pointer for the main frame to itself. | |
2653 if (!is_subframe_) | |
2654 render_view_->main_render_frame_ = this; | |
lfg
2015/05/08 19:42:27
Consider adding a CHECK or DCHECK that there's no
nasko
2015/05/11 16:12:33
Done.
| |
2646 } | 2655 } |
2647 | 2656 |
2648 // When we perform a new navigation, we need to update the last committed | 2657 // When we perform a new navigation, we need to update the last committed |
2649 // session history entry with state for the page we are leaving. Do this | 2658 // session history entry with state for the page we are leaving. Do this |
2650 // before updating the HistoryController state. | 2659 // before updating the HistoryController state. |
2651 render_view_->UpdateSessionHistory(frame); | 2660 render_view_->UpdateSessionHistory(frame); |
2652 | 2661 |
2653 render_view_->history_controller()->UpdateForCommit( | 2662 render_view_->history_controller()->UpdateForCommit( |
2654 this, item, commit_type, navigation_state->WasWithinSamePage()); | 2663 this, item, commit_type, navigation_state->WasWithinSamePage()); |
2655 | 2664 |
(...skipping 2278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4934 #elif defined(ENABLE_BROWSER_CDMS) | 4943 #elif defined(ENABLE_BROWSER_CDMS) |
4935 cdm_manager_, | 4944 cdm_manager_, |
4936 #endif | 4945 #endif |
4937 this); | 4946 this); |
4938 } | 4947 } |
4939 | 4948 |
4940 return cdm_factory_; | 4949 return cdm_factory_; |
4941 } | 4950 } |
4942 | 4951 |
4943 } // namespace content | 4952 } // namespace content |
OLD | NEW |