Chromium Code Reviews| 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/permissions/permission_manager_factory.h" | |
| 12 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
| 13 #include "chrome/common/pref_names.h" | 14 #include "chrome/common/pref_names.h" |
| 14 #include "content/public/browser/permission_manager.h" | 15 #include "content/public/browser/permission_manager.h" |
| 15 #include "content/public/browser/permission_type.h" | 16 #include "content/public/browser/permission_type.h" |
| 16 #include "content/public/common/url_constants.h" | 17 #include "content/public/common/url_constants.h" |
| 17 #include "extensions/common/constants.h" | 18 #include "extensions/common/constants.h" |
| 18 | 19 |
| 19 namespace { | 20 namespace { |
| 20 | 21 |
| 21 content::PermissionType ContentSettingsTypeToPermission( | 22 content::PermissionType ContentSettingsTypeToPermission( |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 48 if (requesting_origin_.is_empty()) { | 49 if (requesting_origin_.is_empty()) { |
| 49 *denial_reason = content::MEDIA_DEVICE_INVALID_SECURITY_ORIGIN; | 50 *denial_reason = content::MEDIA_DEVICE_INVALID_SECURITY_ORIGIN; |
| 50 return CONTENT_SETTING_BLOCK; | 51 return CONTENT_SETTING_BLOCK; |
| 51 } | 52 } |
| 52 | 53 |
| 53 // Use the Permission Context to find out if the kill switch is on. Set the | 54 // Use the Permission Context to find out if the kill switch is on. Set the |
| 54 // denial reason to kill switch. | 55 // denial reason to kill switch. |
| 55 content::PermissionType permission_type = | 56 content::PermissionType permission_type = |
| 56 ContentSettingsTypeToPermission(content_type_); | 57 ContentSettingsTypeToPermission(content_type_); |
| 57 PermissionContextBase* permission_context = | 58 PermissionContextBase* permission_context = |
| 58 PermissionContext::Get(profile_, permission_type); | 59 PermissionManagerFactory::GetForProfile(profile_)->GetPermissionContext( |
| 60 permission_type); | |
|
mlamouri (slow - plz ping)
2016/04/11 14:06:05
Could that be moved to something like:
`Permission
raymes
2016/04/12 07:44:54
It's a bit too complicated to change this one righ
| |
| 59 | 61 |
| 60 if (!permission_context) { | 62 if (!permission_context) { |
| 61 *denial_reason = content::MEDIA_DEVICE_PERMISSION_DENIED; | 63 *denial_reason = content::MEDIA_DEVICE_PERMISSION_DENIED; |
| 62 return CONTENT_SETTING_BLOCK; | 64 return CONTENT_SETTING_BLOCK; |
| 63 } | 65 } |
| 64 | 66 |
| 65 MediaStreamDevicePermissionContext* media_device_permission_context = | 67 MediaStreamDevicePermissionContext* media_device_permission_context = |
| 66 static_cast<MediaStreamDevicePermissionContext*>(permission_context); | 68 static_cast<MediaStreamDevicePermissionContext*>(permission_context); |
| 67 | 69 |
| 68 if (media_device_permission_context->IsPermissionKillSwitchOn()) { | 70 if (media_device_permission_context->IsPermissionKillSwitchOn()) { |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 125 return false; | 127 return false; |
| 126 | 128 |
| 127 // Note: we check device_id before dereferencing devices. If the requested | 129 // 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 | 130 // device id is non-empty, then the corresponding device list must not be |
| 129 // NULL. | 131 // NULL. |
| 130 if (!device_id.empty() && !devices->FindById(device_id)) | 132 if (!device_id.empty() && !devices->FindById(device_id)) |
| 131 return false; | 133 return false; |
| 132 | 134 |
| 133 return true; | 135 return true; |
| 134 } | 136 } |
| OLD | NEW |