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

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

Issue 335993002: Convert MIDI permission requests to use WebContents in preparation for switching the code to using … (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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/containers/scoped_ptr_hash_map.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "components/keyed_service/core/keyed_service.h"
11 #include "content/public/browser/browser_context.h"
12
13 namespace content {
14 class WebContents;
15 }
16
17 class GURL;
18 class MidiPermissionRequest;
19 class PermissionQueueController;
20 class PermissionRequestID;
21 class Profile;
22
23 // This class manages MIDI permissions flow. Used on the UI thread.
24 class ChromeMidiPermissionContext : public KeyedService {
25 public:
26 explicit ChromeMidiPermissionContext(Profile* profile);
27 virtual ~ChromeMidiPermissionContext();
28
29 // KeyedService methods:
30 virtual void Shutdown() OVERRIDE;
31
32 // Request to ask users permission about MIDI.
33 void RequestMidiSysExPermission(
34 int render_process_id,
35 int render_view_id,
36 int bridge_id,
37 const GURL& requesting_frame,
38 bool user_gesture,
39 const content::BrowserContext::MidiSysExPermissionCallback& callback);
40
41 // Cancel a pending MIDI permission request.
42 void CancelMidiSysExPermissionRequest(int render_process_id,
43 int render_view_id,
44 int bridge_id,
45 const GURL& requesting_frame);
46
47 // Called when the permission decision is made. If a permissions prompt is
48 // shown to the user it will be called when the user selects an option
49 // from that prompt.
50 void NotifyPermissionSet(
51 const PermissionRequestID& id,
52 const GURL& requesting_frame,
53 const content::BrowserContext::MidiSysExPermissionCallback& callback,
54 bool allowed);
55
56 private:
57 friend class MidiPermissionRequest;
58
59 // Decide whether the permission should be granted.
60 // Calls PermissionDecided if permission can be decided non-interactively,
61 // or NotifyPermissionSet if permission decided by presenting an infobar.
62 void DecidePermission(
63 content::WebContents* web_contents,
64 const PermissionRequestID& id,
65 const GURL& requesting_frame,
66 const GURL& embedder,
67 bool user_gesture,
68 const content::BrowserContext::MidiSysExPermissionCallback& callback);
69
70 // Called when permission is granted without interactively asking the user.
71 void PermissionDecided(
72 const PermissionRequestID& id,
73 const GURL& requesting_frame,
74 const GURL& embedder,
75 const content::BrowserContext::MidiSysExPermissionCallback& callback,
76 bool allowed);
77
78 // Return an instance of the infobar queue controller, creating it if needed.
79 PermissionQueueController* GetQueueController();
80
81 // Removes any pending InfoBar request.
82 void CancelPendingInfobarRequest(const PermissionRequestID& id);
83
84 // Notify the context that a particular request object is no longer needed.
85 void RequestFinished(MidiPermissionRequest* request);
86
87 Profile* const profile_;
88 bool shutting_down_;
89 scoped_ptr<PermissionQueueController> permission_queue_controller_;
90
91 base::ScopedPtrHashMap<std::string, MidiPermissionRequest> pending_requests_;
92
93 DISALLOW_COPY_AND_ASSIGN(ChromeMidiPermissionContext);
94 };
95
96 #endif // CHROME_BROWSER_MEDIA_CHROME_MIDI_PERMISSION_CONTEXT_H_
OLDNEW
« no previous file with comments | « chrome/browser/chrome_content_browser_client.cc ('k') | chrome/browser/media/chrome_midi_permission_context.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698