| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_MEDIA_CAPTURE_DEVICES_DISPATCHER_H_ | 5 #ifndef CHROME_BROWSER_MEDIA_MEDIA_CAPTURE_DEVICES_DISPATCHER_H_ |
| 6 #define CHROME_BROWSER_MEDIA_MEDIA_CAPTURE_DEVICES_DISPATCHER_H_ | 6 #define CHROME_BROWSER_MEDIA_MEDIA_CAPTURE_DEVICES_DISPATCHER_H_ |
| 7 | 7 |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/memory/singleton.h" | 10 #include "base/memory/singleton.h" |
| 11 #include "base/observer_list.h" | 11 #include "base/observer_list.h" |
| 12 #include "content/public/browser/media_observer.h" | 12 #include "content/public/browser/media_observer.h" |
| 13 #include "content/public/common/media_stream_request.h" | 13 #include "content/public/common/media_stream_request.h" |
| 14 | 14 |
| 15 class MediaStreamCaptureIndicator; | 15 class MediaStreamCaptureIndicator; |
| 16 class PrefServiceSyncable; | 16 class PrefRegistrySyncable; |
| 17 class PrefService; |
| 17 class Profile; | 18 class Profile; |
| 18 | 19 |
| 19 // This singleton is used to receive updates about media events from the content | 20 // This singleton is used to receive updates about media events from the content |
| 20 // layer. | 21 // layer. |
| 21 class MediaCaptureDevicesDispatcher : public content::MediaObserver { | 22 class MediaCaptureDevicesDispatcher : public content::MediaObserver { |
| 22 public: | 23 public: |
| 23 class Observer { | 24 class Observer { |
| 24 public: | 25 public: |
| 25 // Handle an information update consisting of a up-to-date audio capture | 26 // Handle an information update consisting of a up-to-date audio capture |
| 26 // device lists. This happens when a microphone is plugged in or unplugged. | 27 // device lists. This happens when a microphone is plugged in or unplugged. |
| (...skipping 11 matching lines...) Expand all Loading... |
| 38 int render_view_id, | 39 int render_view_id, |
| 39 const content::MediaStreamDevice& device, | 40 const content::MediaStreamDevice& device, |
| 40 const content::MediaRequestState state) {} | 41 const content::MediaRequestState state) {} |
| 41 | 42 |
| 42 virtual ~Observer() {} | 43 virtual ~Observer() {} |
| 43 }; | 44 }; |
| 44 | 45 |
| 45 static MediaCaptureDevicesDispatcher* GetInstance(); | 46 static MediaCaptureDevicesDispatcher* GetInstance(); |
| 46 | 47 |
| 47 // Registers the preferences related to Media Stream default devices. | 48 // Registers the preferences related to Media Stream default devices. |
| 48 static void RegisterUserPrefs(PrefServiceSyncable* user_prefs); | 49 static void RegisterUserPrefs(PrefService* user_prefs, |
| 50 PrefRegistrySyncable* registry); |
| 49 | 51 |
| 50 // Methods for observers. Called on UI thread. | 52 // Methods for observers. Called on UI thread. |
| 51 // Observers should add themselves on construction and remove themselves | 53 // Observers should add themselves on construction and remove themselves |
| 52 // on destruction. | 54 // on destruction. |
| 53 void AddObserver(Observer* observer); | 55 void AddObserver(Observer* observer); |
| 54 void RemoveObserver(Observer* observer); | 56 void RemoveObserver(Observer* observer); |
| 55 const content::MediaStreamDevices& GetAudioCaptureDevices(); | 57 const content::MediaStreamDevices& GetAudioCaptureDevices(); |
| 56 const content::MediaStreamDevices& GetVideoCaptureDevices(); | 58 const content::MediaStreamDevices& GetVideoCaptureDevices(); |
| 57 | 59 |
| 58 // Helper to get the default devices which can be used by the media request, | 60 // Helper to get the default devices which can be used by the media request, |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 ObserverList<Observer> observers_; | 121 ObserverList<Observer> observers_; |
| 120 | 122 |
| 121 // Flag to indicate if device enumeration has been done/doing. | 123 // Flag to indicate if device enumeration has been done/doing. |
| 122 // Only accessed on UI thread. | 124 // Only accessed on UI thread. |
| 123 bool devices_enumerated_; | 125 bool devices_enumerated_; |
| 124 | 126 |
| 125 scoped_refptr<MediaStreamCaptureIndicator> media_stream_capture_indicator_; | 127 scoped_refptr<MediaStreamCaptureIndicator> media_stream_capture_indicator_; |
| 126 }; | 128 }; |
| 127 | 129 |
| 128 #endif // CHROME_BROWSER_MEDIA_MEDIA_CAPTURE_DEVICES_DISPATCHER_H_ | 130 #endif // CHROME_BROWSER_MEDIA_MEDIA_CAPTURE_DEVICES_DISPATCHER_H_ |
| OLD | NEW |