| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/renderer_host/pepper/pepper_gamepad_host.h" | 5 #include "content/browser/renderer_host/pepper/pepper_gamepad_host.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "content/browser/gamepad/gamepad_service.h" | 8 #include "content/browser/gamepad/gamepad_service.h" |
| 9 #include "content/public/browser/browser_ppapi_host.h" | 9 #include "content/public/browser/browser_ppapi_host.h" |
| 10 #include "ppapi/c/pp_errors.h" | 10 #include "ppapi/c/pp_errors.h" |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 // gamepad. This is to prevent fingerprinting and matches what the web | 64 // gamepad. This is to prevent fingerprinting and matches what the web |
| 65 // platform does. | 65 // platform does. |
| 66 gamepad_service_->RegisterForUserGesture( | 66 gamepad_service_->RegisterForUserGesture( |
| 67 base::Bind(&PepperGamepadHost::GotUserGesture, | 67 base::Bind(&PepperGamepadHost::GotUserGesture, |
| 68 weak_factory_.GetWeakPtr(), | 68 weak_factory_.GetWeakPtr(), |
| 69 context->MakeReplyMessageContext())); | 69 context->MakeReplyMessageContext())); |
| 70 return PP_OK_COMPLETIONPENDING; | 70 return PP_OK_COMPLETIONPENDING; |
| 71 } | 71 } |
| 72 | 72 |
| 73 void PepperGamepadHost::GotUserGesture( | 73 void PepperGamepadHost::GotUserGesture( |
| 74 const ppapi::host::ReplyMessageContext& in_context) { | 74 const ppapi::host::ReplyMessageContext& context) { |
| 75 base::SharedMemoryHandle handle = | 75 base::SharedMemoryHandle handle = |
| 76 gamepad_service_->GetSharedMemoryHandleForProcess( | 76 gamepad_service_->GetSharedMemoryHandleForProcess( |
| 77 browser_ppapi_host_->GetPluginProcessHandle()); | 77 browser_ppapi_host_->GetPluginProcessHandle()); |
| 78 | 78 |
| 79 // The shared memory handle is sent in the params struct | |
| 80 // (in the reply context), so we have to make a copy to mutate it. | |
| 81 ppapi::host::ReplyMessageContext context = in_context; | |
| 82 context.params.AppendHandle(ppapi::proxy::SerializedHandle( | 79 context.params.AppendHandle(ppapi::proxy::SerializedHandle( |
| 83 handle, sizeof(ppapi::ContentGamepadHardwareBuffer))); | 80 handle, sizeof(ppapi::ContentGamepadHardwareBuffer))); |
| 84 host()->SendReply(context, PpapiPluginMsg_Gamepad_SendMemory()); | 81 host()->SendReply(context, PpapiPluginMsg_Gamepad_SendMemory()); |
| 85 } | 82 } |
| 86 | 83 |
| 87 } // namespace content | 84 } // namespace content |
| OLD | NEW |