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

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

Issue 38043004: Cancel MIDI permission request infobar on MIDIAccess stop. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 2 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
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_CHROME_MIDI_PERMISSION_CONTEXT_H_ 5 #ifndef CHROME_BROWSER_MEDIA_CHROME_MIDI_PERMISSION_CONTEXT_H_
6 #define CHROME_BROWSER_MEDIA_CHROME_MIDI_PERMISSION_CONTEXT_H_ 6 #define CHROME_BROWSER_MEDIA_CHROME_MIDI_PERMISSION_CONTEXT_H_
7 7
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "components/browser_context_keyed_service/browser_context_keyed_service .h" 9 #include "components/browser_context_keyed_service/browser_context_keyed_service .h"
10 #include "content/public/browser/browser_context.h" 10 #include "content/public/browser/browser_context.h"
11 #include "content/public/browser/midi_permission_context.h"
11 12
12 class GURL; 13 class GURL;
13 class PermissionQueueController; 14 class PermissionQueueController;
14 class PermissionRequestID; 15 class PermissionRequestID;
15 class Profile; 16 class Profile;
16 17
17 // This class manages MIDI permissions flow. Used on the UI thread. 18 // This class manages MIDI permissions flow. Used on the UI thread.
18 class ChromeMIDIPermissionContext : public BrowserContextKeyedService { 19 class ChromeMIDIPermissionContext : public content::MidiPermissionContext {
19 public: 20 public:
20 explicit ChromeMIDIPermissionContext(Profile* profile); 21 explicit ChromeMIDIPermissionContext(Profile* profile);
21 virtual ~ChromeMIDIPermissionContext(); 22 virtual ~ChromeMIDIPermissionContext();
22 23
23 // BrowserContextKeyedService methods:
24 virtual void Shutdown() OVERRIDE;
25
26 // Request to ask users permission about MIDI. 24 // Request to ask users permission about MIDI.
jam 2013/10/24 16:15:26 nit: just put content::MidiPermissionContext imple
Kibeom Kim (inactive) 2013/10/24 19:36:26 Done.
27 void RequestMIDISysExPermission( 25 void RequestMIDISysExPermission(
28 int render_process_id, 26 int render_process_id,
29 int render_view_id, 27 int render_view_id,
28 int bridge_id,
30 const GURL& requesting_frame, 29 const GURL& requesting_frame,
31 const content::BrowserContext::MIDISysExPermissionCallback& callback); 30 const content::MIDISysExPermissionCallback& callback)
31 OVERRIDE;
jam 2013/10/24 16:15:26 nit: override doesn't start a line per convention,
Kibeom Kim (inactive) 2013/10/24 19:36:26 Done.
32
33 // The renderer is cancelling a pending permission request.
34 virtual void CancelMIDISysExPermissionRequest(
Bernhard Bauer 2013/10/24 07:42:04 Nit: at the beginning of a block of virtual method
Kibeom Kim (inactive) 2013/10/24 19:36:26 Done.
35 int render_process_id,
36 int render_view_id,
37 int bridge_id,
38 const GURL& requesting_frame) OVERRIDE;
39
40 // Called on the UI thread when the profile is about to be destroyed.
41 void ShutdownOnUIThread();
32 42
33 private: 43 private:
34 // Decide whether the permission should be granted. 44 // Decide whether the permission should be granted.
35 // Calls PermissionDecided if permission can be decided non-interactively, 45 // Calls PermissionDecided if permission can be decided non-interactively,
36 // or NotifyPermissionSet if permission decided by presenting an infobar. 46 // or NotifyPermissionSet if permission decided by presenting an infobar.
37 void DecidePermission( 47 void DecidePermission(
38 const PermissionRequestID& id, 48 const PermissionRequestID& id,
39 const GURL& requesting_frame, 49 const GURL& requesting_frame,
40 const GURL& embedder, 50 const GURL& embedder,
41 const content::BrowserContext::MIDISysExPermissionCallback& callback); 51 const content::MIDISysExPermissionCallback& callback);
42 52
43 // Called when permission is granted without interactively asking the user. 53 // Called when permission is granted without interactively asking the user.
44 void PermissionDecided( 54 void PermissionDecided(
45 const PermissionRequestID& id, 55 const PermissionRequestID& id,
46 const GURL& requesting_frame, 56 const GURL& requesting_frame,
47 const GURL& embedder, 57 const GURL& embedder,
48 const content::BrowserContext::MIDISysExPermissionCallback& callback, 58 const content::MIDISysExPermissionCallback& callback,
49 bool allowed); 59 bool allowed);
50 60
51 // Called when the permission decision is made. It may be by the 61 // Called when the permission decision is made. It may be by the
52 // InfoBarDelegate to notify permission has been set. 62 // InfoBarDelegate to notify permission has been set.
53 void NotifyPermissionSet( 63 void NotifyPermissionSet(
54 const PermissionRequestID& id, 64 const PermissionRequestID& id,
55 const GURL& requesting_frame, 65 const GURL& requesting_frame,
56 const content::BrowserContext::MIDISysExPermissionCallback& callback, 66 const content::MIDISysExPermissionCallback& callback,
57 bool allowed); 67 bool allowed);
58 68
59 // Return an instance of the infobar queue controller, creating it if needed. 69 // Return an instance of the infobar queue controller, creating it if needed.
60 PermissionQueueController* GetQueueController(); 70 PermissionQueueController* GetQueueController();
61 71
72 // Removes any pending InfoBar request.
73 void CancelPendingInfoBarRequest(const PermissionRequestID& id);
74
62 Profile* const profile_; 75 Profile* const profile_;
63 bool shutting_down_; 76 bool shutting_down_;
64 scoped_ptr<PermissionQueueController> permission_queue_controller_; 77 scoped_ptr<PermissionQueueController> permission_queue_controller_;
65 78
66 DISALLOW_COPY_AND_ASSIGN(ChromeMIDIPermissionContext); 79 DISALLOW_COPY_AND_ASSIGN(ChromeMIDIPermissionContext);
67 }; 80 };
68 81
69 #endif // CHROME_BROWSER_MEDIA_CHROME_MIDI_PERMISSION_CONTEXT_H_ 82 #endif // CHROME_BROWSER_MEDIA_CHROME_MIDI_PERMISSION_CONTEXT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698