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

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

Issue 151343002: Web MIDI: make naming convention be consistent (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review boliu #2 Created 6 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « content/renderer/media/midi_dispatcher.h ('k') | content/renderer/media/midi_message_filter.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
11 #include "third_party/WebKit/public/web/WebMIDIPermissionRequest.h" 11 #include "third_party/WebKit/public/web/WebMIDIPermissionRequest.h"
12 #include "third_party/WebKit/public/web/WebSecurityOrigin.h" 12 #include "third_party/WebKit/public/web/WebSecurityOrigin.h"
13 13
14 using blink::WebMIDIPermissionRequest; 14 using blink::WebMIDIPermissionRequest;
15 using blink::WebSecurityOrigin; 15 using blink::WebSecurityOrigin;
16 16
17 namespace content { 17 namespace content {
18 18
19 MIDIDispatcher::MIDIDispatcher(RenderViewImpl* render_view) 19 MidiDispatcher::MidiDispatcher(RenderViewImpl* render_view)
20 : RenderViewObserver(render_view) { 20 : RenderViewObserver(render_view) {
21 } 21 }
22 22
23 MIDIDispatcher::~MIDIDispatcher() {} 23 MidiDispatcher::~MidiDispatcher() {}
24 24
25 bool MIDIDispatcher::OnMessageReceived(const IPC::Message& message) { 25 bool MidiDispatcher::OnMessageReceived(const IPC::Message& message) {
26 bool handled = true; 26 bool handled = true;
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 bridge_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(), 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 base::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,
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
OLDNEW
« no previous file with comments | « content/renderer/media/midi_dispatcher.h ('k') | content/renderer/media/midi_message_filter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698