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 924 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
935 | 935 |
936 #if defined(OS_MACOSX) || defined(OS_ANDROID) | 936 #if defined(OS_MACOSX) || defined(OS_ANDROID) |
937 void RenderFrameImpl::DidHideExternalPopupMenu() { | 937 void RenderFrameImpl::DidHideExternalPopupMenu() { |
938 // We need to clear external_popup_menu_ as soon as ExternalPopupMenu::close | 938 // We need to clear external_popup_menu_ as soon as ExternalPopupMenu::close |
939 // is called. Otherwise, createExternalPopupMenu() for new popup will fail. | 939 // is called. Otherwise, createExternalPopupMenu() for new popup will fail. |
940 external_popup_menu_.reset(); | 940 external_popup_menu_.reset(); |
941 } | 941 } |
942 #endif | 942 #endif |
943 | 943 |
944 bool RenderFrameImpl::OnMessageReceived(const IPC::Message& msg) { | 944 bool RenderFrameImpl::OnMessageReceived(const IPC::Message& msg) { |
| 945 // We may get here while detaching, when the WebFrame has been deleted. Do |
| 946 // not process any messages in this state. |
| 947 if (!frame_) |
| 948 return false; |
| 949 |
945 // TODO(kenrb): document() should not be null, but as a transitional step | 950 // TODO(kenrb): document() should not be null, but as a transitional step |
946 // we have RenderFrameProxy 'wrapping' a RenderFrameImpl, passing messages | 951 // we have RenderFrameProxy 'wrapping' a RenderFrameImpl, passing messages |
947 // to this method. This happens for a top-level remote frame, where a | 952 // to this method. This happens for a top-level remote frame, where a |
948 // document-less RenderFrame is replaced by a RenderFrameProxy but kept | 953 // document-less RenderFrame is replaced by a RenderFrameProxy but kept |
949 // around and is still able to receive messages. | 954 // around and is still able to receive messages. |
950 if (!frame_->document().isNull()) | 955 if (!frame_->document().isNull()) |
951 GetContentClient()->SetActiveURL(frame_->document().url()); | 956 GetContentClient()->SetActiveURL(frame_->document().url()); |
952 | 957 |
953 ObserverListBase<RenderFrameObserver>::Iterator it(observers_); | 958 ObserverListBase<RenderFrameObserver>::Iterator it(observers_); |
954 RenderFrameObserver* observer; | 959 RenderFrameObserver* observer; |
(...skipping 1142 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; |
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 } |
(...skipping 2323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4442 | 4450 |
4443 #if defined(ENABLE_BROWSER_CDMS) | 4451 #if defined(ENABLE_BROWSER_CDMS) |
4444 RendererCdmManager* RenderFrameImpl::GetCdmManager() { | 4452 RendererCdmManager* RenderFrameImpl::GetCdmManager() { |
4445 if (!cdm_manager_) | 4453 if (!cdm_manager_) |
4446 cdm_manager_ = new RendererCdmManager(this); | 4454 cdm_manager_ = new RendererCdmManager(this); |
4447 return cdm_manager_; | 4455 return cdm_manager_; |
4448 } | 4456 } |
4449 #endif // defined(ENABLE_BROWSER_CDMS) | 4457 #endif // defined(ENABLE_BROWSER_CDMS) |
4450 | 4458 |
4451 } // namespace content | 4459 } // namespace content |
OLD | NEW |