| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "ipc/attachment_broker_privileged_win.h" | 5 #include "ipc/attachment_broker_privileged_win.h" |
| 6 | 6 |
| 7 #include <windows.h> | 7 #include <windows.h> |
| 8 | 8 |
| 9 #include "base/process/process.h" | 9 #include "base/process/process.h" |
| 10 #include "ipc/attachment_broker_messages.h" | 10 #include "ipc/attachment_broker_messages.h" |
| 11 #include "ipc/brokerable_attachment.h" | 11 #include "ipc/brokerable_attachment.h" |
| 12 #include "ipc/handle_attachment_win.h" | 12 #include "ipc/handle_attachment_win.h" |
| 13 #include "ipc/ipc_channel.h" | 13 #include "ipc/ipc_channel.h" |
| 14 | 14 |
| 15 namespace IPC { | 15 namespace IPC { |
| 16 | 16 |
| 17 AttachmentBrokerPrivilegedWin::AttachmentBrokerPrivilegedWin() {} | 17 AttachmentBrokerPrivilegedWin::AttachmentBrokerPrivilegedWin() {} |
| 18 | 18 |
| 19 AttachmentBrokerPrivilegedWin::~AttachmentBrokerPrivilegedWin() {} | 19 AttachmentBrokerPrivilegedWin::~AttachmentBrokerPrivilegedWin() {} |
| 20 | 20 |
| 21 bool AttachmentBrokerPrivilegedWin::SendAttachmentToProcess( | 21 bool AttachmentBrokerPrivilegedWin::SendAttachmentToProcess( |
| 22 const BrokerableAttachment* attachment, | 22 const BrokerableAttachment* attachment, |
| 23 base::ProcessId destination_process) { | 23 base::ProcessId destination_process) { |
| 24 switch (attachment->GetBrokerableType()) { | 24 switch (attachment->GetBrokerableType()) { |
| 25 case BrokerableAttachment::WIN_HANDLE: { | 25 case BrokerableAttachment::WIN_HANDLE: |
| 26 const internal::HandleAttachmentWin* handle_attachment = | 26 const internal::HandleAttachmentWin* handle_attachment = |
| 27 static_cast<const internal::HandleAttachmentWin*>(attachment); | 27 static_cast<const internal::HandleAttachmentWin*>(attachment); |
| 28 HandleWireFormat wire_format = | 28 HandleWireFormat wire_format = |
| 29 handle_attachment->GetWireFormat(destination_process); | 29 handle_attachment->GetWireFormat(destination_process); |
| 30 HandleWireFormat new_wire_format = | 30 HandleWireFormat new_wire_format = |
| 31 DuplicateWinHandle(wire_format, base::Process::Current().Pid()); | 31 DuplicateWinHandle(wire_format, base::Process::Current().Pid()); |
| 32 if (new_wire_format.handle == 0) | 32 if (new_wire_format.handle == 0) |
| 33 return false; | 33 return false; |
| 34 RouteDuplicatedHandle(new_wire_format); | 34 RouteDuplicatedHandle(new_wire_format); |
| 35 return true; | 35 return true; |
| 36 } | |
| 37 case BrokerableAttachment::PLACEHOLDER: | |
| 38 NOTREACHED(); | |
| 39 return false; | |
| 40 } | 36 } |
| 41 return false; | 37 return false; |
| 42 } | 38 } |
| 43 | 39 |
| 44 bool AttachmentBrokerPrivilegedWin::OnMessageReceived(const Message& msg) { | 40 bool AttachmentBrokerPrivilegedWin::OnMessageReceived(const Message& msg) { |
| 45 bool handled = true; | 41 bool handled = true; |
| 46 switch (msg.type()) { | 42 switch (msg.type()) { |
| 47 IPC_MESSAGE_HANDLER_GENERIC(AttachmentBrokerMsg_DuplicateWinHandle, | 43 IPC_MESSAGE_HANDLER_GENERIC(AttachmentBrokerMsg_DuplicateWinHandle, |
| 48 OnDuplicateWinHandle(msg)) | 44 OnDuplicateWinHandle(msg)) |
| 49 IPC_MESSAGE_UNHANDLED(handled = false) | 45 IPC_MESSAGE_UNHANDLED(handled = false) |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 dest_process.Handle(), &new_handle, | 124 dest_process.Handle(), &new_handle, |
| 129 desired_access, FALSE, options); | 125 desired_access, FALSE, options); |
| 130 | 126 |
| 131 new_wire_format.handle = (result != 0) ? HandleToLong(new_handle) : 0; | 127 new_wire_format.handle = (result != 0) ? HandleToLong(new_handle) : 0; |
| 132 } | 128 } |
| 133 | 129 |
| 134 return new_wire_format; | 130 return new_wire_format; |
| 135 } | 131 } |
| 136 | 132 |
| 137 } // namespace IPC | 133 } // namespace IPC |
| OLD | NEW |