Chromium Code Reviews| 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 | |
|
DaleCurtis
2014/07/23 22:17:19
Line break is normally kept here.
qinmin
2014/07/23 22:28:48
Done.
| |
| 32 #if defined(OS_CHROMEOS) | 32 #if defined(OS_CHROMEOS) |
| 33 #include "chrome/browser/chromeos/login/users/user_manager.h" | 33 #include "chrome/browser/chromeos/login/users/user_manager.h" |
| 34 #endif | 34 #endif |
| 35 | 35 |
| 36 using content::BrowserThread; | 36 using content::BrowserThread; |
| 37 | 37 |
| 38 namespace { | 38 namespace { |
| 39 | 39 |
| 40 bool HasAvailableDevicesForRequest(const content::MediaStreamRequest& request) { | 40 bool HasAvailableDevicesForRequest(const content::MediaStreamRequest& request) { |
| 41 const content::MediaStreamDevices* audio_devices = | 41 const content::MediaStreamDevices* audio_devices = |
| (...skipping 609 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 651 } | 651 } |
| 652 if (IsDeviceVideoCaptureRequestedAndAllowed()) { | 652 if (IsDeviceVideoCaptureRequestedAndAllowed()) { |
| 653 request_permissions_[content::MEDIA_DEVICE_VIDEO_CAPTURE].permission = | 653 request_permissions_[content::MEDIA_DEVICE_VIDEO_CAPTURE].permission = |
| 654 MEDIA_BLOCKED_BY_USER; | 654 MEDIA_BLOCKED_BY_USER; |
| 655 } | 655 } |
| 656 | 656 |
| 657 content_settings_->OnMediaStreamPermissionSet(request_.security_origin, | 657 content_settings_->OnMediaStreamPermissionSet(request_.security_origin, |
| 658 request_permissions_); | 658 request_permissions_); |
| 659 } | 659 } |
| 660 | 660 |
| 661 bool MediaStreamDevicesController::IsDeviceAudioCaptureRequestedAndAllowed() | 661 bool MediaStreamDevicesController::IsDeviceAudioCaptureRequestedAndAllowed() |
|
DaleCurtis
2014/07/23 22:17:19
Presumably all three of these methods are being ca
qinmin
2014/07/23 22:28:48
Yes.
On 2014/07/23 22:17:19, DaleCurtis wrote:
| |
| 662 const { | 662 const { |
| 663 MediaStreamTypeSettingsMap::const_iterator it = | 663 MediaStreamTypeSettingsMap::const_iterator it = |
| 664 request_permissions_.find(content::MEDIA_DEVICE_AUDIO_CAPTURE); | 664 request_permissions_.find(content::MEDIA_DEVICE_AUDIO_CAPTURE); |
| 665 return (it != request_permissions_.end() && | 665 return (it != request_permissions_.end() && IsCaptureDeviceRequestAllowed() && |
| 666 it->second.permission == MEDIA_ALLOWED); | 666 it->second.permission == MEDIA_ALLOWED); |
| 667 } | 667 } |
| 668 | 668 |
| 669 bool MediaStreamDevicesController::IsDeviceVideoCaptureRequestedAndAllowed() | 669 bool MediaStreamDevicesController::IsDeviceVideoCaptureRequestedAndAllowed() |
| 670 const { | 670 const { |
| 671 MediaStreamTypeSettingsMap::const_iterator it = | 671 MediaStreamTypeSettingsMap::const_iterator it = |
| 672 request_permissions_.find(content::MEDIA_DEVICE_VIDEO_CAPTURE); | 672 request_permissions_.find(content::MEDIA_DEVICE_VIDEO_CAPTURE); |
| 673 return (it != request_permissions_.end() && | 673 return (it != request_permissions_.end() && IsCaptureDeviceRequestAllowed() && |
| 674 it->second.permission == MEDIA_ALLOWED); | 674 it->second.permission == MEDIA_ALLOWED); |
| 675 } | 675 } |
| 676 | |
| 677 bool MediaStreamDevicesController::IsCaptureDeviceRequestAllowed() const { | |
| 678 #if defined(OS_ANDROID) | |
| 679 // Don't approve device requests if the tab was hidden. | |
| 680 return web_contents_->GetRenderWidgetHostView()->IsShowing(); | |
| 681 #endif | |
| 682 return true; | |
| 683 } | |
| OLD | NEW |