Index: chrome/browser/media/chrome_midi_permission_context.h |
diff --git a/chrome/browser/media/chrome_midi_permission_context.h b/chrome/browser/media/chrome_midi_permission_context.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..46a887718cc1f348345f431f6fab382292c67ab8 |
--- /dev/null |
+++ b/chrome/browser/media/chrome_midi_permission_context.h |
@@ -0,0 +1,82 @@ |
+// Copyright 2013 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef CHROME_BROWSER_MEDIA_CHROME_MIDI_PERMISSION_CONTEXT_H_ |
+#define CHROME_BROWSER_MEDIA_CHROME_MIDI_PERMISSION_CONTEXT_H_ |
+ |
+#include "base/callback.h" |
+#include "base/memory/ref_counted.h" |
+#include "base/memory/scoped_ptr.h" |
+#include "chrome/browser/content_settings/permission_queue_controller.h" |
+#include "content/public/browser/browser_context.h" |
+ |
+class GURL; |
+class PermissionRequestID; |
+class Profile; |
+ |
+// Chrome specific implementation of MIDIPermissionContext; manages MIDI |
Bernhard Bauer
2013/07/31 15:35:39
What's MIDIPermissionContext? It's not a superclas
Takashi Toyoshima
2013/08/01 07:43:09
Oops. Sorry, this should be removed at cleanup.
Or
|
+// permissions flow, and delegates UI handling. |
+class ChromeMIDIPermissionContext |
+ : public base::RefCountedThreadSafe<ChromeMIDIPermissionContext> { |
Bernhard Bauer
2013/07/31 15:35:39
Why is this class refcounted thread safe?
Takashi Toyoshima
2013/08/01 07:43:09
As we commented in the cc file, this class is used
|
+ public: |
+ explicit ChromeMIDIPermissionContext(Profile* profile); |
+ |
+ void RequestMIDISysExPermission( |
+ int render_process_id, |
+ int render_view_id, |
+ const GURL& requesting_frame, |
+ const content::BrowserContext::MIDISysExPermissionCallback& callback); |
+ |
+ // Called on the UI thread when the profile is about to be destroyed. |
+ void ShutdownOnUIThread(); |
+ |
+ protected: |
+ virtual ~ChromeMIDIPermissionContext(); |
Bernhard Bauer
2013/07/31 15:35:39
Is this class subclassed?
Takashi Toyoshima
2013/08/01 07:43:09
Yes for RefCounted.
Bernhard Bauer
2013/08/01 08:21:27
?
Oh, my question might have been worded ambiguou
Takashi Toyoshima
2013/08/01 09:29:45
Ah, I see. I misunderstood your question.
Done.
|
+ |
+ private: |
+ Profile* profile() const { return profile_; } |
Bernhard Bauer
2013/07/31 15:35:39
Do you really need a private accessor? :)
Takashi Toyoshima
2013/08/01 07:43:09
Good point. I remove this to use it directly :)
|
+ |
+ // Return an instance of the infobar queue controller, creating it |
+ // if necessary. |
+ PermissionQueueController* QueueController(); |
Bernhard Bauer
2013/07/31 15:35:39
Nit: GetQueueController() maybe?
Takashi Toyoshima
2013/08/01 07:43:09
Done.
|
+ |
+ // Called on the UI thread when the permission decision is made. It may be by |
+ // the InfoBarDelegate to notify permission has been set. |
+ void NotifyPermissionSet( |
+ const PermissionRequestID& id, |
+ const GURL& requesting_frame, |
+ const content::BrowserContext::MIDISysExPermissionCallback& callback, |
+ bool allowed); |
+ |
+ // Decide whether the permission should be granted. |
+ // Calls PermissionDecided if permission can be decided non-interactively, |
+ // or NotifyPermissionSet if permission decided by presenting an infobar. |
+ // Called on the UI thread. |
+ void DecidePermission( |
+ const PermissionRequestID& id, |
+ const GURL& requesting_frame, |
+ const GURL& embedder, |
+ const content::BrowserContext::MIDISysExPermissionCallback& callback); |
+ |
+ // Called when permission is granted without interactively asking the user. |
+ // Called on the UI thread. |
+ void PermissionDecided( |
+ const PermissionRequestID& id, |
+ const GURL& requesting_frame, |
+ const GURL& embedder, |
+ const content::BrowserContext::MIDISysExPermissionCallback& callback, |
+ bool allowed); |
+ |
+ // Create an PermissionQueueController. overriden in derived classes to |
Bernhard Bauer
2013/07/31 15:35:39
Nit: "Overridden". Also, are these derived classes
Takashi Toyoshima
2013/08/01 07:43:09
Oops. This also may not happen now, so I'll remove
|
+ // provide additional UI flow. Called on the UI thread. |
+ virtual PermissionQueueController* CreateQueueController(); |
+ |
+ Profile* const profile_; |
+ bool shutting_down_; |
+ scoped_ptr<PermissionQueueController> permission_queue_controller_; |
+ |
+ friend class base::RefCountedThreadSafe<ChromeMIDIPermissionContext>; |
Bernhard Bauer
2013/07/31 15:35:39
Friend declarations come first in the private part
Takashi Toyoshima
2013/08/01 07:43:09
Done.
|
+}; |
+ |
+#endif // CHROME_BROWSER_MEDIA_CHROME_MIDI_PERMISSION_CONTEXT_H_ |