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

Side by Side Diff: content/browser/renderer_host/media/midi_dispatcher_host.cc

Issue 335993002: Convert MIDI permission requests to use WebContents in preparation for switching the code to using … (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "content/browser/renderer_host/media/midi_dispatcher_host.h"
6
7 #include "base/bind.h"
8 #include "content/browser/child_process_security_policy_impl.h"
9 #include "content/browser/renderer_host/render_view_host_impl.h"
10 #include "content/common/media/midi_messages.h"
11 #include "content/public/browser/browser_context.h"
12 #include "content/public/browser/browser_thread.h"
13 #include "url/gurl.h"
14
15 namespace content {
16
17 MidiDispatcherHost::MidiDispatcherHost(int render_process_id,
18 BrowserContext* browser_context)
19 : BrowserMessageFilter(MidiMsgStart),
20 render_process_id_(render_process_id),
21 browser_context_(browser_context) {
22 }
23
24 MidiDispatcherHost::~MidiDispatcherHost() {
25 }
26
27 bool MidiDispatcherHost::OnMessageReceived(const IPC::Message& message) {
28 bool handled = true;
29 IPC_BEGIN_MESSAGE_MAP(MidiDispatcherHost, message)
30 IPC_MESSAGE_HANDLER(MidiHostMsg_RequestSysExPermission,
31 OnRequestSysExPermission)
32 IPC_MESSAGE_HANDLER(MidiHostMsg_CancelSysExPermissionRequest,
33 OnCancelSysExPermissionRequest)
34 IPC_MESSAGE_UNHANDLED(handled = false)
35 IPC_END_MESSAGE_MAP()
36 return handled;
37 }
38
39 void MidiDispatcherHost::OverrideThreadForMessage(
40 const IPC::Message& message, BrowserThread::ID* thread) {
41 if (IPC_MESSAGE_CLASS(message) == MidiMsgStart)
42 *thread = BrowserThread::UI;
43 }
44
45 void MidiDispatcherHost::OnRequestSysExPermission(int render_view_id,
46 int bridge_id,
47 const GURL& origin,
48 bool user_gesture) {
49 DCHECK_CURRENTLY_ON(BrowserThread::UI);
50
51 browser_context_->RequestMidiSysExPermission(
52 render_process_id_,
53 render_view_id,
54 bridge_id,
55 origin,
56 user_gesture,
57 base::Bind(&MidiDispatcherHost::WasSysExPermissionGranted,
58 base::Unretained(this),
59 render_view_id,
60 bridge_id));
61 }
62
63 void MidiDispatcherHost::OnCancelSysExPermissionRequest(
64 int render_view_id,
65 int bridge_id,
66 const GURL& requesting_frame) {
67 DCHECK_CURRENTLY_ON(BrowserThread::UI);
68 DVLOG(1) << __FUNCTION__ << " " << render_process_id_ << ":" << render_view_id
69 << ":" << bridge_id;
70 browser_context_->CancelMidiSysExPermissionRequest(
71 render_process_id_, render_view_id, bridge_id, requesting_frame);
72 }
73 void MidiDispatcherHost::WasSysExPermissionGranted(int render_view_id,
74 int bridge_id,
75 bool is_allowed) {
76 if (is_allowed)
77 ChildProcessSecurityPolicyImpl::GetInstance()->GrantSendMidiSysExMessage(
78 render_process_id_);
79 Send(new MidiMsg_SysExPermissionApproved(
80 render_view_id, bridge_id, is_allowed));
81 }
82
83 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/media/midi_dispatcher_host.h ('k') | content/browser/renderer_host/media/midi_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698