OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/media/midi_host.h" | 5 #include "content/browser/renderer_host/media/midi_host.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
10 #include "base/process.h" | 10 #include "base/process.h" |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 bool handled = true; | 46 bool handled = true; |
47 IPC_BEGIN_MESSAGE_MAP_EX(MIDIHost, message, *message_was_ok) | 47 IPC_BEGIN_MESSAGE_MAP_EX(MIDIHost, message, *message_was_ok) |
48 IPC_MESSAGE_HANDLER(MIDIHostMsg_RequestAccess, OnRequestAccess) | 48 IPC_MESSAGE_HANDLER(MIDIHostMsg_RequestAccess, OnRequestAccess) |
49 IPC_MESSAGE_HANDLER(MIDIHostMsg_SendData, OnSendData) | 49 IPC_MESSAGE_HANDLER(MIDIHostMsg_SendData, OnSendData) |
50 IPC_MESSAGE_UNHANDLED(handled = false) | 50 IPC_MESSAGE_UNHANDLED(handled = false) |
51 IPC_END_MESSAGE_MAP_EX() | 51 IPC_END_MESSAGE_MAP_EX() |
52 | 52 |
53 return handled; | 53 return handled; |
54 } | 54 } |
55 | 55 |
56 void MIDIHost::OnRequestAccess(int client_id, int access) { | 56 void MIDIHost::OnRequestAccess(const std::string& origin, |
| 57 int client_id, |
| 58 int access) { |
| 59 // TODO(toyoshim): Use |origin| to handle sysex permissions. |
| 60 |
57 MIDIPortInfoList input_ports; | 61 MIDIPortInfoList input_ports; |
58 MIDIPortInfoList output_ports; | 62 MIDIPortInfoList output_ports; |
59 | 63 |
60 // Ask permission and register to receive MIDI data. | 64 // Ask permission and register to receive MIDI data. |
61 bool approved = false; | 65 bool approved = false; |
62 if (midi_manager_) { | 66 if (midi_manager_) { |
63 approved = midi_manager_->RequestAccess(this, access); | 67 approved = midi_manager_->RequestAccess(this, access); |
64 if (approved) { | 68 if (approved) { |
65 input_ports = midi_manager_->input_ports(); | 69 input_ports = midi_manager_->input_ports(); |
66 output_ports = midi_manager_->output_ports(); | 70 output_ports = midi_manager_->output_ports(); |
(...skipping 23 matching lines...) Expand all Loading... |
90 const uint8* data, | 94 const uint8* data, |
91 size_t length, | 95 size_t length, |
92 double timestamp) { | 96 double timestamp) { |
93 TRACE_EVENT0("midi", "MIDIHost::ReceiveMIDIData"); | 97 TRACE_EVENT0("midi", "MIDIHost::ReceiveMIDIData"); |
94 // Send to the renderer. | 98 // Send to the renderer. |
95 std::vector<uint8> v(data, data + length); | 99 std::vector<uint8> v(data, data + length); |
96 Send(new MIDIMsg_DataReceived(port_index, v, timestamp)); | 100 Send(new MIDIMsg_DataReceived(port_index, v, timestamp)); |
97 } | 101 } |
98 | 102 |
99 } // namespace content | 103 } // namespace content |
OLD | NEW |