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() : BrowserMessageFilter(VRMsgStart) { |
| 13 } |
| 14 |
| 15 VRMessageFilter::~VRMessageFilter() { |
| 16 } |
| 17 |
| 18 void VRMessageFilter::OnDestruct() const { |
| 19 BrowserThread::DeleteOnIOThread::Destruct(this); |
| 20 } |
| 21 |
| 22 bool VRMessageFilter::OnMessageReceived(const IPC::Message& message) { |
| 23 bool handled = true; |
| 24 IPC_BEGIN_MESSAGE_MAP(VRMessageFilter, message) |
| 25 IPC_MESSAGE_HANDLER(VRHostMsg_GetVRDevices, OnGetVRDevices) |
| 26 IPC_MESSAGE_HANDLER(VRHostMsg_GetSensorState, OnGetSensorState) |
| 27 IPC_MESSAGE_HANDLER(VRHostMsg_ResetSensor, OnResetSensor) |
| 28 IPC_MESSAGE_UNHANDLED(handled = false) |
| 29 IPC_END_MESSAGE_MAP() |
| 30 return handled; |
| 31 } |
| 32 |
| 33 void VRMessageFilter::OnGetVRDevices(int32_t render_frame_id, int request_id) { |
| 34 std::vector<blink::WebVRDevice> devices; |
| 35 GetServiceInstance()->GetVRDevices(&devices); |
| 36 Send(new VRMsg_GetDevicesSuccess(render_frame_id, request_id, devices)); |
| 37 } |
| 38 |
| 39 void VRMessageFilter::OnGetSensorState(int32_t render_frame_id, |
| 40 unsigned int index, |
| 41 blink::WebHMDSensorState* state) { |
| 42 VRDevice* device = GetServiceInstance()->GetDevice(index); |
| 43 if (device) |
| 44 device->GetSensorState(state); |
| 45 } |
| 46 |
| 47 void VRMessageFilter::OnResetSensor(int32_t render_frame_id, |
| 48 unsigned int index) { |
| 49 VRDevice* device = GetServiceInstance()->GetDevice(index); |
| 50 if (device) |
| 51 device->ResetSensor(); |
| 52 } |
| 53 |
| 54 } // namespace content |
OLD | NEW |