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