Index: chrome/browser/media/media_stream_devices_controller.h |
diff --git a/chrome/browser/media/media_stream_devices_controller.h b/chrome/browser/media/media_stream_devices_controller.h |
index ab77eaad304993b8f9f4850915f03243d81e999b..f97cc0e13d23077c783581060925ceec1c35f40d 100644 |
--- a/chrome/browser/media/media_stream_devices_controller.h |
+++ b/chrome/browser/media/media_stream_devices_controller.h |
@@ -9,7 +9,6 @@ |
#include "content/public/browser/web_contents_delegate.h" |
-class GURL; |
class Profile; |
class MediaStreamDevicesController { |
@@ -29,26 +28,37 @@ class MediaStreamDevicesController { |
// Public methods to be called by MediaStreamInfoBarDelegate; |
bool has_audio() const { return has_audio_; } |
bool has_video() const { return has_video_; } |
+ const std::string& GetSecurityOriginSpec() const; |
content::MediaStreamDevices GetAudioDevices() const; |
content::MediaStreamDevices GetVideoDevices() const; |
- const GURL& GetSecurityOrigin() const; |
+ bool IsSafeToAlwaysAllowAudio() const; |
+ bool IsSafeToAlwaysAllowVideo() const; |
void Accept(const std::string& audio_id, |
const std::string& video_id, |
bool always_allow); |
void Deny(); |
private: |
- // Finds a device in the current request with the specified |id| and |type|, |
- // adds it to the |devices| array and also return the name of the device. |
- void AddDeviceWithId(content::MediaStreamDeviceType type, |
- const std::string& id, |
- content::MediaStreamDevices* devices, |
- std::string* device_name); |
+ // Used by the various helper methods below to filter an operation on devices |
+ // of a particular type. |
+ typedef bool (*FilterByDeviceTypeFunc)(content::MediaStreamDeviceType); |
+ |
+ // Returns true if a secure scheme is being used by the origin AND only |
+ // devices of the given physical |device_type| are present in the subset of |
+ // devices selected by the |is_included| function. |
+ bool IsSafeToAlwaysAllow(FilterByDeviceTypeFunc is_included, |
+ content::MediaStreamDeviceType device_type) const; |
// Returns true if the media section in content settings is set to |
// |CONTENT_SETTING_BLOCK|, otherwise returns false. |
bool IsMediaDeviceBlocked(); |
+ // NOTE on AlwaysAllowOrigin functionality: The rules only apply to physical |
+ // capture devices, and not tab mirroring (or other "virtual device" types). |
+ // Virtual devices are always denied an AlwaysAllowOrigin status because they |
+ // refer to internal objects whose "IDs" might be re-used for different |
+ // objects across browser sessions. |
+ |
// Returns true if request's origin is from internal objects like |
// chrome://URLs, otherwise returns false. |
bool ShouldAlwaysAllowOrigin(); |
@@ -69,6 +79,17 @@ class MediaStreamDevicesController { |
std::string GetFirstDeviceId(content::MediaStreamDeviceType type); |
+ // Copies all devices passing the |is_included| predicate to the given output |
+ // container. |
+ void FindSubsetOfDevices(FilterByDeviceTypeFunc is_included, |
+ content::MediaStreamDevices* out) const; |
+ |
+ // Finds the first device with the given |device_id| within the subset of |
+ // devices passing the |is_included| predicate, or return NULL. |
+ const content::MediaStreamDevice* FindFirstDeviceWithIdInSubset( |
+ FilterByDeviceTypeFunc is_included, |
+ const std::string& device_id) const; |
+ |
bool has_audio_; |
bool has_video_; |