| 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 #include "chrome/browser/media/webrtc/media_stream_devices_controller.h" | 5 #include "chrome/browser/media/webrtc/media_stream_devices_controller.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
| (...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 407 break; | 407 break; |
| 408 } | 408 } |
| 409 case content::MEDIA_DEVICE_ACCESS: { | 409 case content::MEDIA_DEVICE_ACCESS: { |
| 410 // Get the default devices for the request. | 410 // Get the default devices for the request. |
| 411 MediaCaptureDevicesDispatcher::GetInstance()->GetDefaultDevicesForProfile( | 411 MediaCaptureDevicesDispatcher::GetInstance()->GetDefaultDevicesForProfile( |
| 412 profile_, audio_allowed, video_allowed, &devices); | 412 profile_, audio_allowed, video_allowed, &devices); |
| 413 break; | 413 break; |
| 414 } | 414 } |
| 415 } // switch | 415 } // switch |
| 416 | 416 |
| 417 if (audio_allowed) { | |
| 418 HostContentSettingsMapFactory::GetForProfile(profile_) | |
| 419 ->UpdateLastUsageByPattern( | |
| 420 ContentSettingsPattern::FromURLNoWildcard(request_.security_origin), | |
| 421 ContentSettingsPattern::Wildcard(), | |
| 422 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC); | |
| 423 } | |
| 424 if (video_allowed) { | |
| 425 HostContentSettingsMapFactory::GetForProfile(profile_) | |
| 426 ->UpdateLastUsageByPattern( | |
| 427 ContentSettingsPattern::FromURLNoWildcard(request_.security_origin), | |
| 428 ContentSettingsPattern::Wildcard(), | |
| 429 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA); | |
| 430 } | |
| 431 | |
| 432 return devices; | 417 return devices; |
| 433 } | 418 } |
| 434 | 419 |
| 435 void MediaStreamDevicesController::RunCallback( | 420 void MediaStreamDevicesController::RunCallback( |
| 436 ContentSetting audio_setting, | 421 ContentSetting audio_setting, |
| 437 ContentSetting video_setting, | 422 ContentSetting video_setting, |
| 438 content::MediaStreamRequestResult denial_reason) { | 423 content::MediaStreamRequestResult denial_reason) { |
| 439 CHECK(!callback_.is_null()); | 424 CHECK(!callback_.is_null()); |
| 440 | 425 |
| 441 // If the kill switch is on we don't update the tab context or persist the | 426 // If the kill switch is on we don't update the tab context or persist the |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 610 if (android_permission_blocked) | 595 if (android_permission_blocked) |
| 611 return false; | 596 return false; |
| 612 | 597 |
| 613 // Don't approve device requests if the tab was hidden. | 598 // Don't approve device requests if the tab was hidden. |
| 614 // TODO(qinmin): Add a test for this. http://crbug.com/396869. | 599 // TODO(qinmin): Add a test for this. http://crbug.com/396869. |
| 615 // TODO(raymes): Shouldn't this apply to all permissions not just audio/video? | 600 // TODO(raymes): Shouldn't this apply to all permissions not just audio/video? |
| 616 return web_contents_->GetRenderWidgetHostView()->IsShowing(); | 601 return web_contents_->GetRenderWidgetHostView()->IsShowing(); |
| 617 #endif | 602 #endif |
| 618 return true; | 603 return true; |
| 619 } | 604 } |
| OLD | NEW |