Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / content / renderer / media / midi_dispatcher.h
blob0d40f46d26ed0369a1f0dda4aaccfb6ab11e276d
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/public/renderer/render_frame_observer.h"
10 #include "third_party/WebKit/public/web/WebMIDIClient.h"
12 namespace blink {
13 class WebMIDIPermissionRequest;
16 namespace content {
18 // MidiDispatcher implements WebMIDIClient to handle permissions for using
19 // system exclusive messages.
20 // It works as RenderFrameObserver to handle IPC messages between
21 // MidiDispatcherHost owned by WebContents since permissions are managed in
22 // the browser process.
23 class MidiDispatcher : public RenderFrameObserver,
24 public blink::WebMIDIClient {
25 public:
26 explicit MidiDispatcher(RenderFrame* render_frame);
27 virtual ~MidiDispatcher();
29 private:
30 // RenderFrameObserver implementation.
31 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
33 // blink::WebMIDIClient implementation.
34 virtual void requestSysexPermission(
35 const blink::WebMIDIPermissionRequest& request);
36 virtual void cancelSysexPermissionRequest(
37 const blink::WebMIDIPermissionRequest& request);
39 // Permission for using system exclusive messages has been set.
40 void OnSysExPermissionApproved(int client_id, bool is_allowed);
42 // Each WebMIDIPermissionRequest object is valid until
43 // cancelSysexPermissionRequest() is called with the object, or used to call
44 // WebMIDIPermissionRequest::setIsAllowed().
45 typedef IDMap<blink::WebMIDIPermissionRequest, IDMapOwnPointer> Requests;
46 Requests requests_;
48 DISALLOW_COPY_AND_ASSIGN(MidiDispatcher);
51 } // namespace content
53 #endif // CONTENT_RENDERER_MEDIA_MIDI_DISPATCHER_H_