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

Unified Diff: chrome/browser/media/media_capture_devices_dispatcher.h

Issue 1095393004: Refactor: Make MediaCaptureDevicesDispatcher have pluggable handlers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase and address review comments of ps#2 Created 5 years, 7 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/media_capture_devices_dispatcher.h
diff --git a/chrome/browser/media/media_capture_devices_dispatcher.h b/chrome/browser/media/media_capture_devices_dispatcher.h
index 8c2855577f4261b870e6fdab9bf079b8044f2c4e..e24b1eeaa1bdf72a761ee0bdf39ef39ef5fc726f 100644
--- a/chrome/browser/media/media_capture_devices_dispatcher.h
+++ b/chrome/browser/media/media_capture_devices_dispatcher.h
@@ -11,11 +11,12 @@
#include "base/callback.h"
#include "base/memory/scoped_ptr.h"
+#include "base/memory/scoped_vector.h"
#include "base/memory/singleton.h"
#include "base/observer_list.h"
+#include "chrome/browser/media/media_access_handler.h"
Sergey Ulanov 2015/06/01 23:39:18 You can forward-declare MediaAccessHandler. Don't
changbin 2015/06/02 14:20:09 Done.
+#include "chrome/browser/media/permission_bubble_media_access_handler.h"
Sergey Ulanov 2015/06/01 23:39:18 Don't need this.
#include "content/public/browser/media_observer.h"
-#include "content/public/browser/notification_observer.h"
-#include "content/public/browser/notification_registrar.h"
#include "content/public/browser/web_contents_delegate.h"
#include "content/public/common/media_stream_request.h"
@@ -33,8 +34,7 @@ class PrefRegistrySyncable;
// This singleton is used to receive updates about media events from the content
// layer.
-class MediaCaptureDevicesDispatcher : public content::MediaObserver,
- public content::NotificationObserver {
+class MediaCaptureDevicesDispatcher : public content::MediaObserver {
public:
class Observer {
public:
@@ -91,12 +91,10 @@ class MediaCaptureDevicesDispatcher : public content::MediaObserver,
content::MediaStreamType type);
// Same as above but for an |extension|, which may not be NULL.
-#if defined(ENABLE_EXTENSIONS)
bool CheckMediaAccessPermission(content::WebContents* web_contents,
const GURL& security_origin,
content::MediaStreamType type,
const extensions::Extension* extension);
-#endif
// Helper to get the default devices which can be used by the media request.
// Uses the first available devices if the default devices are not available.
@@ -150,60 +148,9 @@ class MediaCaptureDevicesDispatcher : public content::MediaObserver,
private:
friend struct DefaultSingletonTraits<MediaCaptureDevicesDispatcher>;
- struct PendingAccessRequest {
- PendingAccessRequest(const content::MediaStreamRequest& request,
- const content::MediaResponseCallback& callback);
- ~PendingAccessRequest();
-
- // TODO(gbillock): make the MediaStreamDevicesController owned by
- // this object when we're using bubbles.
- content::MediaStreamRequest request;
- content::MediaResponseCallback callback;
- };
- typedef std::deque<PendingAccessRequest> RequestsQueue;
- typedef std::map<content::WebContents*, RequestsQueue> RequestsQueues;
-
MediaCaptureDevicesDispatcher();
~MediaCaptureDevicesDispatcher() override;
- // content::NotificationObserver implementation.
- void Observe(int type,
- const content::NotificationSource& source,
- const content::NotificationDetails& details) override;
-
- // Helpers for ProcessMediaAccessRequest().
- void ProcessDesktopCaptureAccessRequest(
- content::WebContents* web_contents,
- const content::MediaStreamRequest& request,
- const content::MediaResponseCallback& callback,
- const extensions::Extension* extension);
- void ProcessScreenCaptureAccessRequest(
- content::WebContents* web_contents,
- const content::MediaStreamRequest& request,
- const content::MediaResponseCallback& callback,
- const extensions::Extension* extension);
- void ProcessTabCaptureAccessRequest(
- content::WebContents* web_contents,
- const content::MediaStreamRequest& request,
- const content::MediaResponseCallback& callback,
- const extensions::Extension* extension);
-#if defined(ENABLE_EXTENSIONS)
- void ProcessMediaAccessRequestFromPlatformAppOrExtension(
- content::WebContents* web_contents,
- const content::MediaStreamRequest& request,
- const content::MediaResponseCallback& callback,
- const extensions::Extension* extension);
-#endif
- void ProcessRegularMediaAccessRequest(
- content::WebContents* web_contents,
- const content::MediaStreamRequest& request,
- const content::MediaResponseCallback& callback);
- void ProcessQueuedAccessRequest(content::WebContents* web_contents);
- void OnAccessRequestResponse(content::WebContents* web_contents,
- const content::MediaStreamDevices& devices,
- content::MediaStreamRequestResult result,
- scoped_ptr<content::MediaStreamUI> ui);
-
// Called by the MediaObserver() functions, executed on UI thread.
void NotifyAudioDevicesChangedOnUIThread();
void NotifyVideoDevicesChangedOnUIThread();
@@ -229,24 +176,12 @@ class MediaCaptureDevicesDispatcher : public content::MediaObserver,
// Flag used by unittests to disable device enumeration.
bool is_device_enumeration_disabled_;
- RequestsQueues pending_requests_;
-
scoped_refptr<MediaStreamCaptureIndicator> media_stream_capture_indicator_;
scoped_ptr<DesktopStreamsRegistry> desktop_streams_registry_;
- content::NotificationRegistrar notifications_registrar_;
-
- // Tracks MEDIA_DESKTOP_VIDEO_CAPTURE sessions which reach the
- // MEDIA_REQUEST_STATE_DONE state. Sessions are remove when
- // MEDIA_REQUEST_STATE_CLOSING is encountered.
- struct DesktopCaptureSession {
- int render_process_id;
- int render_frame_id;
- int page_request_id;
- };
- typedef std::list<DesktopCaptureSession> DesktopCaptureSessions;
- DesktopCaptureSessions desktop_capture_sessions_;
+ // Handlers for processing media access requests.
+ ScopedVector<MediaAccessHandler> media_access_handlers_;
DISALLOW_COPY_AND_ASSIGN(MediaCaptureDevicesDispatcher);
};

Powered by Google App Engine
This is Rietveld 408576698