| 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 574 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 585 MEDIA_BLOCKED_BY_USER_SETTING; | 585 MEDIA_BLOCKED_BY_USER_SETTING; |
| 586 } else { | 586 } else { |
| 587 ++requested_devices; | 587 ++requested_devices; |
| 588 } | 588 } |
| 589 } | 589 } |
| 590 | 590 |
| 591 return requested_devices; | 591 return requested_devices; |
| 592 } | 592 } |
| 593 | 593 |
| 594 bool MediaStreamDevicesController::IsDefaultMediaAccessBlocked() const { | 594 bool MediaStreamDevicesController::IsDefaultMediaAccessBlocked() const { |
| 595 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 595 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 596 return (profile_->GetHostContentSettingsMap()->GetDefaultContentSetting( | 596 return (profile_->GetHostContentSettingsMap()->GetDefaultContentSetting( |
| 597 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC, NULL) | 597 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC, NULL) |
| 598 == CONTENT_SETTING_BLOCK && | 598 == CONTENT_SETTING_BLOCK && |
| 599 profile_->GetHostContentSettingsMap()->GetDefaultContentSetting( | 599 profile_->GetHostContentSettingsMap()->GetDefaultContentSetting( |
| 600 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA, NULL) | 600 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA, NULL) |
| 601 == CONTENT_SETTING_BLOCK); | 601 == CONTENT_SETTING_BLOCK); |
| 602 } | 602 } |
| 603 | 603 |
| 604 bool MediaStreamDevicesController::IsSchemeSecure() const { | 604 bool MediaStreamDevicesController::IsSchemeSecure() const { |
| 605 return request_.security_origin.SchemeIsSecure() || | 605 return request_.security_origin.SchemeIsSecure() || |
| 606 request_.security_origin.SchemeIs(extensions::kExtensionScheme); | 606 request_.security_origin.SchemeIs(extensions::kExtensionScheme); |
| 607 } | 607 } |
| 608 | 608 |
| 609 void MediaStreamDevicesController::StorePermission(bool allowed) const { | 609 void MediaStreamDevicesController::StorePermission(bool allowed) const { |
| 610 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 610 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 611 ContentSettingsPattern primary_pattern = | 611 ContentSettingsPattern primary_pattern = |
| 612 ContentSettingsPattern::FromURLNoWildcard(request_.security_origin); | 612 ContentSettingsPattern::FromURLNoWildcard(request_.security_origin); |
| 613 // Check the pattern is valid or not. When the request is from a file access, | 613 // Check the pattern is valid or not. When the request is from a file access, |
| 614 // no exception will be made. | 614 // no exception will be made. |
| 615 if (!primary_pattern.IsValid()) | 615 if (!primary_pattern.IsValid()) |
| 616 return; | 616 return; |
| 617 | 617 |
| 618 ContentSetting content_setting = allowed ? | 618 ContentSetting content_setting = allowed ? |
| 619 CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK; | 619 CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK; |
| 620 if (request_permissions_.find(content::MEDIA_DEVICE_AUDIO_CAPTURE) != | 620 if (request_permissions_.find(content::MEDIA_DEVICE_AUDIO_CAPTURE) != |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 683 } | 683 } |
| 684 | 684 |
| 685 bool MediaStreamDevicesController::IsCaptureDeviceRequestAllowed() const { | 685 bool MediaStreamDevicesController::IsCaptureDeviceRequestAllowed() const { |
| 686 #if defined(OS_ANDROID) | 686 #if defined(OS_ANDROID) |
| 687 // Don't approve device requests if the tab was hidden. | 687 // Don't approve device requests if the tab was hidden. |
| 688 // TODO(qinmin): Add a test for this. http://crbug.com/396869. | 688 // TODO(qinmin): Add a test for this. http://crbug.com/396869. |
| 689 return web_contents_->GetRenderWidgetHostView()->IsShowing(); | 689 return web_contents_->GetRenderWidgetHostView()->IsShowing(); |
| 690 #endif | 690 #endif |
| 691 return true; | 691 return true; |
| 692 } | 692 } |
| OLD | NEW |