| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_permission.h" | 5 #include "chrome/browser/media/media_permission.h" |
| 6 | 6 |
| 7 #include "chrome/browser/media/media_capture_devices_dispatcher.h" | 7 #include "chrome/browser/media/media_capture_devices_dispatcher.h" |
| 8 #include "chrome/browser/media/media_stream_device_permission_context.h" | 8 #include "chrome/browser/media/media_stream_device_permission_context.h" |
| 9 #include "chrome/browser/media/media_stream_device_permissions.h" | 9 #include "chrome/browser/media/media_stream_device_permissions.h" |
| 10 #include "chrome/browser/permissions/permission_context.h" | |
| 11 #include "chrome/browser/permissions/permission_context_base.h" | 10 #include "chrome/browser/permissions/permission_context_base.h" |
| 11 #include "chrome/browser/permissions/permission_manager.h" |
| 12 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
| 13 #include "chrome/common/pref_names.h" | 13 #include "chrome/common/pref_names.h" |
| 14 #include "content/public/browser/permission_manager.h" | 14 #include "content/public/browser/permission_manager.h" |
| 15 #include "content/public/browser/permission_type.h" | 15 #include "content/public/browser/permission_type.h" |
| 16 #include "content/public/common/url_constants.h" | 16 #include "content/public/common/url_constants.h" |
| 17 #include "extensions/common/constants.h" | 17 #include "extensions/common/constants.h" |
| 18 | 18 |
| 19 namespace { | 19 namespace { |
| 20 | 20 |
| 21 content::PermissionType ContentSettingsTypeToPermission( | 21 content::PermissionType ContentSettingsTypeToPermission( |
| (...skipping 25 matching lines...) Expand all Loading... |
| 47 // file access without |--allow-file-access-from-files| flag. | 47 // file access without |--allow-file-access-from-files| flag. |
| 48 if (requesting_origin_.is_empty()) { | 48 if (requesting_origin_.is_empty()) { |
| 49 *denial_reason = content::MEDIA_DEVICE_INVALID_SECURITY_ORIGIN; | 49 *denial_reason = content::MEDIA_DEVICE_INVALID_SECURITY_ORIGIN; |
| 50 return CONTENT_SETTING_BLOCK; | 50 return CONTENT_SETTING_BLOCK; |
| 51 } | 51 } |
| 52 | 52 |
| 53 // Use the Permission Context to find out if the kill switch is on. Set the | 53 // Use the Permission Context to find out if the kill switch is on. Set the |
| 54 // denial reason to kill switch. | 54 // denial reason to kill switch. |
| 55 content::PermissionType permission_type = | 55 content::PermissionType permission_type = |
| 56 ContentSettingsTypeToPermission(content_type_); | 56 ContentSettingsTypeToPermission(content_type_); |
| 57 // TODO(raymes): This calls into GetPermissionContext which is a private |
| 58 // member of PermissionManager. Remove this call when this class is refactored |
| 59 // into a PermissionContext. See crbug.com/596786. |
| 57 PermissionContextBase* permission_context = | 60 PermissionContextBase* permission_context = |
| 58 PermissionContext::Get(profile_, permission_type); | 61 PermissionManager::Get(profile_)->GetPermissionContext(permission_type); |
| 59 | 62 |
| 60 if (!permission_context) { | 63 if (!permission_context) { |
| 61 *denial_reason = content::MEDIA_DEVICE_PERMISSION_DENIED; | 64 *denial_reason = content::MEDIA_DEVICE_PERMISSION_DENIED; |
| 62 return CONTENT_SETTING_BLOCK; | 65 return CONTENT_SETTING_BLOCK; |
| 63 } | 66 } |
| 64 | 67 |
| 65 MediaStreamDevicePermissionContext* media_device_permission_context = | 68 MediaStreamDevicePermissionContext* media_device_permission_context = |
| 66 static_cast<MediaStreamDevicePermissionContext*>(permission_context); | 69 static_cast<MediaStreamDevicePermissionContext*>(permission_context); |
| 67 | 70 |
| 68 if (media_device_permission_context->IsPermissionKillSwitchOn()) { | 71 if (media_device_permission_context->IsPermissionKillSwitchOn()) { |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 return false; | 128 return false; |
| 126 | 129 |
| 127 // Note: we check device_id before dereferencing devices. If the requested | 130 // Note: we check device_id before dereferencing devices. If the requested |
| 128 // device id is non-empty, then the corresponding device list must not be | 131 // device id is non-empty, then the corresponding device list must not be |
| 129 // NULL. | 132 // NULL. |
| 130 if (!device_id.empty() && !devices->FindById(device_id)) | 133 if (!device_id.empty() && !devices->FindById(device_id)) |
| 131 return false; | 134 return false; |
| 132 | 135 |
| 133 return true; | 136 return true; |
| 134 } | 137 } |
| OLD | NEW |