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/containers/scoped_ptr_hash_map.h" |
8 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
9 #include "components/keyed_service/core/keyed_service.h" | 10 #include "components/keyed_service/core/keyed_service.h" |
10 #include "content/public/browser/browser_context.h" | 11 #include "content/public/browser/browser_context.h" |
11 | 12 |
12 namespace content { | 13 namespace content { |
13 class WebContents; | 14 class WebContents; |
14 } | 15 } |
15 | 16 |
16 class GURL; | 17 class GURL; |
| 18 class MidiPermissionRequest; |
17 class PermissionQueueController; | 19 class PermissionQueueController; |
18 class PermissionRequestID; | 20 class PermissionRequestID; |
19 class Profile; | 21 class Profile; |
20 | 22 |
21 // This class manages MIDI permissions flow. Used on the UI thread. | 23 // This class manages MIDI permissions flow. Used on the UI thread. |
22 class ChromeMidiPermissionContext : public KeyedService { | 24 class ChromeMidiPermissionContext : public KeyedService { |
23 public: | 25 public: |
24 explicit ChromeMidiPermissionContext(Profile* profile); | 26 explicit ChromeMidiPermissionContext(Profile* profile); |
25 virtual ~ChromeMidiPermissionContext(); | 27 virtual ~ChromeMidiPermissionContext(); |
26 | 28 |
(...skipping 18 matching lines...) Expand all Loading... |
45 // Called when the permission decision is made. If a permissions prompt is | 47 // Called when the permission decision is made. If a permissions prompt is |
46 // shown to the user it will be called when the user selects an option | 48 // shown to the user it will be called when the user selects an option |
47 // from that prompt. | 49 // from that prompt. |
48 void NotifyPermissionSet( | 50 void NotifyPermissionSet( |
49 const PermissionRequestID& id, | 51 const PermissionRequestID& id, |
50 const GURL& requesting_frame, | 52 const GURL& requesting_frame, |
51 const content::BrowserContext::MidiSysExPermissionCallback& callback, | 53 const content::BrowserContext::MidiSysExPermissionCallback& callback, |
52 bool allowed); | 54 bool allowed); |
53 | 55 |
54 private: | 56 private: |
| 57 friend class MidiPermissionRequest; |
| 58 |
55 // Decide whether the permission should be granted. | 59 // Decide whether the permission should be granted. |
56 // Calls PermissionDecided if permission can be decided non-interactively, | 60 // Calls PermissionDecided if permission can be decided non-interactively, |
57 // or NotifyPermissionSet if permission decided by presenting an infobar. | 61 // or NotifyPermissionSet if permission decided by presenting an infobar. |
58 void DecidePermission( | 62 void DecidePermission( |
59 content::WebContents* web_contents, | 63 content::WebContents* web_contents, |
60 const PermissionRequestID& id, | 64 const PermissionRequestID& id, |
61 const GURL& requesting_frame, | 65 const GURL& requesting_frame, |
62 const GURL& embedder, | 66 const GURL& embedder, |
63 bool user_gesture, | 67 bool user_gesture, |
64 const content::BrowserContext::MidiSysExPermissionCallback& callback); | 68 const content::BrowserContext::MidiSysExPermissionCallback& callback); |
65 | 69 |
66 // Called when permission is granted without interactively asking the user. | 70 // Called when permission is granted without interactively asking the user. |
67 void PermissionDecided( | 71 void PermissionDecided( |
68 const PermissionRequestID& id, | 72 const PermissionRequestID& id, |
69 const GURL& requesting_frame, | 73 const GURL& requesting_frame, |
70 const GURL& embedder, | 74 const GURL& embedder, |
71 const content::BrowserContext::MidiSysExPermissionCallback& callback, | 75 const content::BrowserContext::MidiSysExPermissionCallback& callback, |
72 bool allowed); | 76 bool allowed); |
73 | 77 |
74 // Return an instance of the infobar queue controller, creating it if needed. | 78 // Return an instance of the infobar queue controller, creating it if needed. |
75 PermissionQueueController* GetQueueController(); | 79 PermissionQueueController* GetQueueController(); |
76 | 80 |
77 // Removes any pending InfoBar request. | 81 // Removes any pending InfoBar request. |
78 void CancelPendingInfobarRequest(const PermissionRequestID& id); | 82 void CancelPendingInfobarRequest(const PermissionRequestID& id); |
79 | 83 |
| 84 // Notify the context that a particular request object is no longer needed. |
| 85 void RequestFinished(MidiPermissionRequest* request); |
| 86 |
80 Profile* const profile_; | 87 Profile* const profile_; |
81 bool shutting_down_; | 88 bool shutting_down_; |
82 scoped_ptr<PermissionQueueController> permission_queue_controller_; | 89 scoped_ptr<PermissionQueueController> permission_queue_controller_; |
83 | 90 |
| 91 base::ScopedPtrHashMap<std::string, MidiPermissionRequest> pending_requests_; |
| 92 |
84 DISALLOW_COPY_AND_ASSIGN(ChromeMidiPermissionContext); | 93 DISALLOW_COPY_AND_ASSIGN(ChromeMidiPermissionContext); |
85 }; | 94 }; |
86 | 95 |
87 #endif // CHROME_BROWSER_MEDIA_CHROME_MIDI_PERMISSION_CONTEXT_H_ | 96 #endif // CHROME_BROWSER_MEDIA_CHROME_MIDI_PERMISSION_CONTEXT_H_ |
OLD | NEW |