Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(335)

Side by Side Diff: chrome/browser/media/webrtc/media_stream_devices_controller.cc

Issue 2759593002: Remove c/b/media/webrtc/media_permission.{h,cc} (Closed)
Patch Set: Remove c/b/media/webrtc/media_permission.{h,cc} Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/webrtc/media_stream_devices_controller.h" 5 #include "chrome/browser/media/webrtc/media_stream_devices_controller.h"
6 6
7 #include <map> 7 #include <map>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/callback_helpers.h" 10 #include "base/callback_helpers.h"
11 #include "base/memory/ptr_util.h" 11 #include "base/memory/ptr_util.h"
12 #include "base/metrics/histogram_macros.h" 12 #include "base/metrics/histogram_macros.h"
13 #include "base/strings/utf_string_conversions.h" 13 #include "base/strings/utf_string_conversions.h"
14 #include "base/values.h" 14 #include "base/values.h"
15 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" 15 #include "chrome/browser/content_settings/host_content_settings_map_factory.h"
16 #include "chrome/browser/content_settings/tab_specific_content_settings.h" 16 #include "chrome/browser/content_settings/tab_specific_content_settings.h"
17 #include "chrome/browser/media/webrtc/media_capture_devices_dispatcher.h" 17 #include "chrome/browser/media/webrtc/media_capture_devices_dispatcher.h"
18 #include "chrome/browser/media/webrtc/media_permission.h"
19 #include "chrome/browser/media/webrtc/media_stream_capture_indicator.h" 18 #include "chrome/browser/media/webrtc/media_stream_capture_indicator.h"
20 #include "chrome/browser/media/webrtc/media_stream_device_permissions.h" 19 #include "chrome/browser/media/webrtc/media_stream_device_permissions.h"
20 #include "chrome/browser/permissions/permission_manager.h"
21 #include "chrome/browser/permissions/permission_result.h"
21 #include "chrome/browser/permissions/permission_uma_util.h" 22 #include "chrome/browser/permissions/permission_uma_util.h"
22 #include "chrome/browser/permissions/permission_util.h" 23 #include "chrome/browser/permissions/permission_util.h"
23 #include "chrome/browser/profiles/profile.h" 24 #include "chrome/browser/profiles/profile.h"
24 #include "chrome/browser/ui/browser.h" 25 #include "chrome/browser/ui/browser.h"
25 #include "chrome/common/chrome_switches.h" 26 #include "chrome/common/chrome_switches.h"
26 #include "chrome/common/pref_names.h" 27 #include "chrome/common/pref_names.h"
27 #include "chrome/grit/generated_resources.h" 28 #include "chrome/grit/generated_resources.h"
28 #include "components/content_settings/core/browser/host_content_settings_map.h" 29 #include "components/content_settings/core/browser/host_content_settings_map.h"
29 #include "components/content_settings/core/common/content_settings_pattern.h" 30 #include "components/content_settings/core/common/content_settings_pattern.h"
30 #include "components/pref_registry/pref_registry_syncable.h" 31 #include "components/pref_registry/pref_registry_syncable.h"
(...skipping 680 matching lines...) Expand 10 before | Expand all | Expand 10 after
711 } 712 }
712 713
713 ContentSetting MediaStreamDevicesController::GetContentSetting( 714 ContentSetting MediaStreamDevicesController::GetContentSetting(
714 ContentSettingsType content_type, 715 ContentSettingsType content_type,
715 const content::MediaStreamRequest& request, 716 const content::MediaStreamRequest& request,
716 bool was_requested, 717 bool was_requested,
717 bool was_initially_blocked, 718 bool was_initially_blocked,
718 content::MediaStreamRequestResult* denial_reason) const { 719 content::MediaStreamRequestResult* denial_reason) const {
719 DCHECK(content_type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC || 720 DCHECK(content_type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC ||
720 content_type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA); 721 content_type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA);
722 DCHECK(!request_.security_origin.is_empty());
721 DCHECK(content::IsOriginSecure(request_.security_origin) || 723 DCHECK(content::IsOriginSecure(request_.security_origin) ||
722 request_.request_type == content::MEDIA_OPEN_DEVICE_PEPPER_ONLY); 724 request_.request_type == content::MEDIA_OPEN_DEVICE_PEPPER_ONLY);
723 if (!was_requested) { 725 if (!was_requested) {
724 // No denial reason set as it will have been previously set. 726 // No denial reason set as it will have been previously set.
725 return CONTENT_SETTING_DEFAULT; 727 return CONTENT_SETTING_DEFAULT;
726 } 728 }
727 729
728 if (was_initially_blocked) { 730 if (was_initially_blocked) {
729 // No denial reason set as it will have been previously set. 731 // No denial reason set as it will have been previously set.
730 return CONTENT_SETTING_BLOCK; 732 return CONTENT_SETTING_BLOCK;
731 } 733 }
732 734
733 if (!IsUserAcceptAllowed(content_type)) { 735 if (!IsUserAcceptAllowed(content_type)) {
734 *denial_reason = content::MEDIA_DEVICE_PERMISSION_DENIED; 736 *denial_reason = content::MEDIA_DEVICE_PERMISSION_DENIED;
735 return CONTENT_SETTING_BLOCK; 737 return CONTENT_SETTING_BLOCK;
736 } 738 }
737 739
738 MediaPermission permission(content_type, request.security_origin, 740 PermissionResult result =
739 web_contents_->GetLastCommittedURL().GetOrigin(), 741 PermissionManager::Get(profile_)->GetPermissionStatus(
740 profile_, web_contents_); 742 content_type, request.security_origin,
741 return permission.GetPermissionStatus(denial_reason); 743 web_contents_->GetLastCommittedURL().GetOrigin());
744 if (result.content_setting == CONTENT_SETTING_BLOCK) {
745 *denial_reason = (result.source == PermissionStatusSource::KILL_SWITCH)
746 ? content::MEDIA_DEVICE_KILL_SWITCH_ON
747 : content::MEDIA_DEVICE_PERMISSION_DENIED;
748 }
749
750 return result.content_setting;
742 } 751 }
743 752
744 ContentSetting MediaStreamDevicesController::GetNewSetting( 753 ContentSetting MediaStreamDevicesController::GetNewSetting(
745 ContentSettingsType content_type, 754 ContentSettingsType content_type,
746 ContentSetting old_setting, 755 ContentSetting old_setting,
747 ContentSetting user_decision) const { 756 ContentSetting user_decision) const {
748 DCHECK(user_decision == CONTENT_SETTING_ALLOW || 757 DCHECK(user_decision == CONTENT_SETTING_ALLOW ||
749 user_decision == CONTENT_SETTING_BLOCK); 758 user_decision == CONTENT_SETTING_BLOCK);
750 ContentSetting result = old_setting; 759 ContentSetting result = old_setting;
751 if (old_setting == CONTENT_SETTING_ASK) 760 if (old_setting == CONTENT_SETTING_ASK)
(...skipping 23 matching lines...) Expand all
775 } 784 }
776 } 785 }
777 786
778 // Don't approve device requests if the tab was hidden. 787 // Don't approve device requests if the tab was hidden.
779 // TODO(qinmin): Add a test for this. http://crbug.com/396869. 788 // TODO(qinmin): Add a test for this. http://crbug.com/396869.
780 // TODO(raymes): Shouldn't this apply to all permissions not just audio/video? 789 // TODO(raymes): Shouldn't this apply to all permissions not just audio/video?
781 return web_contents_->GetRenderWidgetHostView()->IsShowing(); 790 return web_contents_->GetRenderWidgetHostView()->IsShowing();
782 #endif 791 #endif
783 return true; 792 return true;
784 } 793 }
OLDNEW
« no previous file with comments | « chrome/browser/media/webrtc/media_permission.cc ('k') | chrome/browser/media/webrtc/permission_bubble_media_access_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698