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

Unified Diff: chrome/browser/media/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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/media/midi_permission_context.h
diff --git a/chrome/browser/media/chrome_midi_permission_context.h b/chrome/browser/media/midi_permission_context.h
similarity index 72%
rename from chrome/browser/media/chrome_midi_permission_context.h
rename to chrome/browser/media/midi_permission_context.h
index 9417523147aefcf45f03c40b72e4a5116a033e6f..8d65772059aaf3b6d7b2cf81e0aa5b3b670862e2 100644
--- a/chrome/browser/media/chrome_midi_permission_context.h
+++ b/chrome/browser/media/midi_permission_context.h
@@ -2,13 +2,13 @@
// 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_
+#ifndef CHROME_BROWSER_MEDIA_MIDI_PERMISSION_CONTEXT_H_
+#define CHROME_BROWSER_MEDIA_MIDI_PERMISSION_CONTEXT_H_
#include "base/containers/scoped_ptr_hash_map.h"
#include "base/memory/scoped_ptr.h"
+#include "base/memory/weak_ptr.h"
#include "components/keyed_service/core/keyed_service.h"
-#include "content/public/browser/browser_context.h"
namespace content {
class WebContents;
@@ -21,28 +21,22 @@ class PermissionRequestID;
class Profile;
// This class manages MIDI permissions flow. Used on the UI thread.
-class ChromeMidiPermissionContext : public KeyedService {
+class MidiPermissionContext : public KeyedService {
public:
- explicit ChromeMidiPermissionContext(Profile* profile);
- virtual ~ChromeMidiPermissionContext();
+ explicit MidiPermissionContext(Profile* profile);
+ virtual ~MidiPermissionContext();
// KeyedService methods:
virtual void Shutdown() OVERRIDE;
// Request to ask users permission about MIDI.
void RequestMidiSysExPermission(
- int render_process_id,
- int render_view_id,
+ content::WebContents* web_contents,
int bridge_id,
const GURL& requesting_frame,
bool user_gesture,
- const content::BrowserContext::MidiSysExPermissionCallback& callback);
-
- // Cancel a pending MIDI permission request.
- void CancelMidiSysExPermissionRequest(int render_process_id,
- int render_view_id,
- int bridge_id,
- const GURL& requesting_frame);
+ const base::Callback<void(bool)>& result_callback,
+ base::Closure* cancel_callback);
// Called when the permission decision is made. If a permissions prompt is
// shown to the user it will be called when the user selects an option
@@ -50,12 +44,17 @@ class ChromeMidiPermissionContext : public KeyedService {
void NotifyPermissionSet(
const PermissionRequestID& id,
const GURL& requesting_frame,
- const content::BrowserContext::MidiSysExPermissionCallback& callback,
+ const base::Callback<void(bool)>& callback,
bool allowed);
private:
friend class MidiPermissionRequest;
+ // Cancel a pending MIDI permission request.
+ void CancelMidiSysExPermissionRequest(int render_process_id,
+ int render_view_id,
+ int bridge_id);
+
// 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.
@@ -65,14 +64,14 @@ class ChromeMidiPermissionContext : public KeyedService {
const GURL& requesting_frame,
const GURL& embedder,
bool user_gesture,
- const content::BrowserContext::MidiSysExPermissionCallback& callback);
+ const base::Callback<void(bool)>& callback);
// Called when permission is granted without interactively asking the user.
void PermissionDecided(
const PermissionRequestID& id,
const GURL& requesting_frame,
const GURL& embedder,
- const content::BrowserContext::MidiSysExPermissionCallback& callback,
+ const base::Callback<void(bool)>& callback,
bool allowed);
// Return an instance of the infobar queue controller, creating it if needed.
@@ -90,7 +89,9 @@ class ChromeMidiPermissionContext : public KeyedService {
base::ScopedPtrHashMap<std::string, MidiPermissionRequest> pending_requests_;
- DISALLOW_COPY_AND_ASSIGN(ChromeMidiPermissionContext);
+ base::WeakPtrFactory<MidiPermissionContext> weak_factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(MidiPermissionContext);
};
-#endif // CHROME_BROWSER_MEDIA_CHROME_MIDI_PERMISSION_CONTEXT_H_
+#endif // CHROME_BROWSER_MEDIA_MIDI_PERMISSION_CONTEXT_H_
« no previous file with comments | « chrome/browser/media/chrome_midi_permission_context_factory.cc ('k') | chrome/browser/media/midi_permission_context.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698