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

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

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

Powered by Google App Engine
This is Rietveld 408576698