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 "third_party/WebKit/public/platform/WebString.h" | 10 #include "third_party/WebKit/public/platform/WebString.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 } | 43 } |
44 | 44 |
45 void MidiDispatcher::cancelSysexPermissionRequest( | 45 void MidiDispatcher::cancelSysexPermissionRequest( |
46 const WebMIDIPermissionRequest& request) { | 46 const WebMIDIPermissionRequest& request) { |
47 for (Requests::iterator it(&requests_); !it.IsAtEnd(); it.Advance()) { | 47 for (Requests::iterator it(&requests_); !it.IsAtEnd(); it.Advance()) { |
48 WebMIDIPermissionRequest* value = it.GetCurrentValue(); | 48 WebMIDIPermissionRequest* value = it.GetCurrentValue(); |
49 if (value->equals(request)) { | 49 if (value->equals(request)) { |
50 base::string16 origin = request.securityOrigin().toString(); | 50 base::string16 origin = request.securityOrigin().toString(); |
51 Send(new MidiHostMsg_CancelSysExPermissionRequest( | 51 Send(new MidiHostMsg_CancelSysExPermissionRequest( |
52 routing_id(), it.GetCurrentKey(), GURL(origin))); | 52 routing_id(), it.GetCurrentKey(), GURL(origin))); |
53 requests_.Remove(it.GetCurrentKey()); | 53 // The request will be removed by OnSysExPermissionApproved once |
| 54 // the blink MIDIAccessInitializer object is deleted. |
54 break; | 55 break; |
55 } | 56 } |
56 } | 57 } |
57 } | 58 } |
58 | 59 |
59 void MidiDispatcher::OnSysExPermissionApproved(int bridge_id, | 60 void MidiDispatcher::OnSysExPermissionApproved(int bridge_id, |
60 bool is_allowed) { | 61 bool is_allowed) { |
61 // |request| can be NULL when the request is canceled. | 62 // |request| can be NULL when the request is canceled. |
62 WebMIDIPermissionRequest* request = requests_.Lookup(bridge_id); | 63 WebMIDIPermissionRequest* request = requests_.Lookup(bridge_id); |
63 if (!request) | 64 if (!request) |
64 return; | 65 return; |
65 request->setIsAllowed(is_allowed); | 66 request->setIsAllowed(is_allowed); |
66 requests_.Remove(bridge_id); | 67 requests_.Remove(bridge_id); |
67 } | 68 } |
68 | 69 |
69 } // namespace content | 70 } // namespace content |
OLD | NEW |