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 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
451 ->GetMediaStreamCaptureIndicator() | 451 ->GetMediaStreamCaptureIndicator() |
452 ->RegisterMediaStream(web_contents_, devices); | 452 ->RegisterMediaStream(web_contents_, devices); |
453 } | 453 } |
454 base::ResetAndReturn(&callback_).Run(devices, request_result, std::move(ui)); | 454 base::ResetAndReturn(&callback_).Run(devices, request_result, std::move(ui)); |
455 } | 455 } |
456 | 456 |
457 void MediaStreamDevicesController::StorePermission( | 457 void MediaStreamDevicesController::StorePermission( |
458 ContentSetting new_audio_setting, | 458 ContentSetting new_audio_setting, |
459 ContentSetting new_video_setting) const { | 459 ContentSetting new_video_setting) const { |
460 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 460 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
461 ContentSettingsPattern primary_pattern = | |
462 ContentSettingsPattern::FromURLNoWildcard(request_.security_origin); | |
463 | 461 |
464 bool is_pepper_request = | 462 bool is_pepper_request = |
465 request_.request_type == content::MEDIA_OPEN_DEVICE_PEPPER_ONLY; | 463 request_.request_type == content::MEDIA_OPEN_DEVICE_PEPPER_ONLY; |
466 | 464 |
467 if (IsAskingForAudio() && new_audio_setting != CONTENT_SETTING_ASK) { | 465 if (IsAskingForAudio() && new_audio_setting != CONTENT_SETTING_ASK) { |
468 if (ShouldPersistContentSetting(new_audio_setting, request_.security_origin, | 466 if (ShouldPersistContentSetting(new_audio_setting, request_.security_origin, |
469 is_pepper_request)) { | 467 is_pepper_request)) { |
470 HostContentSettingsMapFactory::GetForProfile(profile_)->SetContentSetting( | 468 HostContentSettingsMapFactory::GetForProfile(profile_) |
471 primary_pattern, ContentSettingsPattern::Wildcard(), | 469 ->SetContentSettingDefaultScope(request_.security_origin, GURL(), |
472 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC, std::string(), | 470 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC, |
473 new_audio_setting); | 471 std::string(), new_audio_setting); |
474 } | 472 } |
475 } | 473 } |
476 if (IsAskingForVideo() && new_video_setting != CONTENT_SETTING_ASK) { | 474 if (IsAskingForVideo() && new_video_setting != CONTENT_SETTING_ASK) { |
477 if (ShouldPersistContentSetting(new_video_setting, request_.security_origin, | 475 if (ShouldPersistContentSetting(new_video_setting, request_.security_origin, |
478 is_pepper_request)) { | 476 is_pepper_request)) { |
479 HostContentSettingsMapFactory::GetForProfile(profile_)->SetContentSetting( | 477 HostContentSettingsMapFactory::GetForProfile(profile_) |
480 primary_pattern, ContentSettingsPattern::Wildcard(), | 478 ->SetContentSettingDefaultScope( |
481 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA, std::string(), | 479 request_.security_origin, GURL(), |
482 new_video_setting); | 480 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA, std::string(), |
| 481 new_video_setting); |
483 } | 482 } |
484 } | 483 } |
485 } | 484 } |
486 | 485 |
487 void MediaStreamDevicesController::UpdateTabSpecificContentSettings( | 486 void MediaStreamDevicesController::UpdateTabSpecificContentSettings( |
488 ContentSetting audio_setting, | 487 ContentSetting audio_setting, |
489 ContentSetting video_setting) const { | 488 ContentSetting video_setting) const { |
490 if (!content_settings_) | 489 if (!content_settings_) |
491 return; | 490 return; |
492 | 491 |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
611 if (android_permission_blocked) | 610 if (android_permission_blocked) |
612 return false; | 611 return false; |
613 | 612 |
614 // Don't approve device requests if the tab was hidden. | 613 // Don't approve device requests if the tab was hidden. |
615 // TODO(qinmin): Add a test for this. http://crbug.com/396869. | 614 // TODO(qinmin): Add a test for this. http://crbug.com/396869. |
616 // 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? |
617 return web_contents_->GetRenderWidgetHostView()->IsShowing(); | 616 return web_contents_->GetRenderWidgetHostView()->IsShowing(); |
618 #endif | 617 #endif |
619 return true; | 618 return true; |
620 } | 619 } |
OLD | NEW |