OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "content/browser/renderer_host/vr_message_filter.h" |
| 6 |
| 7 #include "content/common/vr_messages.h" |
| 8 #include "third_party/WebKit/public/platform/WebVR.h" |
| 9 |
| 10 namespace content { |
| 11 |
| 12 VRMessageFilter::VRMessageFilter() |
| 13 : BrowserMessageFilter(VRMsgStart) { |
| 14 } |
| 15 |
| 16 VRMessageFilter::~VRMessageFilter() { |
| 17 } |
| 18 |
| 19 void VRMessageFilter::OnDestruct() const { |
| 20 BrowserThread::DeleteOnIOThread::Destruct(this); |
| 21 } |
| 22 |
| 23 bool VRMessageFilter::OnMessageReceived( |
| 24 const IPC::Message& message) { |
| 25 bool handled = true; |
| 26 IPC_BEGIN_MESSAGE_MAP(VRMessageFilter, message) |
| 27 IPC_MESSAGE_HANDLER(VRHostMsg_GetVRDevices, |
| 28 OnGetVRDevices) |
| 29 IPC_MESSAGE_HANDLER(VRHostMsg_GetSensorState, |
| 30 OnGetSensorState) |
| 31 IPC_MESSAGE_HANDLER(VRHostMsg_ResetSensor, |
| 32 OnResetSensor) |
| 33 IPC_MESSAGE_HANDLER(VRHostMsg_GetRenderTargetRects, |
| 34 OnGetRenderTargetRects) |
| 35 IPC_MESSAGE_UNHANDLED(handled = false) |
| 36 IPC_END_MESSAGE_MAP() |
| 37 return handled; |
| 38 } |
| 39 |
| 40 void VRMessageFilter::OnGetVRDevices( |
| 41 std::vector<blink::WebVRDevice>* devices) { |
| 42 GetServiceInstance()->GetVRDevices(devices); |
| 43 } |
| 44 |
| 45 void VRMessageFilter::OnGetSensorState( |
| 46 unsigned int index, blink::WebHMDSensorState* state) { |
| 47 VRDevice* device = GetServiceInstance()->GetDevice(index); |
| 48 if (device) { |
| 49 device->GetSensorState(state); |
| 50 } |
| 51 } |
| 52 |
| 53 void VRMessageFilter::OnResetSensor(unsigned int index) { |
| 54 VRDevice* device = GetServiceInstance()->GetDevice(index); |
| 55 if (device) { |
| 56 device->ResetSensor(); |
| 57 } |
| 58 } |
| 59 |
| 60 void VRMessageFilter::OnGetRenderTargetRects( |
| 61 unsigned index, |
| 62 blink::WebVRFieldOfView leftFov, |
| 63 blink::WebVRFieldOfView rightFov, |
| 64 blink::WebVRVector4* leftRect, |
| 65 blink::WebVRVector4* rightRect) { |
| 66 VRDevice* device = GetServiceInstance()->GetDevice(index); |
| 67 if (device) { |
| 68 device->GetRenderTargetRects(leftFov, rightFov, leftRect, rightRect); |
| 69 } |
| 70 } |
| 71 |
| 72 } // namespace content |
OLD | NEW |