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 CHROME_BROWSER_MEDIA_CHROME_MIDI_PERMISSION_CONTEXT_H_
6 #define CHROME_BROWSER_MEDIA_CHROME_MIDI_PERMISSION_CONTEXT_H_
8 #include "base/memory/scoped_ptr.h"
9 #include "components/browser_context_keyed_service/browser_context_keyed_service.h"
10 #include "content/public/browser/browser_context.h"
17 class PermissionQueueController;
18 class PermissionRequestID;
21 // This class manages MIDI permissions flow. Used on the UI thread.
22 class ChromeMidiPermissionContext : public BrowserContextKeyedService {
24 explicit ChromeMidiPermissionContext(Profile* profile);
25 virtual ~ChromeMidiPermissionContext();
27 // BrowserContextKeyedService methods:
28 virtual void Shutdown() OVERRIDE;
30 // Request to ask users permission about MIDI.
31 void RequestMidiSysExPermission(
32 int render_process_id,
35 const GURL& requesting_frame,
36 const content::BrowserContext::MidiSysExPermissionCallback& callback);
38 // Cancel a pending MIDI permission request.
39 void CancelMidiSysExPermissionRequest(int render_process_id,
42 const GURL& requesting_frame);
44 // Called when the permission decision is made. If a permissions prompt is
45 // shown to the user it will be called when the user selects an option
47 void NotifyPermissionSet(
48 const PermissionRequestID& id,
49 const GURL& requesting_frame,
50 const content::BrowserContext::MidiSysExPermissionCallback& callback,
54 // Decide whether the permission should be granted.
55 // Calls PermissionDecided if permission can be decided non-interactively,
56 // or NotifyPermissionSet if permission decided by presenting an infobar.
57 void DecidePermission(
58 content::WebContents* web_contents,
59 const PermissionRequestID& id,
60 const GURL& requesting_frame,
62 const content::BrowserContext::MidiSysExPermissionCallback& callback);
64 // Called when permission is granted without interactively asking the user.
65 void PermissionDecided(
66 const PermissionRequestID& id,
67 const GURL& requesting_frame,
69 const content::BrowserContext::MidiSysExPermissionCallback& callback,
72 // Return an instance of the infobar queue controller, creating it if needed.
73 PermissionQueueController* GetQueueController();
75 // Removes any pending InfoBar request.
76 void CancelPendingInfobarRequest(const PermissionRequestID& id);
78 Profile* const profile_;
80 scoped_ptr<PermissionQueueController> permission_queue_controller_;
82 DISALLOW_COPY_AND_ASSIGN(ChromeMidiPermissionContext);
85 #endif // CHROME_BROWSER_MEDIA_CHROME_MIDI_PERMISSION_CONTEXT_H_