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

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

Issue 2713083003: Use ContentSetting in chrome/ instead of PermissionStatus (Closed)
Patch Set: maybe fix android compile + address comments + basic tests Created 3 years, 9 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 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/webrtc/media_permission.h" 5 #include "chrome/browser/media/webrtc/media_permission.h"
6 6
7 #include "chrome/browser/media/webrtc/media_capture_devices_dispatcher.h" 7 #include "chrome/browser/media/webrtc/media_capture_devices_dispatcher.h"
8 #include "chrome/browser/media/webrtc/media_stream_device_permissions.h" 8 #include "chrome/browser/media/webrtc/media_stream_device_permissions.h"
9 #include "chrome/browser/permissions/permission_context_base.h" 9 #include "chrome/browser/permissions/permission_context_base.h"
10 #include "chrome/browser/permissions/permission_manager.h" 10 #include "chrome/browser/permissions/permission_manager.h"
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 return CONTENT_SETTING_ALLOW; 99 return CONTENT_SETTING_ALLOW;
100 } 100 }
101 } 101 }
102 102
103 *denial_reason = content::MEDIA_DEVICE_PERMISSION_DENIED; 103 *denial_reason = content::MEDIA_DEVICE_PERMISSION_DENIED;
104 return CONTENT_SETTING_BLOCK; 104 return CONTENT_SETTING_BLOCK;
105 } 105 }
106 #endif // defined(OS_CHROMEOS) 106 #endif // defined(OS_CHROMEOS)
107 107
108 // Check policy and content settings. 108 // Check policy and content settings.
109 blink::mojom::PermissionStatus status = 109 ContentSetting content_setting =
110 permission_manager->GetPermissionStatus( 110 permission_manager
111 content_type_, requesting_origin_, embedding_origin_); 111 ->GetPermissionStatus(content_type_, requesting_origin_,
112 switch (status) { 112 embedding_origin_)
113 case blink::mojom::PermissionStatus::DENIED: 113 .content_setting;
114 *denial_reason = content::MEDIA_DEVICE_PERMISSION_DENIED; 114 if (content_setting == CONTENT_SETTING_BLOCK)
115 return CONTENT_SETTING_BLOCK; 115 *denial_reason = content::MEDIA_DEVICE_PERMISSION_DENIED;
116 case blink::mojom::PermissionStatus::ASK: 116 return content_setting;
117 return CONTENT_SETTING_ASK;
118 case blink::mojom::PermissionStatus::GRANTED:
119 return CONTENT_SETTING_ALLOW;
120 }
121
122 NOTREACHED();
123 return CONTENT_SETTING_BLOCK;
124 } 117 }
125 118
126 ContentSetting MediaPermission::GetPermissionStatusWithDeviceRequired( 119 ContentSetting MediaPermission::GetPermissionStatusWithDeviceRequired(
127 const std::string& device_id, 120 const std::string& device_id,
128 content::MediaStreamRequestResult* denial_reason) const { 121 content::MediaStreamRequestResult* denial_reason) const {
129 // Deny the request if there is no device attached to the OS of the requested 122 // Deny the request if there is no device attached to the OS of the requested
130 // type. 123 // type.
131 if (!HasAvailableDevices(device_id)) { 124 if (!HasAvailableDevices(device_id)) {
132 *denial_reason = content::MEDIA_DEVICE_NO_HARDWARE; 125 *denial_reason = content::MEDIA_DEVICE_NO_HARDWARE;
133 return CONTENT_SETTING_BLOCK; 126 return CONTENT_SETTING_BLOCK;
(...skipping 23 matching lines...) Expand all
157 return false; 150 return false;
158 151
159 // Note: we check device_id before dereferencing devices. If the requested 152 // Note: we check device_id before dereferencing devices. If the requested
160 // device id is non-empty, then the corresponding device list must not be 153 // device id is non-empty, then the corresponding device list must not be
161 // NULL. 154 // NULL.
162 if (!device_id.empty() && !devices->FindById(device_id)) 155 if (!device_id.empty() && !devices->FindById(device_id))
163 return false; 156 return false;
164 157
165 return true; 158 return true;
166 } 159 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698