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 "base/metrics/histogram.h" | 7 #include "base/metrics/histogram.h" |
8 #include "base/prefs/scoped_user_pref_update.h" | 8 #include "base/prefs/scoped_user_pref_update.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
493 kCancel, kPermissionActionsMax); | 493 kCancel, kPermissionActionsMax); |
494 Deny(false, content::MEDIA_DEVICE_PERMISSION_DISMISSED); | 494 Deny(false, content::MEDIA_DEVICE_PERMISSION_DISMISSED); |
495 } | 495 } |
496 | 496 |
497 void MediaStreamDevicesController::RequestFinished() { | 497 void MediaStreamDevicesController::RequestFinished() { |
498 delete this; | 498 delete this; |
499 } | 499 } |
500 | 500 |
501 bool MediaStreamDevicesController::IsRequestAllowedByDefault() const { | 501 bool MediaStreamDevicesController::IsRequestAllowedByDefault() const { |
502 // The request from internal objects like chrome://URLs is always allowed. | 502 // The request from internal objects like chrome://URLs is always allowed. |
503 if (CheckAllowAllMediaStreamContentForOrigin(profile_, | 503 if (CheckAllowAllMediaStreamContentForOrigin( |
504 request_.security_origin)) { | 504 profile_, request_.security_origin, |
505 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC) && | |
506 CheckAllowAllMediaStreamContentForOrigin( | |
507 profile_, request_.security_origin, | |
508 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA)) { | |
505 return true; | 509 return true; |
506 } | 510 } |
507 | 511 |
508 struct { | 512 struct { |
509 bool has_capability; | 513 bool has_capability; |
510 const char* policy_name; | 514 const char* policy_name; |
511 const char* list_policy_name; | 515 const char* list_policy_name; |
512 ContentSettingsType settings_type; | 516 ContentSettingsType settings_type; |
513 } device_checks[] = { | 517 } device_checks[] = { |
514 { IsDeviceAudioCaptureRequestedAndAllowed(), prefs::kAudioCaptureAllowed, | 518 { IsDeviceAudioCaptureRequestedAndAllowed(), prefs::kAudioCaptureAllowed, |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
579 } else { | 583 } else { |
580 ++requested_devices; | 584 ++requested_devices; |
581 } | 585 } |
582 } | 586 } |
583 | 587 |
584 return requested_devices; | 588 return requested_devices; |
585 } | 589 } |
586 | 590 |
587 bool MediaStreamDevicesController::IsDefaultMediaAccessBlocked() const { | 591 bool MediaStreamDevicesController::IsDefaultMediaAccessBlocked() const { |
588 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 592 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
589 // TODO(markusheintz): Replace CONTENT_SETTINGS_TYPE_MEDIA_STREAM with the | 593 return (profile_->GetHostContentSettingsMap()->GetDefaultContentSetting( |
590 // appropriate new CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC and | 594 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC, NULL |
591 // CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA. | 595 ) == CONTENT_SETTING_BLOCK && |
markusheintz_
2015/03/06 16:05:33
The closing ) should be in the previous line.
He
msramek
2015/03/06 17:47:33
Done.
| |
592 ContentSetting current_setting = | 596 profile_->GetHostContentSettingsMap()->GetDefaultContentSetting( |
593 profile_->GetHostContentSettingsMap()->GetDefaultContentSetting( | 597 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA, NULL |
594 CONTENT_SETTINGS_TYPE_MEDIASTREAM, NULL); | 598 ) == CONTENT_SETTING_BLOCK); |
595 return (current_setting == CONTENT_SETTING_BLOCK); | |
596 } | 599 } |
597 | 600 |
598 bool MediaStreamDevicesController::IsSchemeSecure() const { | 601 bool MediaStreamDevicesController::IsSchemeSecure() const { |
599 return request_.security_origin.SchemeIsSecure() || | 602 return request_.security_origin.SchemeIsSecure() || |
600 request_.security_origin.SchemeIs(extensions::kExtensionScheme); | 603 request_.security_origin.SchemeIs(extensions::kExtensionScheme); |
601 } | 604 } |
602 | 605 |
603 void MediaStreamDevicesController::StorePermission(bool allowed) const { | 606 void MediaStreamDevicesController::StorePermission(bool allowed) const { |
604 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 607 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
605 ContentSettingsPattern primary_pattern = | 608 ContentSettingsPattern primary_pattern = |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
677 } | 680 } |
678 | 681 |
679 bool MediaStreamDevicesController::IsCaptureDeviceRequestAllowed() const { | 682 bool MediaStreamDevicesController::IsCaptureDeviceRequestAllowed() const { |
680 #if defined(OS_ANDROID) | 683 #if defined(OS_ANDROID) |
681 // Don't approve device requests if the tab was hidden. | 684 // Don't approve device requests if the tab was hidden. |
682 // TODO(qinmin): Add a test for this. http://crbug.com/396869. | 685 // TODO(qinmin): Add a test for this. http://crbug.com/396869. |
683 return web_contents_->GetRenderWidgetHostView()->IsShowing(); | 686 return web_contents_->GetRenderWidgetHostView()->IsShowing(); |
684 #endif | 687 #endif |
685 return true; | 688 return true; |
686 } | 689 } |
OLD | NEW |