| 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/renderer/media/midi_dispatcher.h" | 5 #include "content/renderer/media/midi_dispatcher.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "content/common/media/midi_messages.h" | 9 #include "content/common/media/midi_messages.h" |
| 10 #include "content/renderer/render_view_impl.h" | 10 #include "content/renderer/render_view_impl.h" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 Send(new MIDIHostMsg_RequestSysExPermission(routing_id(), bridge_id, url)); | 41 Send(new MIDIHostMsg_RequestSysExPermission(routing_id(), bridge_id, url)); |
| 42 } | 42 } |
| 43 | 43 |
| 44 void MIDIDispatcher::cancelSysExPermissionRequest( | 44 void MIDIDispatcher::cancelSysExPermissionRequest( |
| 45 const WebMIDIPermissionRequest& request) { | 45 const WebMIDIPermissionRequest& request) { |
| 46 for (IDMap<WebMIDIPermissionRequest>::iterator it(&requests_); | 46 for (IDMap<WebMIDIPermissionRequest>::iterator it(&requests_); |
| 47 !it.IsAtEnd(); | 47 !it.IsAtEnd(); |
| 48 it.Advance()) { | 48 it.Advance()) { |
| 49 WebMIDIPermissionRequest* value = it.GetCurrentValue(); | 49 WebMIDIPermissionRequest* value = it.GetCurrentValue(); |
| 50 if (value->equals(request)) { | 50 if (value->equals(request)) { |
| 51 string16 origin = request.securityOrigin().toString(); | 51 base::string16 origin = request.securityOrigin().toString(); |
| 52 Send(new MIDIHostMsg_CancelSysExPermissionRequest( | 52 Send(new MIDIHostMsg_CancelSysExPermissionRequest( |
| 53 routing_id(), it.GetCurrentKey(), GURL(origin))); | 53 routing_id(), it.GetCurrentKey(), GURL(origin))); |
| 54 requests_.Remove(it.GetCurrentKey()); | 54 requests_.Remove(it.GetCurrentKey()); |
| 55 break; | 55 break; |
| 56 } | 56 } |
| 57 } | 57 } |
| 58 } | 58 } |
| 59 | 59 |
| 60 void MIDIDispatcher::OnSysExPermissionApproved(int bridge_id, bool is_allowed) { | 60 void MIDIDispatcher::OnSysExPermissionApproved(int bridge_id, bool is_allowed) { |
| 61 // |request| can be NULL when the request is canceled. | 61 // |request| can be NULL when the request is canceled. |
| 62 WebMIDIPermissionRequest* request = requests_.Lookup(bridge_id); | 62 WebMIDIPermissionRequest* request = requests_.Lookup(bridge_id); |
| 63 if (!request) | 63 if (!request) |
| 64 return; | 64 return; |
| 65 request->setIsAllowed(is_allowed); | 65 request->setIsAllowed(is_allowed); |
| 66 requests_.Remove(bridge_id); | 66 requests_.Remove(bridge_id); |
| 67 } | 67 } |
| 68 | 68 |
| 69 } // namespace content | 69 } // namespace content |
| OLD | NEW |