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 CHROME_BROWSER_MEDIA_CHROME_MIDI_PERMISSION_CONTEXT_H_ | 5 #ifndef CHROME_BROWSER_MEDIA_CHROME_MIDI_PERMISSION_CONTEXT_H_ |
6 #define CHROME_BROWSER_MEDIA_CHROME_MIDI_PERMISSION_CONTEXT_H_ | 6 #define CHROME_BROWSER_MEDIA_CHROME_MIDI_PERMISSION_CONTEXT_H_ |
7 | 7 |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "components/browser_context_keyed_service/browser_context_keyed_service
.h" | 9 #include "components/browser_context_keyed_service/browser_context_keyed_service
.h" |
10 #include "content/public/browser/browser_context.h" | 10 #include "content/public/browser/browser_context.h" |
11 | 11 |
12 class GURL; | 12 class GURL; |
13 class PermissionQueueController; | 13 class PermissionQueueController; |
14 class PermissionRequestID; | 14 class PermissionRequestID; |
15 class Profile; | 15 class Profile; |
16 | 16 |
17 // This class manages MIDI permissions flow. Used on the UI thread. | 17 // This class manages MIDI permissions flow. Used on the UI thread. |
18 class ChromeMIDIPermissionContext : public BrowserContextKeyedService { | 18 class ChromeMIDIPermissionContext : public BrowserContextKeyedService { |
19 public: | 19 public: |
20 explicit ChromeMIDIPermissionContext(Profile* profile); | 20 explicit ChromeMIDIPermissionContext(Profile* profile); |
21 virtual ~ChromeMIDIPermissionContext(); | 21 virtual ~ChromeMIDIPermissionContext(); |
22 | 22 |
23 // BrowserContextKeyedService methods: | 23 // BrowserContextKeyedService methods: |
24 virtual void Shutdown() OVERRIDE; | 24 virtual void Shutdown() OVERRIDE; |
25 | 25 |
26 // Request to ask users permission about MIDI. | 26 // Request to ask users permission about MIDI. |
27 void RequestMIDISysExPermission( | 27 void RequestMIDISysExPermission( |
28 int render_process_id, | 28 int render_process_id, |
29 int render_view_id, | 29 int render_view_id, |
| 30 int bridge_id, |
30 const GURL& requesting_frame, | 31 const GURL& requesting_frame, |
31 const content::BrowserContext::MIDISysExPermissionCallback& callback); | 32 const content::BrowserContext::MIDISysExPermissionCallback& callback); |
32 | 33 |
| 34 // Cancel a pending MIDI permission request. |
| 35 void CancelMIDISysExPermissionRequest(int render_process_id, |
| 36 int render_view_id, |
| 37 int bridge_id, |
| 38 const GURL& requesting_frame); |
| 39 |
33 private: | 40 private: |
34 // Decide whether the permission should be granted. | 41 // Decide whether the permission should be granted. |
35 // Calls PermissionDecided if permission can be decided non-interactively, | 42 // Calls PermissionDecided if permission can be decided non-interactively, |
36 // or NotifyPermissionSet if permission decided by presenting an infobar. | 43 // or NotifyPermissionSet if permission decided by presenting an infobar. |
37 void DecidePermission( | 44 void DecidePermission( |
38 const PermissionRequestID& id, | 45 const PermissionRequestID& id, |
39 const GURL& requesting_frame, | 46 const GURL& requesting_frame, |
40 const GURL& embedder, | 47 const GURL& embedder, |
41 const content::BrowserContext::MIDISysExPermissionCallback& callback); | 48 const content::BrowserContext::MIDISysExPermissionCallback& callback); |
42 | 49 |
43 // Called when permission is granted without interactively asking the user. | 50 // Called when permission is granted without interactively asking the user. |
44 void PermissionDecided( | 51 void PermissionDecided( |
45 const PermissionRequestID& id, | 52 const PermissionRequestID& id, |
46 const GURL& requesting_frame, | 53 const GURL& requesting_frame, |
47 const GURL& embedder, | 54 const GURL& embedder, |
48 const content::BrowserContext::MIDISysExPermissionCallback& callback, | 55 const content::BrowserContext::MIDISysExPermissionCallback& callback, |
49 bool allowed); | 56 bool allowed); |
50 | 57 |
51 // Called when the permission decision is made. It may be by the | 58 // Called when the permission decision is made. It may be by the |
52 // InfoBarDelegate to notify permission has been set. | 59 // InfoBarDelegate to notify permission has been set. |
53 void NotifyPermissionSet( | 60 void NotifyPermissionSet( |
54 const PermissionRequestID& id, | 61 const PermissionRequestID& id, |
55 const GURL& requesting_frame, | 62 const GURL& requesting_frame, |
56 const content::BrowserContext::MIDISysExPermissionCallback& callback, | 63 const content::BrowserContext::MIDISysExPermissionCallback& callback, |
57 bool allowed); | 64 bool allowed); |
58 | 65 |
59 // Return an instance of the infobar queue controller, creating it if needed. | 66 // Return an instance of the infobar queue controller, creating it if needed. |
60 PermissionQueueController* GetQueueController(); | 67 PermissionQueueController* GetQueueController(); |
61 | 68 |
| 69 // Removes any pending InfoBar request. |
| 70 void CancelPendingInfoBarRequest(const PermissionRequestID& id); |
| 71 |
62 Profile* const profile_; | 72 Profile* const profile_; |
63 bool shutting_down_; | 73 bool shutting_down_; |
64 scoped_ptr<PermissionQueueController> permission_queue_controller_; | 74 scoped_ptr<PermissionQueueController> permission_queue_controller_; |
65 | 75 |
66 DISALLOW_COPY_AND_ASSIGN(ChromeMIDIPermissionContext); | 76 DISALLOW_COPY_AND_ASSIGN(ChromeMIDIPermissionContext); |
67 }; | 77 }; |
68 | 78 |
69 #endif // CHROME_BROWSER_MEDIA_CHROME_MIDI_PERMISSION_CONTEXT_H_ | 79 #endif // CHROME_BROWSER_MEDIA_CHROME_MIDI_PERMISSION_CONTEXT_H_ |
OLD | NEW |