| 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 606 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 642 } | 643 } |
| 643 | 644 |
| 644 content_settings_->OnMediaStreamPermissionSet(request_.security_origin, | 645 content_settings_->OnMediaStreamPermissionSet(request_.security_origin, |
| 645 request_permissions_); | 646 request_permissions_); |
| 646 } | 647 } |
| 647 | 648 |
| 648 bool MediaStreamDevicesController::IsDeviceAudioCaptureRequestedAndAllowed() | 649 bool MediaStreamDevicesController::IsDeviceAudioCaptureRequestedAndAllowed() |
| 649 const { | 650 const { |
| 650 MediaStreamTypeSettingsMap::const_iterator it = | 651 MediaStreamTypeSettingsMap::const_iterator it = |
| 651 request_permissions_.find(content::MEDIA_DEVICE_AUDIO_CAPTURE); | 652 request_permissions_.find(content::MEDIA_DEVICE_AUDIO_CAPTURE); |
| 652 return (it != request_permissions_.end() && | 653 return (it != request_permissions_.end() && IsCaptureDeviceRequestAllowed() && |
| 653 it->second.permission == MEDIA_ALLOWED); | 654 it->second.permission == MEDIA_ALLOWED); |
| 654 } | 655 } |
| 655 | 656 |
| 656 bool MediaStreamDevicesController::IsDeviceVideoCaptureRequestedAndAllowed() | 657 bool MediaStreamDevicesController::IsDeviceVideoCaptureRequestedAndAllowed() |
| 657 const { | 658 const { |
| 658 MediaStreamTypeSettingsMap::const_iterator it = | 659 MediaStreamTypeSettingsMap::const_iterator it = |
| 659 request_permissions_.find(content::MEDIA_DEVICE_VIDEO_CAPTURE); | 660 request_permissions_.find(content::MEDIA_DEVICE_VIDEO_CAPTURE); |
| 660 return (it != request_permissions_.end() && | 661 return (it != request_permissions_.end() && IsCaptureDeviceRequestAllowed() && |
| 661 it->second.permission == MEDIA_ALLOWED); | 662 it->second.permission == MEDIA_ALLOWED); |
| 662 } | 663 } |
| 664 |
| 665 bool MediaStreamDevicesController::IsCaptureDeviceRequestAllowed() const { |
| 666 #if defined(OS_ANDROID) |
| 667 // Don't approve device requests if the tab was hidden. |
| 668 // TODO(qinmin): Add a test for this. http://crbug.com/396869. |
| 669 return web_contents_->GetRenderWidgetHostView()->IsShowing(); |
| 670 #endif |
| 671 return true; |
| 672 } |
| OLD | NEW |