| 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/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
| 9 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
| 10 #include "base/prefs/scoped_user_pref_update.h" | 10 #include "base/prefs/scoped_user_pref_update.h" |
| 11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
| 12 #include "base/values.h" | 12 #include "base/values.h" |
| 13 #include "chrome/browser/content_settings/content_settings_provider.h" | 13 #include "chrome/browser/content_settings/content_settings_provider.h" |
| 14 #include "chrome/browser/content_settings/host_content_settings_map.h" | 14 #include "chrome/browser/content_settings/host_content_settings_map.h" |
| 15 #include "chrome/browser/content_settings/tab_specific_content_settings.h" | 15 #include "chrome/browser/content_settings/tab_specific_content_settings.h" |
| 16 #include "chrome/browser/media/media_capture_devices_dispatcher.h" | 16 #include "chrome/browser/media/media_capture_devices_dispatcher.h" |
| 17 #include "chrome/browser/media/media_stream_capture_indicator.h" | 17 #include "chrome/browser/media/media_stream_capture_indicator.h" |
| 18 #include "chrome/browser/profiles/profile.h" | 18 #include "chrome/browser/profiles/profile.h" |
| 19 #include "chrome/browser/ui/browser.h" | 19 #include "chrome/browser/ui/browser.h" |
| 20 #include "chrome/common/chrome_switches.h" | 20 #include "chrome/common/chrome_switches.h" |
| 21 #include "chrome/common/content_settings.h" | 21 #include "chrome/common/content_settings.h" |
| 22 #include "chrome/common/content_settings_pattern.h" | 22 #include "chrome/common/content_settings_pattern.h" |
| 23 #include "chrome/common/pref_names.h" | 23 #include "chrome/common/pref_names.h" |
| 24 #include "components/pref_registry/pref_registry_syncable.h" | 24 #include "components/pref_registry/pref_registry_syncable.h" |
| 25 #include "content/public/browser/browser_thread.h" | 25 #include "content/public/browser/browser_thread.h" |
| 26 #include "content/public/browser/render_widget_host_view.h" |
| 26 #include "content/public/common/media_stream_request.h" | 27 #include "content/public/common/media_stream_request.h" |
| 27 #include "extensions/common/constants.h" | 28 #include "extensions/common/constants.h" |
| 28 #include "grit/generated_resources.h" | 29 #include "grit/generated_resources.h" |
| 29 #include "grit/theme_resources.h" | 30 #include "grit/theme_resources.h" |
| 30 #include "ui/base/l10n/l10n_util.h" | 31 #include "ui/base/l10n/l10n_util.h" |
| 31 | 32 |
| 32 #if defined(OS_CHROMEOS) | 33 #if defined(OS_CHROMEOS) |
| 33 #include "chrome/browser/chromeos/login/users/user_manager.h" | 34 #include "chrome/browser/chromeos/login/users/user_manager.h" |
| 34 #endif | 35 #endif |
| 35 | 36 |
| (...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 655 } | 656 } |
| 656 | 657 |
| 657 content_settings_->OnMediaStreamPermissionSet(request_.security_origin, | 658 content_settings_->OnMediaStreamPermissionSet(request_.security_origin, |
| 658 request_permissions_); | 659 request_permissions_); |
| 659 } | 660 } |
| 660 | 661 |
| 661 bool MediaStreamDevicesController::IsDeviceAudioCaptureRequestedAndAllowed() | 662 bool MediaStreamDevicesController::IsDeviceAudioCaptureRequestedAndAllowed() |
| 662 const { | 663 const { |
| 663 MediaStreamTypeSettingsMap::const_iterator it = | 664 MediaStreamTypeSettingsMap::const_iterator it = |
| 664 request_permissions_.find(content::MEDIA_DEVICE_AUDIO_CAPTURE); | 665 request_permissions_.find(content::MEDIA_DEVICE_AUDIO_CAPTURE); |
| 665 return (it != request_permissions_.end() && | 666 return (it != request_permissions_.end() && IsCaptureDeviceRequestAllowed() && |
| 666 it->second.permission == MEDIA_ALLOWED); | 667 it->second.permission == MEDIA_ALLOWED); |
| 667 } | 668 } |
| 668 | 669 |
| 669 bool MediaStreamDevicesController::IsDeviceVideoCaptureRequestedAndAllowed() | 670 bool MediaStreamDevicesController::IsDeviceVideoCaptureRequestedAndAllowed() |
| 670 const { | 671 const { |
| 671 MediaStreamTypeSettingsMap::const_iterator it = | 672 MediaStreamTypeSettingsMap::const_iterator it = |
| 672 request_permissions_.find(content::MEDIA_DEVICE_VIDEO_CAPTURE); | 673 request_permissions_.find(content::MEDIA_DEVICE_VIDEO_CAPTURE); |
| 673 return (it != request_permissions_.end() && | 674 return (it != request_permissions_.end() && IsCaptureDeviceRequestAllowed() && |
| 674 it->second.permission == MEDIA_ALLOWED); | 675 it->second.permission == MEDIA_ALLOWED); |
| 675 } | 676 } |
| 677 |
| 678 bool MediaStreamDevicesController::IsCaptureDeviceRequestAllowed() const { |
| 679 #if defined(OS_ANDROID) |
| 680 // Don't approve device requests if the tab was hidden. |
| 681 // TODO(qinmin): Add a test for this. http://crbug.com/396869. |
| 682 return web_contents_->GetRenderWidgetHostView()->IsShowing(); |
| 683 #endif |
| 684 return true; |
| 685 } |
| OLD | NEW |