Fix crash on app list start page contents not existing.
[chromium-blink-merge.git] / content / renderer / media / midi_dispatcher.h
blob65a11d117b70d550144e58f5012665fa8785697d
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.
5 #ifndef CONTENT_RENDERER_MEDIA_MIDI_DISPATCHER_H_
6 #define CONTENT_RENDERER_MEDIA_MIDI_DISPATCHER_H_
8 #include "base/id_map.h"
9 #include "content/common/permission_service.mojom.h"
10 #include "content/public/renderer/render_frame_observer.h"
11 #include "third_party/WebKit/public/web/WebMIDIClient.h"
13 namespace blink {
14 class WebMIDIPermissionRequest;
17 namespace content {
19 // MidiDispatcher implements WebMIDIClient to handle permissions for using
20 // system exclusive messages.
21 // It works as RenderFrameObserver to keep a 1:1 relationship with a RenderFrame
22 // and make sure it has the same life cycle.
23 class MidiDispatcher : public RenderFrameObserver,
24 public blink::WebMIDIClient {
25 public:
26 explicit MidiDispatcher(RenderFrame* render_frame);
27 virtual ~MidiDispatcher();
29 private:
30 // blink::WebMIDIClient implementation.
31 virtual void requestSysexPermission(
32 const blink::WebMIDIPermissionRequest& request);
33 virtual void cancelSysexPermissionRequest(
34 const blink::WebMIDIPermissionRequest& request);
36 // Permission for using system exclusive messages has been set.
37 void OnSysExPermissionSet(int request_id, PermissionStatus status);
39 // Each WebMIDIPermissionRequest object is valid until
40 // cancelSysexPermissionRequest() is called with the object, or used to call
41 // WebMIDIPermissionRequest::setIsAllowed().
42 typedef IDMap<blink::WebMIDIPermissionRequest, IDMapOwnPointer> Requests;
43 Requests requests_;
45 PermissionServicePtr permission_service_;
47 DISALLOW_COPY_AND_ASSIGN(MidiDispatcher);
50 } // namespace content
52 #endif // CONTENT_RENDERER_MEDIA_MIDI_DISPATCHER_H_