OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/browser/frame_host/render_frame_proxy_host.h" | 5 #include "content/browser/frame_host/render_frame_proxy_host.h" |
6 | 6 |
7 #include "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
| 8 #include "content/browser/bad_message.h" |
8 #include "content/browser/frame_host/cross_process_frame_connector.h" | 9 #include "content/browser/frame_host/cross_process_frame_connector.h" |
9 #include "content/browser/frame_host/frame_tree.h" | 10 #include "content/browser/frame_host/frame_tree.h" |
10 #include "content/browser/frame_host/frame_tree_node.h" | 11 #include "content/browser/frame_host/frame_tree_node.h" |
11 #include "content/browser/frame_host/render_frame_host_impl.h" | 12 #include "content/browser/frame_host/render_frame_host_impl.h" |
12 #include "content/browser/frame_host/render_widget_host_view_child_frame.h" | 13 #include "content/browser/frame_host/render_widget_host_view_child_frame.h" |
13 #include "content/browser/renderer_host/render_view_host_impl.h" | 14 #include "content/browser/renderer_host/render_view_host_impl.h" |
14 #include "content/browser/renderer_host/render_widget_host_view_base.h" | 15 #include "content/browser/renderer_host/render_widget_host_view_base.h" |
15 #include "content/browser/site_instance_impl.h" | 16 #include "content/browser/site_instance_impl.h" |
16 #include "content/common/frame_messages.h" | 17 #include "content/common/frame_messages.h" |
17 #include "content/public/browser/browser_thread.h" | 18 #include "content/public/browser/browser_thread.h" |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 return GetProcess()->Send(msg); | 110 return GetProcess()->Send(msg); |
110 } | 111 } |
111 | 112 |
112 bool RenderFrameProxyHost::OnMessageReceived(const IPC::Message& msg) { | 113 bool RenderFrameProxyHost::OnMessageReceived(const IPC::Message& msg) { |
113 if (cross_process_frame_connector_.get() && | 114 if (cross_process_frame_connector_.get() && |
114 cross_process_frame_connector_->OnMessageReceived(msg)) | 115 cross_process_frame_connector_->OnMessageReceived(msg)) |
115 return true; | 116 return true; |
116 | 117 |
117 bool handled = true; | 118 bool handled = true; |
118 IPC_BEGIN_MESSAGE_MAP(RenderFrameProxyHost, msg) | 119 IPC_BEGIN_MESSAGE_MAP(RenderFrameProxyHost, msg) |
| 120 IPC_MESSAGE_HANDLER(FrameHostMsg_Detach, OnDetach) |
119 IPC_MESSAGE_HANDLER(FrameHostMsg_OpenURL, OnOpenURL) | 121 IPC_MESSAGE_HANDLER(FrameHostMsg_OpenURL, OnOpenURL) |
120 IPC_MESSAGE_UNHANDLED(handled = false) | 122 IPC_MESSAGE_UNHANDLED(handled = false) |
121 IPC_END_MESSAGE_MAP() | 123 IPC_END_MESSAGE_MAP() |
122 return handled; | 124 return handled; |
123 } | 125 } |
124 | 126 |
125 bool RenderFrameProxyHost::InitRenderFrameProxy() { | 127 bool RenderFrameProxyHost::InitRenderFrameProxy() { |
126 DCHECK(!render_frame_proxy_created_); | 128 DCHECK(!render_frame_proxy_created_); |
127 // The process may (if we're sharing a process with another host that already | 129 // The process may (if we're sharing a process with another host that already |
128 // initialized it) or may not (we have our own process or the old process | 130 // initialized it) or may not (we have our own process or the old process |
(...skipping 21 matching lines...) Expand all Loading... |
150 ->current_replication_state())); | 152 ->current_replication_state())); |
151 | 153 |
152 render_frame_proxy_created_ = true; | 154 render_frame_proxy_created_ = true; |
153 return true; | 155 return true; |
154 } | 156 } |
155 | 157 |
156 void RenderFrameProxyHost::DisownOpener() { | 158 void RenderFrameProxyHost::DisownOpener() { |
157 Send(new FrameMsg_DisownOpener(GetRoutingID())); | 159 Send(new FrameMsg_DisownOpener(GetRoutingID())); |
158 } | 160 } |
159 | 161 |
| 162 void RenderFrameProxyHost::OnDetach() { |
| 163 // This message should only be received for subframes. Note that we can't |
| 164 // restrict it to just the current SiteInstances of the ancestors of this |
| 165 // frame, because another frame in the tree may be able to detach this frame |
| 166 // by navigating its parent. |
| 167 if (frame_tree_node_->IsMainFrame()) { |
| 168 bad_message::ReceivedBadMessage(GetProcess(), bad_message::RFPH_DETACH); |
| 169 return; |
| 170 } |
| 171 frame_tree_node_->frame_tree()->RemoveFrame(frame_tree_node_); |
| 172 } |
| 173 |
160 void RenderFrameProxyHost::OnOpenURL( | 174 void RenderFrameProxyHost::OnOpenURL( |
161 const FrameHostMsg_OpenURL_Params& params) { | 175 const FrameHostMsg_OpenURL_Params& params) { |
| 176 // TODO(creis): Verify that we are in the same BrowsingInstance as the current |
| 177 // RenderFrameHost. See NavigatorImpl::RequestOpenURL. |
162 frame_tree_node_->current_frame_host()->OpenURL(params, site_instance_.get()); | 178 frame_tree_node_->current_frame_host()->OpenURL(params, site_instance_.get()); |
163 } | 179 } |
164 | 180 |
165 } // namespace content | 181 } // namespace content |
OLD | NEW |