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 934 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
945 | 945 |
946 #if defined(OS_MACOSX) || defined(OS_ANDROID) | 946 #if defined(OS_MACOSX) || defined(OS_ANDROID) |
947 void RenderFrameImpl::DidHideExternalPopupMenu() { | 947 void RenderFrameImpl::DidHideExternalPopupMenu() { |
948 // We need to clear external_popup_menu_ as soon as ExternalPopupMenu::close | 948 // We need to clear external_popup_menu_ as soon as ExternalPopupMenu::close |
949 // is called. Otherwise, createExternalPopupMenu() for new popup will fail. | 949 // is called. Otherwise, createExternalPopupMenu() for new popup will fail. |
950 external_popup_menu_.reset(); | 950 external_popup_menu_.reset(); |
951 } | 951 } |
952 #endif | 952 #endif |
953 | 953 |
954 bool RenderFrameImpl::OnMessageReceived(const IPC::Message& msg) { | 954 bool RenderFrameImpl::OnMessageReceived(const IPC::Message& msg) { |
955 // We may get here while detaching, when the WebFrame has been deleted. Do | |
956 // not process any messages in this state. | |
957 if (!frame_) | |
958 return false; | |
959 | |
955 // TODO(kenrb): document() should not be null, but as a transitional step | 960 // TODO(kenrb): document() should not be null, but as a transitional step |
956 // we have RenderFrameProxy 'wrapping' a RenderFrameImpl, passing messages | 961 // we have RenderFrameProxy 'wrapping' a RenderFrameImpl, passing messages |
957 // to this method. This happens for a top-level remote frame, where a | 962 // to this method. This happens for a top-level remote frame, where a |
958 // document-less RenderFrame is replaced by a RenderFrameProxy but kept | 963 // document-less RenderFrame is replaced by a RenderFrameProxy but kept |
959 // around and is still able to receive messages. | 964 // around and is still able to receive messages. |
960 if (!frame_->document().isNull()) | 965 if (!frame_->document().isNull()) |
961 GetContentClient()->SetActiveURL(frame_->document().url()); | 966 GetContentClient()->SetActiveURL(frame_->document().url()); |
962 | 967 |
963 ObserverListBase<RenderFrameObserver>::Iterator it(&observers_); | 968 ObserverListBase<RenderFrameObserver>::Iterator it(&observers_); |
964 RenderFrameObserver* observer; | 969 RenderFrameObserver* observer; |
(...skipping 1132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2097 // containing RenderViewHost (so that they have the same lifetime), so only | 2102 // containing RenderViewHost (so that they have the same lifetime), so only |
2098 // removal from the map is needed and no deletion. | 2103 // removal from the map is needed and no deletion. |
2099 FrameMap::iterator it = g_frame_map.Get().find(frame); | 2104 FrameMap::iterator it = g_frame_map.Get().find(frame); |
2100 CHECK(it != g_frame_map.Get().end()); | 2105 CHECK(it != g_frame_map.Get().end()); |
2101 CHECK_EQ(it->second, this); | 2106 CHECK_EQ(it->second, this); |
2102 g_frame_map.Get().erase(it); | 2107 g_frame_map.Get().erase(it); |
2103 | 2108 |
2104 if (is_subframe) | 2109 if (is_subframe) |
2105 frame->parent()->removeChild(frame); | 2110 frame->parent()->removeChild(frame); |
2106 | 2111 |
2107 // |frame| is invalid after here. | 2112 // |frame| is invalid after here. Be sure to clear frame_ as well, since this |
2113 // object may not be deleted immediately and other methods may try to access | |
2114 // it. | |
2108 frame->close(); | 2115 frame->close(); |
2116 frame_ = nullptr; | |
2109 | 2117 |
2110 if (is_subframe) { | 2118 if (is_subframe) { |
2111 delete this; | 2119 delete this; |
nasko
2015/03/16 17:12:17
Based on this, isn't it the case that frame_ is in
Charlie Reis
2015/03/16 17:21:18
Yes, it's only for the main frame. Comment update
| |
2112 // Object is invalid after this point. | 2120 // Object is invalid after this point. |
2113 } | 2121 } |
2114 } | 2122 } |
2115 | 2123 |
2116 void RenderFrameImpl::frameFocused() { | 2124 void RenderFrameImpl::frameFocused() { |
2117 Send(new FrameHostMsg_FrameFocused(routing_id_)); | 2125 Send(new FrameHostMsg_FrameFocused(routing_id_)); |
2118 } | 2126 } |
2119 | 2127 |
2120 void RenderFrameImpl::willClose(blink::WebFrame* frame) { | 2128 void RenderFrameImpl::willClose(blink::WebFrame* frame) { |
2121 DCHECK(!frame_ || frame_ == frame); | 2129 DCHECK(!frame_ || frame_ == frame); |
(...skipping 2401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4523 | 4531 |
4524 #if defined(ENABLE_BROWSER_CDMS) | 4532 #if defined(ENABLE_BROWSER_CDMS) |
4525 RendererCdmManager* RenderFrameImpl::GetCdmManager() { | 4533 RendererCdmManager* RenderFrameImpl::GetCdmManager() { |
4526 if (!cdm_manager_) | 4534 if (!cdm_manager_) |
4527 cdm_manager_ = new RendererCdmManager(this); | 4535 cdm_manager_ = new RendererCdmManager(this); |
4528 return cdm_manager_; | 4536 return cdm_manager_; |
4529 } | 4537 } |
4530 #endif // defined(ENABLE_BROWSER_CDMS) | 4538 #endif // defined(ENABLE_BROWSER_CDMS) |
4531 | 4539 |
4532 } // namespace content | 4540 } // namespace content |
OLD | NEW |