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 887 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
898 | 898 |
899 #if defined(OS_MACOSX) || defined(OS_ANDROID) | 899 #if defined(OS_MACOSX) || defined(OS_ANDROID) |
900 void RenderFrameImpl::DidHideExternalPopupMenu() { | 900 void RenderFrameImpl::DidHideExternalPopupMenu() { |
901 // We need to clear external_popup_menu_ as soon as ExternalPopupMenu::close | 901 // We need to clear external_popup_menu_ as soon as ExternalPopupMenu::close |
902 // is called. Otherwise, createExternalPopupMenu() for new popup will fail. | 902 // is called. Otherwise, createExternalPopupMenu() for new popup will fail. |
903 external_popup_menu_.reset(); | 903 external_popup_menu_.reset(); |
904 } | 904 } |
905 #endif | 905 #endif |
906 | 906 |
907 bool RenderFrameImpl::OnMessageReceived(const IPC::Message& msg) { | 907 bool RenderFrameImpl::OnMessageReceived(const IPC::Message& msg) { |
| 908 // We may get here while detaching, when the WebFrame has been deleted. Do |
| 909 // not process any messages in this state. |
| 910 if (!frame_) |
| 911 return false; |
| 912 |
908 // TODO(kenrb): document() should not be null, but as a transitional step | 913 // TODO(kenrb): document() should not be null, but as a transitional step |
909 // we have RenderFrameProxy 'wrapping' a RenderFrameImpl, passing messages | 914 // we have RenderFrameProxy 'wrapping' a RenderFrameImpl, passing messages |
910 // to this method. This happens for a top-level remote frame, where a | 915 // to this method. This happens for a top-level remote frame, where a |
911 // document-less RenderFrame is replaced by a RenderFrameProxy but kept | 916 // document-less RenderFrame is replaced by a RenderFrameProxy but kept |
912 // around and is still able to receive messages. | 917 // around and is still able to receive messages. |
913 if (!frame_->document().isNull()) | 918 if (!frame_->document().isNull()) |
914 GetContentClient()->SetActiveURL(frame_->document().url()); | 919 GetContentClient()->SetActiveURL(frame_->document().url()); |
915 | 920 |
916 ObserverListBase<RenderFrameObserver>::Iterator it(observers_); | 921 ObserverListBase<RenderFrameObserver>::Iterator it(observers_); |
917 RenderFrameObserver* observer; | 922 RenderFrameObserver* observer; |
(...skipping 1123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2041 // containing RenderViewHost (so that they have the same lifetime), so only | 2046 // containing RenderViewHost (so that they have the same lifetime), so only |
2042 // removal from the map is needed and no deletion. | 2047 // removal from the map is needed and no deletion. |
2043 FrameMap::iterator it = g_frame_map.Get().find(frame); | 2048 FrameMap::iterator it = g_frame_map.Get().find(frame); |
2044 CHECK(it != g_frame_map.Get().end()); | 2049 CHECK(it != g_frame_map.Get().end()); |
2045 CHECK_EQ(it->second, this); | 2050 CHECK_EQ(it->second, this); |
2046 g_frame_map.Get().erase(it); | 2051 g_frame_map.Get().erase(it); |
2047 | 2052 |
2048 if (is_subframe) | 2053 if (is_subframe) |
2049 frame->parent()->removeChild(frame); | 2054 frame->parent()->removeChild(frame); |
2050 | 2055 |
2051 // |frame| is invalid after here. | 2056 // |frame| is invalid after here. Be sure to clear frame_ as well, since this |
| 2057 // object may not be deleted immediately and other methods may try to access |
| 2058 // it. |
2052 frame->close(); | 2059 frame->close(); |
| 2060 frame_ = nullptr; |
2053 | 2061 |
2054 if (is_subframe) { | 2062 if (is_subframe) { |
2055 delete this; | 2063 delete this; |
2056 // Object is invalid after this point. | 2064 // Object is invalid after this point. |
2057 } | 2065 } |
2058 } | 2066 } |
2059 | 2067 |
2060 void RenderFrameImpl::frameFocused() { | 2068 void RenderFrameImpl::frameFocused() { |
2061 Send(new FrameHostMsg_FrameFocused(routing_id_)); | 2069 Send(new FrameHostMsg_FrameFocused(routing_id_)); |
2062 } | 2070 } |
(...skipping 2295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4358 | 4366 |
4359 #if defined(ENABLE_BROWSER_CDMS) | 4367 #if defined(ENABLE_BROWSER_CDMS) |
4360 RendererCdmManager* RenderFrameImpl::GetCdmManager() { | 4368 RendererCdmManager* RenderFrameImpl::GetCdmManager() { |
4361 if (!cdm_manager_) | 4369 if (!cdm_manager_) |
4362 cdm_manager_ = new RendererCdmManager(this); | 4370 cdm_manager_ = new RendererCdmManager(this); |
4363 return cdm_manager_; | 4371 return cdm_manager_; |
4364 } | 4372 } |
4365 #endif // defined(ENABLE_BROWSER_CDMS) | 4373 #endif // defined(ENABLE_BROWSER_CDMS) |
4366 | 4374 |
4367 } // namespace content | 4375 } // namespace content |
OLD | NEW |