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 #ifndef CONTENT_RENDERER_MEDIA_MIDI_DISPATCHER_H_ | 5 #ifndef CONTENT_RENDERER_MEDIA_MIDI_DISPATCHER_H_ |
6 #define CONTENT_RENDERER_MEDIA_MIDI_DISPATCHER_H_ | 6 #define CONTENT_RENDERER_MEDIA_MIDI_DISPATCHER_H_ |
7 | 7 |
8 #include "base/id_map.h" | 8 #include "base/id_map.h" |
| 9 #include "content/common/permission_service.mojom.h" |
9 #include "content/public/renderer/render_frame_observer.h" | 10 #include "content/public/renderer/render_frame_observer.h" |
10 #include "third_party/WebKit/public/web/WebMIDIClient.h" | 11 #include "third_party/WebKit/public/web/WebMIDIClient.h" |
11 | 12 |
12 namespace blink { | 13 namespace blink { |
13 class WebMIDIPermissionRequest; | 14 class WebMIDIPermissionRequest; |
14 } | 15 } |
15 | 16 |
16 namespace content { | 17 namespace content { |
17 | 18 |
18 // MidiDispatcher implements WebMIDIClient to handle permissions for using | 19 // MidiDispatcher implements WebMIDIClient to handle permissions for using |
19 // system exclusive messages. | 20 // system exclusive messages. |
20 // It works as RenderFrameObserver to handle IPC messages between | 21 // It works as RenderFrameObserver to keep a 1:1 relationship with a RenderFrame |
21 // MidiDispatcherHost owned by WebContents since permissions are managed in | 22 // and make sure it has the same life cycle. |
22 // the browser process. | |
23 class MidiDispatcher : public RenderFrameObserver, | 23 class MidiDispatcher : public RenderFrameObserver, |
24 public blink::WebMIDIClient { | 24 public blink::WebMIDIClient { |
25 public: | 25 public: |
26 explicit MidiDispatcher(RenderFrame* render_frame); | 26 explicit MidiDispatcher(RenderFrame* render_frame); |
27 virtual ~MidiDispatcher(); | 27 virtual ~MidiDispatcher(); |
28 | 28 |
29 private: | 29 private: |
30 // RenderFrameObserver implementation. | |
31 bool OnMessageReceived(const IPC::Message& message) override; | |
32 | |
33 // blink::WebMIDIClient implementation. | 30 // blink::WebMIDIClient implementation. |
34 virtual void requestSysexPermission( | 31 virtual void requestSysexPermission( |
35 const blink::WebMIDIPermissionRequest& request); | 32 const blink::WebMIDIPermissionRequest& request); |
36 virtual void cancelSysexPermissionRequest( | 33 virtual void cancelSysexPermissionRequest( |
37 const blink::WebMIDIPermissionRequest& request); | 34 const blink::WebMIDIPermissionRequest& request); |
38 | 35 |
39 // Permission for using system exclusive messages has been set. | 36 // Permission for using system exclusive messages has been set. |
40 void OnSysExPermissionApproved(int client_id, bool is_allowed); | 37 void OnSysExPermissionSet(int request_id, PermissionStatus status); |
41 | 38 |
42 // Each WebMIDIPermissionRequest object is valid until | 39 // Each WebMIDIPermissionRequest object is valid until |
43 // cancelSysexPermissionRequest() is called with the object, or used to call | 40 // cancelSysexPermissionRequest() is called with the object, or used to call |
44 // WebMIDIPermissionRequest::setIsAllowed(). | 41 // WebMIDIPermissionRequest::setIsAllowed(). |
45 typedef IDMap<blink::WebMIDIPermissionRequest, IDMapOwnPointer> Requests; | 42 typedef IDMap<blink::WebMIDIPermissionRequest, IDMapOwnPointer> Requests; |
46 Requests requests_; | 43 Requests requests_; |
47 | 44 |
| 45 PermissionServicePtr permission_service_; |
| 46 |
48 DISALLOW_COPY_AND_ASSIGN(MidiDispatcher); | 47 DISALLOW_COPY_AND_ASSIGN(MidiDispatcher); |
49 }; | 48 }; |
50 | 49 |
51 } // namespace content | 50 } // namespace content |
52 | 51 |
53 #endif // CONTENT_RENDERER_MEDIA_MIDI_DISPATCHER_H_ | 52 #endif // CONTENT_RENDERER_MEDIA_MIDI_DISPATCHER_H_ |
OLD | NEW |