Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(168)

Side by Side Diff: content/renderer/media/midi_dispatcher.cc

Issue 38043004: Cancel MIDI permission request infobar on MIDIAccess stop. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 16 matching lines...) Expand all
27 IPC_BEGIN_MESSAGE_MAP(MIDIDispatcher, message) 27 IPC_BEGIN_MESSAGE_MAP(MIDIDispatcher, message)
28 IPC_MESSAGE_HANDLER(MIDIMsg_SysExPermissionApproved, 28 IPC_MESSAGE_HANDLER(MIDIMsg_SysExPermissionApproved,
29 OnSysExPermissionApproved) 29 OnSysExPermissionApproved)
30 IPC_MESSAGE_UNHANDLED(handled = false) 30 IPC_MESSAGE_UNHANDLED(handled = false)
31 IPC_END_MESSAGE_MAP() 31 IPC_END_MESSAGE_MAP()
32 return handled; 32 return handled;
33 } 33 }
34 34
35 void MIDIDispatcher::requestSysExPermission( 35 void MIDIDispatcher::requestSysExPermission(
36 const WebMIDIPermissionRequest& request) { 36 const WebMIDIPermissionRequest& request) {
37 int client_id = requests_.Add(new WebMIDIPermissionRequest(request)); 37 int bridge_id = requests_.Add(new WebMIDIPermissionRequest(request));
38 WebSecurityOrigin security_origin = request.securityOrigin(); 38 WebSecurityOrigin security_origin = request.securityOrigin();
39 std::string origin = security_origin.toString().utf8(); 39 std::string origin = security_origin.toString().utf8();
40 GURL url(origin); 40 GURL url(origin);
41 Send(new MIDIHostMsg_RequestSysExPermission(routing_id(), client_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) {
Kibeom Kim (inactive) 2013/10/23 23:37:31 ddorwin@ or scherkus@ or xhwang@: This is triggere
ddorwin 2013/10/23 23:52:40 Can you provide more details on the exact path? T
Kibeom Kim (inactive) 2013/10/24 00:00:05 This is the call stack for MIDI. Started by one o
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 continue; 51 requests_.Remove(it.GetCurrentKey());
52 requests_.Remove(it.GetCurrentKey()); 52 string16 origin = request.securityOrigin().toString();
53 Send(new MIDIHostMsg_CancelSysExPermissionRequest(
54 routing_id(), it.GetCurrentKey(), GURL(origin)));
55 break;
56 }
53 } 57 }
54 } 58 }
55 59
56 void MIDIDispatcher::OnSysExPermissionApproved(int client_id, bool is_allowed) { 60 void MIDIDispatcher::OnSysExPermissionApproved(int bridge_id, bool is_allowed) {
57 // |request| can be NULL when the request is canceled. 61 // |request| can be NULL when the request is canceled.
58 WebMIDIPermissionRequest* request = requests_.Lookup(client_id); 62 WebMIDIPermissionRequest* request = requests_.Lookup(bridge_id);
59 if (!request) 63 if (!request)
60 return; 64 return;
61 request->setIsAllowed(is_allowed); 65 request->setIsAllowed(is_allowed);
62 requests_.Remove(client_id); 66 requests_.Remove(bridge_id);
63 } 67 }
64 68
65 } // namespace content 69 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698