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"
13 class PermissionQueueController;
14 class PermissionRequestID;
17 // This class manages MIDI permissions flow. Used on the UI thread.
18 class ChromeMIDIPermissionContext : public BrowserContextKeyedService {
20 explicit ChromeMIDIPermissionContext(Profile* profile);
21 virtual ~ChromeMIDIPermissionContext();
23 // BrowserContextKeyedService methods:
24 virtual void Shutdown() OVERRIDE;
26 // Request to ask users permission about MIDI.
27 void RequestMIDISysExPermission(
28 int render_process_id,
31 const GURL& requesting_frame,
32 const content::BrowserContext::MIDISysExPermissionCallback& callback);
34 // Cancel a pending MIDI permission request.
35 void CancelMIDISysExPermissionRequest(int render_process_id,
38 const GURL& requesting_frame);
41 // Decide whether the permission should be granted.
42 // Calls PermissionDecided if permission can be decided non-interactively,
43 // or NotifyPermissionSet if permission decided by presenting an infobar.
44 void DecidePermission(
45 const PermissionRequestID& id,
46 const GURL& requesting_frame,
48 const content::BrowserContext::MIDISysExPermissionCallback& callback);
50 // Called when permission is granted without interactively asking the user.
51 void PermissionDecided(
52 const PermissionRequestID& id,
53 const GURL& requesting_frame,
55 const content::BrowserContext::MIDISysExPermissionCallback& callback,
58 // Called when the permission decision is made. It may be by the
59 // InfoBarDelegate to notify permission has been set.
60 void NotifyPermissionSet(
61 const PermissionRequestID& id,
62 const GURL& requesting_frame,
63 const content::BrowserContext::MIDISysExPermissionCallback& callback,
66 // Return an instance of the infobar queue controller, creating it if needed.
67 PermissionQueueController* GetQueueController();
69 // Removes any pending InfoBar request.
70 void CancelPendingInfoBarRequest(const PermissionRequestID& id);
72 Profile* const profile_;
74 scoped_ptr<PermissionQueueController> permission_queue_controller_;
76 DISALLOW_COPY_AND_ASSIGN(ChromeMIDIPermissionContext);
79 #endif // CHROME_BROWSER_MEDIA_CHROME_MIDI_PERMISSION_CONTEXT_H_