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

Unified Diff: content/browser/renderer_host/media/media_stream_manager.cc

Issue 11446042: Make sure that all OpenDevice requests are scrutinized against the audio and video policies. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Moved RequestType according to Shijing's proposal. Created 8 years 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: content/browser/renderer_host/media/media_stream_manager.cc
diff --git a/content/browser/renderer_host/media/media_stream_manager.cc b/content/browser/renderer_host/media/media_stream_manager.cc
index 864e999d0b32e429081450bfa194e1ad953f465b..e0dee03d52a226cf682915df73a54fba64ddc470 100644
--- a/content/browser/renderer_host/media/media_stream_manager.cc
+++ b/content/browser/renderer_host/media/media_stream_manager.cc
@@ -64,13 +64,6 @@ static bool Requested(const StreamOptions& options,
// TODO(xians): Merge DeviceRequest with MediaStreamRequest.
class MediaStreamManager::DeviceRequest {
public:
- enum RequestType {
- DEVICE_ACCESS = 0,
- GENERATE_STREAM,
- ENUMERATE_DEVICES,
- OPEN_DEVICE
- };
-
DeviceRequest()
: requester(NULL),
type(GENERATE_STREAM),
@@ -81,7 +74,7 @@ class MediaStreamManager::DeviceRequest {
DeviceRequest(MediaStreamRequester* requester,
const StreamOptions& request_options,
- RequestType request_type,
+ MediaStreamRequestType request_type,
int render_process_id,
int render_view_id,
const GURL& request_security_origin)
@@ -128,7 +121,7 @@ class MediaStreamManager::DeviceRequest {
MediaStreamRequester* requester; // Can be NULL.
StreamOptions options;
- RequestType type;
+ MediaStreamRequestType type;
int render_process_id;
int render_view_id;
GURL security_origin;
@@ -201,7 +194,7 @@ std::string MediaStreamManager::MakeMediaAccessRequest(
// Create a new request based on options.
DeviceRequest* request = new DeviceRequest(NULL,
options,
- DeviceRequest::DEVICE_ACCESS,
+ DEVICE_ACCESS,
render_process_id,
render_view_id,
security_origin);
@@ -229,7 +222,7 @@ std::string MediaStreamManager::GenerateStream(
// Create a new request based on options.
DeviceRequest* request = new DeviceRequest(requester, options,
- DeviceRequest::GENERATE_STREAM,
+ GENERATE_STREAM,
render_process_id,
render_view_id,
security_origin);
@@ -250,7 +243,7 @@ std::string MediaStreamManager::GenerateStreamForDevice(
// Create a new request based on options.
DeviceRequest* request = new DeviceRequest(requester, options,
- DeviceRequest::GENERATE_STREAM,
+ GENERATE_STREAM,
render_process_id,
render_view_id,
security_origin);
@@ -337,7 +330,7 @@ void MediaStreamManager::StopGeneratedStream(const std::string& label) {
// Find the request and close all open devices for the request.
DeviceRequests::iterator it = requests_.find(label);
if (it != requests_.end()) {
- if (it->second->type == DeviceRequest::ENUMERATE_DEVICES) {
+ if (it->second->type == ENUMERATE_DEVICES) {
StopEnumerateDevices(label);
return;
}
@@ -349,7 +342,7 @@ void MediaStreamManager::StopGeneratedStream(const std::string& label) {
device_it != request->devices.end(); ++device_it) {
GetDeviceManager(device_it->stream_type)->Close(device_it->session_id);
}
- if (request->type == DeviceRequest::GENERATE_STREAM &&
+ if (request->type == GENERATE_STREAM &&
RequestDone(*request)) {
// Notify observers that this device is being closed.
for (int i = MEDIA_NO_SERVICE + 1; i != NUM_MEDIA_TYPES; ++i) {
@@ -402,7 +395,7 @@ std::string MediaStreamManager::EnumerateDevices(
DeviceRequest* request = new DeviceRequest(requester,
options,
- DeviceRequest::ENUMERATE_DEVICES,
+ ENUMERATE_DEVICES,
render_process_id,
render_view_id,
security_origin);
@@ -430,7 +423,7 @@ void MediaStreamManager::StopEnumerateDevices(const std::string& label) {
DeviceRequests::iterator it = requests_.find(label);
if (it != requests_.end()) {
- DCHECK_EQ(it->second->type, DeviceRequest::ENUMERATE_DEVICES);
+ DCHECK_EQ(it->second->type, ENUMERATE_DEVICES);
// Delete the DeviceRequest.
scoped_ptr<DeviceRequest> request(it->second);
requests_.erase(it);
@@ -461,7 +454,7 @@ std::string MediaStreamManager::OpenDevice(
DeviceRequest* request = new DeviceRequest(requester,
options,
- DeviceRequest::OPEN_DEVICE,
+ OPEN_DEVICE,
render_process_id,
render_view_id,
security_origin);
@@ -469,6 +462,8 @@ std::string MediaStreamManager::OpenDevice(
const std::string& label = AddRequest(request);
StartEnumeration(request);
+ PostRequestToUI(label);
+
return label;
}
@@ -590,7 +585,8 @@ void MediaStreamManager::PostRequestToUI(const std::string& label) {
request->render_process_id,
request->render_view_id,
request->options,
- request->security_origin);
+ request->security_origin,
+ request->type);
}
void MediaStreamManager::InitializeDeviceManagersOnIOThread() {
@@ -668,10 +664,10 @@ void MediaStreamManager::Opened(MediaStreamType stream_type,
}
switch (request->type) {
- case DeviceRequest::OPEN_DEVICE:
+ case OPEN_DEVICE:
request->requester->DeviceOpened(label, devices->front());
break;
- case DeviceRequest::GENERATE_STREAM: {
+ case GENERATE_STREAM: {
// Partition the array of devices into audio vs video.
StreamDeviceInfoArray audio_devices, video_devices;
for (StreamDeviceInfoArray::const_iterator device_it = devices->begin();
@@ -730,7 +726,7 @@ void MediaStreamManager::DevicesEnumerated(
if (it->second->getState(stream_type) ==
MEDIA_REQUEST_STATE_REQUESTED &&
Requested(it->second->options, stream_type)) {
- if (it->second->type != DeviceRequest::ENUMERATE_DEVICES)
+ if (it->second->type != ENUMERATE_DEVICES)
it->second->setState(stream_type, MEDIA_REQUEST_STATE_PENDING_APPROVAL);
label_list.push_back(it->first);
}
@@ -739,26 +735,10 @@ void MediaStreamManager::DevicesEnumerated(
it != label_list.end(); ++it) {
DeviceRequest* request = requests_[*it];
switch (request->type) {
- case DeviceRequest::ENUMERATE_DEVICES:
+ case ENUMERATE_DEVICES:
if (need_update_clients && request->requester)
request->requester->DevicesEnumerated(*it, devices);
break;
- case DeviceRequest::OPEN_DEVICE:
- DCHECK(!request->requested_device_id.empty());
- for (StreamDeviceInfoArray::const_iterator device_it = devices.begin();
- device_it != devices.end(); ++device_it) {
- if (request->requested_device_id == device_it->device_id) {
- StreamDeviceInfo device = *device_it;
- device.in_use = false;
- device.session_id =
- GetDeviceManager(device_it->stream_type)->Open(device);
- request->setState(device_it->stream_type,
- MEDIA_REQUEST_STATE_OPENING);
- request->devices.push_back(device);
- break;
- }
- }
- break;
default:
ui_controller_->AddAvailableDevicesToRequest(*it, stream_type,
devices);
@@ -833,7 +813,7 @@ void MediaStreamManager::DevicesAccepted(const std::string& label,
return;
}
- if (request_it->second->type == DeviceRequest::DEVICE_ACCESS) {
+ if (request_it->second->type == DEVICE_ACCESS) {
scoped_ptr<DeviceRequest> request(request_it->second);
if (!request->callback.is_null()) {
// Map the devices to MediaStreamDevices.
@@ -899,7 +879,7 @@ void MediaStreamManager::SettingsError(const std::string& label) {
if (request->requester)
request->requester->StreamGenerationFailed(label);
- if (request->type == DeviceRequest::DEVICE_ACCESS &&
+ if (request->type == DEVICE_ACCESS &&
!request->callback.is_null())
request->callback.Run(label, MediaStreamDevices());

Powered by Google App Engine
This is Rietveld 408576698