| 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/media_stream_devices_controller.h" | 5 #include "chrome/browser/media/media_stream_devices_controller.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
| (...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 456 ->GetMediaStreamCaptureIndicator() | 456 ->GetMediaStreamCaptureIndicator() |
| 457 ->RegisterMediaStream(web_contents_, devices); | 457 ->RegisterMediaStream(web_contents_, devices); |
| 458 } | 458 } |
| 459 base::ResetAndReturn(&callback_).Run(devices, request_result, std::move(ui)); | 459 base::ResetAndReturn(&callback_).Run(devices, request_result, std::move(ui)); |
| 460 } | 460 } |
| 461 | 461 |
| 462 void MediaStreamDevicesController::StorePermission( | 462 void MediaStreamDevicesController::StorePermission( |
| 463 ContentSetting new_audio_setting, | 463 ContentSetting new_audio_setting, |
| 464 ContentSetting new_video_setting) const { | 464 ContentSetting new_video_setting) const { |
| 465 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 465 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 466 | 466 DCHECK(content::IsOriginSecure(request_.security_origin) || |
| 467 bool is_pepper_request = | 467 request_.request_type == content::MEDIA_OPEN_DEVICE_PEPPER_ONLY); |
| 468 request_.request_type == content::MEDIA_OPEN_DEVICE_PEPPER_ONLY; | |
| 469 | 468 |
| 470 if (IsAskingForAudio() && new_audio_setting != CONTENT_SETTING_ASK) { | 469 if (IsAskingForAudio() && new_audio_setting != CONTENT_SETTING_ASK) { |
| 471 if (ShouldPersistContentSetting(new_audio_setting, request_.security_origin, | 470 if (ShouldPersistContentSetting(request_.security_origin)) { |
| 472 is_pepper_request)) { | |
| 473 HostContentSettingsMapFactory::GetForProfile(profile_) | 471 HostContentSettingsMapFactory::GetForProfile(profile_) |
| 474 ->SetContentSettingDefaultScope(request_.security_origin, GURL(), | 472 ->SetContentSettingDefaultScope(request_.security_origin, GURL(), |
| 475 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC, | 473 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC, |
| 476 std::string(), new_audio_setting); | 474 std::string(), new_audio_setting); |
| 477 } | 475 } |
| 478 } | 476 } |
| 479 if (IsAskingForVideo() && new_video_setting != CONTENT_SETTING_ASK) { | 477 if (IsAskingForVideo() && new_video_setting != CONTENT_SETTING_ASK) { |
| 480 if (ShouldPersistContentSetting(new_video_setting, request_.security_origin, | 478 if (ShouldPersistContentSetting(request_.security_origin)) { |
| 481 is_pepper_request)) { | |
| 482 HostContentSettingsMapFactory::GetForProfile(profile_) | 479 HostContentSettingsMapFactory::GetForProfile(profile_) |
| 483 ->SetContentSettingDefaultScope( | 480 ->SetContentSettingDefaultScope( |
| 484 request_.security_origin, GURL(), | 481 request_.security_origin, GURL(), |
| 485 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA, std::string(), | 482 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA, std::string(), |
| 486 new_video_setting); | 483 new_video_setting); |
| 487 } | 484 } |
| 488 } | 485 } |
| 489 } | 486 } |
| 490 | 487 |
| 491 void MediaStreamDevicesController::UpdateTabSpecificContentSettings( | 488 void MediaStreamDevicesController::UpdateTabSpecificContentSettings( |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 554 | 551 |
| 555 content::PermissionType permission_type; | 552 content::PermissionType permission_type; |
| 556 if (content_type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC) { | 553 if (content_type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC) { |
| 557 permission_type = content::PermissionType::AUDIO_CAPTURE; | 554 permission_type = content::PermissionType::AUDIO_CAPTURE; |
| 558 } else { | 555 } else { |
| 559 DCHECK(content_type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA); | 556 DCHECK(content_type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA); |
| 560 permission_type = content::PermissionType::VIDEO_CAPTURE; | 557 permission_type = content::PermissionType::VIDEO_CAPTURE; |
| 561 } | 558 } |
| 562 | 559 |
| 563 if (ContentTypeIsRequested(permission_type, request)) { | 560 if (ContentTypeIsRequested(permission_type, request)) { |
| 564 bool is_insecure_pepper_request = | 561 DCHECK(content::IsOriginSecure(request_.security_origin) || |
| 565 request.request_type == content::MEDIA_OPEN_DEVICE_PEPPER_ONLY && | 562 request_.request_type == content::MEDIA_OPEN_DEVICE_PEPPER_ONLY); |
| 566 request.security_origin.SchemeIs(url::kHttpScheme); | 563 MediaPermission permission(content_type, request.security_origin, |
| 567 MediaPermission permission( | |
| 568 content_type, is_insecure_pepper_request, request.security_origin, | |
| 569 web_contents_->GetLastCommittedURL().GetOrigin(), profile_); | 564 web_contents_->GetLastCommittedURL().GetOrigin(), profile_); |
| 570 return permission.GetPermissionStatusWithDeviceRequired(requested_device_id, | 565 return permission.GetPermissionStatusWithDeviceRequired(requested_device_id, |
| 571 denial_reason); | 566 denial_reason); |
| 572 } | 567 } |
| 573 // Return the default content setting if the device is not requested. | 568 // Return the default content setting if the device is not requested. |
| 574 return CONTENT_SETTING_DEFAULT; | 569 return CONTENT_SETTING_DEFAULT; |
| 575 } | 570 } |
| 576 | 571 |
| 577 ContentSetting MediaStreamDevicesController::GetNewSetting( | 572 ContentSetting MediaStreamDevicesController::GetNewSetting( |
| 578 ContentSettingsType content_type, | 573 ContentSettingsType content_type, |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 615 if (android_permission_blocked) | 610 if (android_permission_blocked) |
| 616 return false; | 611 return false; |
| 617 | 612 |
| 618 // Don't approve device requests if the tab was hidden. | 613 // Don't approve device requests if the tab was hidden. |
| 619 // TODO(qinmin): Add a test for this. http://crbug.com/396869. | 614 // TODO(qinmin): Add a test for this. http://crbug.com/396869. |
| 620 // TODO(raymes): Shouldn't this apply to all permissions not just audio/video? | 615 // TODO(raymes): Shouldn't this apply to all permissions not just audio/video? |
| 621 return web_contents_->GetRenderWidgetHostView()->IsShowing(); | 616 return web_contents_->GetRenderWidgetHostView()->IsShowing(); |
| 622 #endif | 617 #endif |
| 623 return true; | 618 return true; |
| 624 } | 619 } |
| OLD | NEW |