Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(451)

Side by Side Diff: chrome/browser/media/chrome_midi_permission_context.h

Issue 20990005: Web MIDI: implement permission infobar (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review #5 Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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 private:
36 friend class base::RefCountedThreadSafe<ChromeMIDIPermissionContext>;
37
38 virtual ~ChromeMIDIPermissionContext();
39
40 // Return an instance of the infobar queue controller, creating it
41 // if necessary.
42 PermissionQueueController* GetQueueController();
43
44 // Called on the UI thread when the permission decision is made. It may be by
45 // the InfoBarDelegate to notify permission has been set.
46 void NotifyPermissionSet(
47 const PermissionRequestID& id,
48 const GURL& requesting_frame,
49 const content::BrowserContext::MIDISysExPermissionCallback& callback,
50 bool allowed);
51
52 // Decide whether the permission should be granted.
53 // Calls PermissionDecided if permission can be decided non-interactively,
54 // or NotifyPermissionSet if permission decided by presenting an infobar.
55 // Called on the UI thread.
56 void DecidePermission(
57 const PermissionRequestID& id,
58 const GURL& requesting_frame,
59 const GURL& embedder,
60 const content::BrowserContext::MIDISysExPermissionCallback& callback);
61
62 // Called when permission is granted without interactively asking the user.
63 // Called on the UI thread.
64 void PermissionDecided(
65 const PermissionRequestID& id,
66 const GURL& requesting_frame,
67 const GURL& embedder,
68 const content::BrowserContext::MIDISysExPermissionCallback& callback,
69 bool allowed);
70
71 // Create an PermissionQueueController. Called on the UI thread.
72 PermissionQueueController* CreateQueueController();
73
74 Profile* const profile_;
75 bool shutting_down_;
76 scoped_ptr<PermissionQueueController> permission_queue_controller_;
77 };
78
79 #endif // CHROME_BROWSER_MEDIA_CHROME_MIDI_PERMISSION_CONTEXT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698