| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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_dispatcher_host.h" | 5 #include "content/browser/renderer_host/media/midi_dispatcher_host.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "content/browser/child_process_security_policy_impl.h" | 8 #include "content/browser/child_process_security_policy_impl.h" |
| 9 #include "content/browser/renderer_host/render_view_host_impl.h" | 9 #include "content/browser/renderer_host/render_view_host_impl.h" |
| 10 #include "content/common/media/midi_messages.h" | 10 #include "content/common/media/midi_messages.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 | 22 |
| 23 MIDIDispatcherHost::~MIDIDispatcherHost() { | 23 MIDIDispatcherHost::~MIDIDispatcherHost() { |
| 24 } | 24 } |
| 25 | 25 |
| 26 bool MIDIDispatcherHost::OnMessageReceived(const IPC::Message& message, | 26 bool MIDIDispatcherHost::OnMessageReceived(const IPC::Message& message, |
| 27 bool* message_was_ok) { | 27 bool* message_was_ok) { |
| 28 bool handled = true; | 28 bool handled = true; |
| 29 IPC_BEGIN_MESSAGE_MAP_EX(MIDIDispatcherHost, message, *message_was_ok) | 29 IPC_BEGIN_MESSAGE_MAP_EX(MIDIDispatcherHost, message, *message_was_ok) |
| 30 IPC_MESSAGE_HANDLER(MIDIHostMsg_RequestSysExPermission, | 30 IPC_MESSAGE_HANDLER(MIDIHostMsg_RequestSysExPermission, |
| 31 OnRequestSysExPermission) | 31 OnRequestSysExPermission) |
| 32 IPC_MESSAGE_HANDLER(MIDIHostMsg_CancelSysExPermissionRequest, |
| 33 OnCancelSysExPermissionRequest) |
| 32 IPC_MESSAGE_UNHANDLED(handled = false) | 34 IPC_MESSAGE_UNHANDLED(handled = false) |
| 33 IPC_END_MESSAGE_MAP_EX() | 35 IPC_END_MESSAGE_MAP_EX() |
| 34 return handled; | 36 return handled; |
| 35 } | 37 } |
| 36 | 38 |
| 37 void MIDIDispatcherHost::OverrideThreadForMessage( | 39 void MIDIDispatcherHost::OverrideThreadForMessage( |
| 38 const IPC::Message& message, BrowserThread::ID* thread) { | 40 const IPC::Message& message, BrowserThread::ID* thread) { |
| 39 if (message.type() == MIDIHostMsg_RequestSysExPermission::ID) | 41 if (IPC_MESSAGE_CLASS(message) == MIDIMsgStart) |
| 40 *thread = BrowserThread::UI; | 42 *thread = BrowserThread::UI; |
| 41 } | 43 } |
| 42 | 44 |
| 43 void MIDIDispatcherHost::OnRequestSysExPermission(int render_view_id, | 45 void MIDIDispatcherHost::OnRequestSysExPermission(int render_view_id, |
| 44 int client_id, | 46 int bridge_id, |
| 45 const GURL& origin) { | 47 const GURL& origin) { |
| 46 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 48 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 47 | 49 |
| 48 browser_context_->RequestMIDISysExPermission( | 50 browser_context_->RequestMIDISysExPermission( |
| 49 render_process_id_, | 51 render_process_id_, |
| 50 render_view_id, | 52 render_view_id, |
| 53 bridge_id, |
| 51 origin, | 54 origin, |
| 52 base::Bind(&MIDIDispatcherHost::WasSysExPermissionGranted, | 55 base::Bind(&MIDIDispatcherHost::WasSysExPermissionGranted, |
| 53 base::Unretained(this), | 56 base::Unretained(this), |
| 54 render_view_id, | 57 render_view_id, |
| 55 client_id)); | 58 bridge_id)); |
| 56 } | 59 } |
| 57 | 60 |
| 61 void MIDIDispatcherHost::OnCancelSysExPermissionRequest( |
| 62 int render_view_id, |
| 63 int bridge_id, |
| 64 const GURL& requesting_frame) { |
| 65 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 66 DVLOG(1) << __FUNCTION__ << " " << render_process_id_ << ":" << render_view_id |
| 67 << ":" << bridge_id; |
| 68 browser_context_->CancelMIDISysExPermissionRequest( |
| 69 render_process_id_, render_view_id, bridge_id, requesting_frame); |
| 70 } |
| 58 void MIDIDispatcherHost::WasSysExPermissionGranted(int render_view_id, | 71 void MIDIDispatcherHost::WasSysExPermissionGranted(int render_view_id, |
| 59 int client_id, | 72 int bridge_id, |
| 60 bool success) { | 73 bool success) { |
| 61 ChildProcessSecurityPolicyImpl::GetInstance()->GrantSendMIDISysExMessage( | 74 ChildProcessSecurityPolicyImpl::GetInstance()->GrantSendMIDISysExMessage( |
| 62 render_process_id_); | 75 render_process_id_); |
| 63 Send(new MIDIMsg_SysExPermissionApproved(render_view_id, client_id, success)); | 76 Send(new MIDIMsg_SysExPermissionApproved(render_view_id, bridge_id, success)); |
| 64 } | 77 } |
| 65 | 78 |
| 66 } // namespace content | 79 } // namespace content |
| OLD | NEW |