| 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 #include <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 1045 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1056 } | 1056 } |
| 1057 | 1057 |
| 1058 // RenderFrameImpl ---------------------------------------------------------- | 1058 // RenderFrameImpl ---------------------------------------------------------- |
| 1059 RenderFrameImpl::RenderFrameImpl(const CreateParams& params) | 1059 RenderFrameImpl::RenderFrameImpl(const CreateParams& params) |
| 1060 : frame_(NULL), | 1060 : frame_(NULL), |
| 1061 is_main_frame_(true), | 1061 is_main_frame_(true), |
| 1062 in_browser_initiated_detach_(false), | 1062 in_browser_initiated_detach_(false), |
| 1063 in_frame_tree_(false), | 1063 in_frame_tree_(false), |
| 1064 render_view_(params.render_view->AsWeakPtr()), | 1064 render_view_(params.render_view->AsWeakPtr()), |
| 1065 routing_id_(params.routing_id), | 1065 routing_id_(params.routing_id), |
| 1066 is_detaching_(false), | |
| 1067 proxy_routing_id_(MSG_ROUTING_NONE), | 1066 proxy_routing_id_(MSG_ROUTING_NONE), |
| 1068 #if defined(ENABLE_PLUGINS) | 1067 #if defined(ENABLE_PLUGINS) |
| 1069 plugin_power_saver_helper_(nullptr), | 1068 plugin_power_saver_helper_(nullptr), |
| 1070 plugin_find_handler_(nullptr), | 1069 plugin_find_handler_(nullptr), |
| 1071 #endif | 1070 #endif |
| 1072 cookie_jar_(this), | 1071 cookie_jar_(this), |
| 1073 selection_text_offset_(0), | 1072 selection_text_offset_(0), |
| 1074 selection_range_(gfx::Range::InvalidRange()), | 1073 selection_range_(gfx::Range::InvalidRange()), |
| 1075 handling_select_range_(false), | 1074 handling_select_range_(false), |
| 1076 notification_permission_dispatcher_(NULL), | 1075 notification_permission_dispatcher_(NULL), |
| (...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1421 #endif // defined(ENABLE_PLUGINS) | 1420 #endif // defined(ENABLE_PLUGINS) |
| 1422 | 1421 |
| 1423 MediaStreamDispatcher* RenderFrameImpl::GetMediaStreamDispatcher() { | 1422 MediaStreamDispatcher* RenderFrameImpl::GetMediaStreamDispatcher() { |
| 1424 if (!web_user_media_client_) | 1423 if (!web_user_media_client_) |
| 1425 InitializeUserMediaClient(); | 1424 InitializeUserMediaClient(); |
| 1426 return web_user_media_client_ ? | 1425 return web_user_media_client_ ? |
| 1427 web_user_media_client_->media_stream_dispatcher() : NULL; | 1426 web_user_media_client_->media_stream_dispatcher() : NULL; |
| 1428 } | 1427 } |
| 1429 | 1428 |
| 1430 bool RenderFrameImpl::Send(IPC::Message* message) { | 1429 bool RenderFrameImpl::Send(IPC::Message* message) { |
| 1431 if (is_detaching_) { | |
| 1432 delete message; | |
| 1433 return false; | |
| 1434 } | |
| 1435 | |
| 1436 return RenderThread::Get()->Send(message); | 1430 return RenderThread::Get()->Send(message); |
| 1437 } | 1431 } |
| 1438 | 1432 |
| 1439 #if defined(USE_EXTERNAL_POPUP_MENU) | 1433 #if defined(USE_EXTERNAL_POPUP_MENU) |
| 1440 void RenderFrameImpl::DidHideExternalPopupMenu() { | 1434 void RenderFrameImpl::DidHideExternalPopupMenu() { |
| 1441 // We need to clear external_popup_menu_ as soon as ExternalPopupMenu::close | 1435 // We need to clear external_popup_menu_ as soon as ExternalPopupMenu::close |
| 1442 // is called. Otherwise, createExternalPopupMenu() for new popup will fail. | 1436 // is called. Otherwise, createExternalPopupMenu() for new popup will fail. |
| 1443 external_popup_menu_.reset(); | 1437 external_popup_menu_.reset(); |
| 1444 } | 1438 } |
| 1445 #endif | 1439 #endif |
| (...skipping 1365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2811 int opener_routing_id = opener ? | 2805 int opener_routing_id = opener ? |
| 2812 RenderFrameImpl::FromWebFrame(opener->toWebLocalFrame())->GetRoutingID() : | 2806 RenderFrameImpl::FromWebFrame(opener->toWebLocalFrame())->GetRoutingID() : |
| 2813 MSG_ROUTING_NONE; | 2807 MSG_ROUTING_NONE; |
| 2814 Send(new FrameHostMsg_DidChangeOpener(routing_id_, opener_routing_id)); | 2808 Send(new FrameHostMsg_DidChangeOpener(routing_id_, opener_routing_id)); |
| 2815 } | 2809 } |
| 2816 | 2810 |
| 2817 void RenderFrameImpl::frameDetached(blink::WebFrame* frame, DetachType type) { | 2811 void RenderFrameImpl::frameDetached(blink::WebFrame* frame, DetachType type) { |
| 2818 // NOTE: This function is called on the frame that is being detached and not | 2812 // NOTE: This function is called on the frame that is being detached and not |
| 2819 // the parent frame. This is different from createChildFrame() which is | 2813 // the parent frame. This is different from createChildFrame() which is |
| 2820 // called on the parent frame. | 2814 // called on the parent frame. |
| 2821 CHECK(!is_detaching_); | |
| 2822 DCHECK_EQ(frame_, frame); | 2815 DCHECK_EQ(frame_, frame); |
| 2823 | 2816 |
| 2824 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, FrameDetached()); | 2817 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, FrameDetached()); |
| 2825 FOR_EACH_OBSERVER(RenderViewObserver, render_view_->observers(), | 2818 FOR_EACH_OBSERVER(RenderViewObserver, render_view_->observers(), |
| 2826 FrameDetached(frame)); | 2819 FrameDetached(frame)); |
| 2827 | 2820 |
| 2828 // We only notify the browser process when the frame is being detached for | 2821 // We only notify the browser process when the frame is being detached for |
| 2829 // removal and it was initiated from the renderer process. | 2822 // removal and it was initiated from the renderer process. |
| 2830 if (!in_browser_initiated_detach_ && type == DetachType::Remove) | 2823 if (!in_browser_initiated_detach_ && type == DetachType::Remove) |
| 2831 Send(new FrameHostMsg_Detach(routing_id_)); | 2824 Send(new FrameHostMsg_Detach(routing_id_)); |
| 2832 | 2825 |
| 2833 // The |is_detaching_| flag disables Send(). FrameHostMsg_Detach must be | |
| 2834 // sent before setting |is_detaching_| to true. | |
| 2835 is_detaching_ = true; | |
| 2836 | |
| 2837 // Clean up the associated RenderWidget for the frame, if there is one. | 2826 // Clean up the associated RenderWidget for the frame, if there is one. |
| 2838 if (render_widget_) { | 2827 if (render_widget_) { |
| 2839 render_widget_->UnregisterRenderFrame(this); | 2828 render_widget_->UnregisterRenderFrame(this); |
| 2840 render_widget_->CloseForFrame(); | 2829 render_widget_->CloseForFrame(); |
| 2841 } | 2830 } |
| 2842 | 2831 |
| 2843 // We need to clean up subframes by removing them from the map and deleting | 2832 // We need to clean up subframes by removing them from the map and deleting |
| 2844 // the RenderFrameImpl. In contrast, the main frame is owned by its | 2833 // the RenderFrameImpl. In contrast, the main frame is owned by its |
| 2845 // containing RenderViewHost (so that they have the same lifetime), so only | 2834 // containing RenderViewHost (so that they have the same lifetime), so only |
| 2846 // removal from the map is needed and no deletion. | 2835 // removal from the map is needed and no deletion. |
| (...skipping 3408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6255 // event target. Potentially a Pepper plugin will receive the event. | 6244 // event target. Potentially a Pepper plugin will receive the event. |
| 6256 // In order to tell whether a plugin gets the last mouse event and which it | 6245 // In order to tell whether a plugin gets the last mouse event and which it |
| 6257 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets | 6246 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets |
| 6258 // the event, it will notify us via DidReceiveMouseEvent() and set itself as | 6247 // the event, it will notify us via DidReceiveMouseEvent() and set itself as |
| 6259 // |pepper_last_mouse_event_target_|. | 6248 // |pepper_last_mouse_event_target_|. |
| 6260 pepper_last_mouse_event_target_ = nullptr; | 6249 pepper_last_mouse_event_target_ = nullptr; |
| 6261 #endif | 6250 #endif |
| 6262 } | 6251 } |
| 6263 | 6252 |
| 6264 } // namespace content | 6253 } // namespace content |
| OLD | NEW |