OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // Represents the browser side of the browser <--> renderer communication | 5 // Represents the browser side of the browser <--> renderer communication |
6 // channel. There will be one RenderProcessHost per renderer process. | 6 // channel. There will be one RenderProcessHost per renderer process. |
7 | 7 |
8 #include "content/browser/renderer_host/render_process_host_impl.h" | 8 #include "content/browser/renderer_host/render_process_host_impl.h" |
9 | 9 |
10 #if defined(OS_WIN) | 10 #if defined(OS_WIN) |
(...skipping 866 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
877 IPC_MESSAGE_HANDLER(ChildProcessHostMsg_ShutdownRequest, | 877 IPC_MESSAGE_HANDLER(ChildProcessHostMsg_ShutdownRequest, |
878 OnShutdownRequest) | 878 OnShutdownRequest) |
879 IPC_MESSAGE_HANDLER(ChildProcessHostMsg_DumpHandlesDone, | 879 IPC_MESSAGE_HANDLER(ChildProcessHostMsg_DumpHandlesDone, |
880 OnDumpHandlesDone) | 880 OnDumpHandlesDone) |
881 IPC_MESSAGE_HANDLER(ViewHostMsg_SuddenTerminationChanged, | 881 IPC_MESSAGE_HANDLER(ViewHostMsg_SuddenTerminationChanged, |
882 SuddenTerminationChanged) | 882 SuddenTerminationChanged) |
883 IPC_MESSAGE_HANDLER(ViewHostMsg_UserMetricsRecordAction, | 883 IPC_MESSAGE_HANDLER(ViewHostMsg_UserMetricsRecordAction, |
884 OnUserMetricsRecordAction) | 884 OnUserMetricsRecordAction) |
885 IPC_MESSAGE_HANDLER(ViewHostMsg_RevealFolderInOS, OnRevealFolderInOS) | 885 IPC_MESSAGE_HANDLER(ViewHostMsg_RevealFolderInOS, OnRevealFolderInOS) |
886 IPC_MESSAGE_HANDLER(ViewHostMsg_SavedPageAsMHTML, OnSavedPageAsMHTML) | 886 IPC_MESSAGE_HANDLER(ViewHostMsg_SavedPageAsMHTML, OnSavedPageAsMHTML) |
| 887 IPC_MESSAGE_HANDLER(ViewHostMsg_SendPostMessage, OnSendPostMessage) |
887 IPC_MESSAGE_UNHANDLED_ERROR() | 888 IPC_MESSAGE_UNHANDLED_ERROR() |
888 IPC_END_MESSAGE_MAP_EX() | 889 IPC_END_MESSAGE_MAP_EX() |
889 | 890 |
890 if (!msg_is_ok) { | 891 if (!msg_is_ok) { |
891 // The message had a handler, but its de-serialization failed. | 892 // The message had a handler, but its de-serialization failed. |
892 // We consider this a capital crime. Kill the renderer if we have one. | 893 // We consider this a capital crime. Kill the renderer if we have one. |
893 LOG(ERROR) << "bad message " << msg.type() << " terminating renderer."; | 894 LOG(ERROR) << "bad message " << msg.type() << " terminating renderer."; |
894 content::RecordAction(UserMetricsAction("BadMessageTerminate_BRPH")); | 895 content::RecordAction(UserMetricsAction("BadMessageTerminate_BRPH")); |
895 ReceivedBadMessage(); | 896 ReceivedBadMessage(); |
896 } | 897 } |
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1303 void RenderProcessHostImpl::OnRevealFolderInOS(const FilePath& path) { | 1304 void RenderProcessHostImpl::OnRevealFolderInOS(const FilePath& path) { |
1304 // Only honor the request if appropriate persmissions are granted. | 1305 // Only honor the request if appropriate persmissions are granted. |
1305 if (ChildProcessSecurityPolicy::GetInstance()->CanReadFile(GetID(), path)) | 1306 if (ChildProcessSecurityPolicy::GetInstance()->CanReadFile(GetID(), path)) |
1306 content::GetContentClient()->browser()->OpenItem(path); | 1307 content::GetContentClient()->browser()->OpenItem(path); |
1307 } | 1308 } |
1308 | 1309 |
1309 void RenderProcessHostImpl::OnSavedPageAsMHTML(int job_id, int64 data_size) { | 1310 void RenderProcessHostImpl::OnSavedPageAsMHTML(int job_id, int64 data_size) { |
1310 content::GetContentClient()->browser()->GetMHTMLGenerationManager()-> | 1311 content::GetContentClient()->browser()->GetMHTMLGenerationManager()-> |
1311 MHTMLGenerated(job_id, data_size); | 1312 MHTMLGenerated(job_id, data_size); |
1312 } | 1313 } |
| 1314 |
| 1315 void RenderProcessHostImpl::OnSendPostMessage( |
| 1316 int64 content_frame_id, |
| 1317 const ViewMsg_PostMessage_Params& params) { |
| 1318 DLOG(WARNING) << "OnSendPostMessage"; |
| 1319 content::FrameMap* frame_mapper = GetBrowserContext()->frame_mapper(); |
| 1320 content::ContentFrame* frame = |
| 1321 frame_mapper->FindFrame(content_frame_id); |
| 1322 |
| 1323 // Until we remove the proxy when a frame is closed, there might be a proxy |
| 1324 // for a frame that no longer exists. If that's the case, just drop the msg. |
| 1325 if (!frame) |
| 1326 return; |
| 1327 |
| 1328 const content::WebKitFrameIdentifier webkitFrameId = |
| 1329 frame->active_webkit_frame(); |
| 1330 |
| 1331 RenderViewHost *rvh = RenderViewHost::FromID(webkitFrameId.process_host_id, |
| 1332 webkitFrameId.route_id); |
| 1333 |
| 1334 // TODO(supersat): Temporary workaround for frames not being removed from |
| 1335 // the mapper properly. |
| 1336 if (!rvh) { |
| 1337 return; |
| 1338 } |
| 1339 |
| 1340 rvh->Send(new ViewMsg_PostMessage(rvh->routing_id(), |
| 1341 webkitFrameId.frame_id, |
| 1342 params)); |
| 1343 } |
OLD | NEW |