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 28 matching lines...) Expand all Loading... | |
39 WebSecurityOrigin security_origin = request.securityOrigin(); | 39 WebSecurityOrigin security_origin = request.securityOrigin(); |
40 GURL url(security_origin.toString()); | 40 GURL url(security_origin.toString()); |
41 Send(new MidiHostMsg_RequestSysExPermission(routing_id(), bridge_id, url, | 41 Send(new MidiHostMsg_RequestSysExPermission(routing_id(), bridge_id, url, |
42 blink::WebUserGestureIndicator::isProcessingUserGesture())); | 42 blink::WebUserGestureIndicator::isProcessingUserGesture())); |
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 continue; |
51 Send(new MidiHostMsg_CancelSysExPermissionRequest( | 51 requests_.Remove(it.GetCurrentKey()); |
52 routing_id(), it.GetCurrentKey(), GURL(origin))); | 52 break; |
53 // The request will be removed by OnSysExPermissionApproved once | |
54 // the blink MIDIAccessInitializer object is deleted. | |
mlamouri (slow - plz ping)
2014/10/09 12:47:36
That doesn't seem to be true.
Charlie Reis
2014/10/09 17:11:31
Sad that there's no test for this class to catch t
mlamouri (slow - plz ping)
2014/10/09 21:33:50
Having the |request| pending would only have it le
| |
55 break; | |
56 } | |
57 } | 53 } |
58 } | 54 } |
59 | 55 |
60 void MidiDispatcher::OnSysExPermissionApproved(int bridge_id, | 56 void MidiDispatcher::OnSysExPermissionApproved(int bridge_id, |
61 bool is_allowed) { | 57 bool is_allowed) { |
62 // |request| can be NULL when the request is canceled. | 58 // |request| can be NULL when the request is canceled. |
63 WebMIDIPermissionRequest* request = requests_.Lookup(bridge_id); | 59 WebMIDIPermissionRequest* request = requests_.Lookup(bridge_id); |
64 if (!request) | 60 if (!request) |
65 return; | 61 return; |
66 request->setIsAllowed(is_allowed); | 62 request->setIsAllowed(is_allowed); |
67 requests_.Remove(bridge_id); | 63 requests_.Remove(bridge_id); |
68 } | 64 } |
69 | 65 |
70 } // namespace content | 66 } // namespace content |
OLD | NEW |