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

Side by Side Diff: chrome/browser/permissions/permission_manager.cc

Issue 1311783007: refactor to Introduce AUDIO_CAPTURE and VIDEO_CAPTURE permissions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 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/permissions/permission_manager.h" 5 #include "chrome/browser/permissions/permission_manager.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "chrome/browser/permissions/permission_context.h" 8 #include "chrome/browser/permissions/permission_context.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_request_id.h" 10 #include "chrome/browser/permissions/permission_request_id.h"
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 return CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENTIFIER; 57 return CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENTIFIER;
58 #else 58 #else
59 NOTIMPLEMENTED(); 59 NOTIMPLEMENTED();
60 break; 60 break;
61 #endif 61 #endif
62 case PermissionType::DURABLE_STORAGE: 62 case PermissionType::DURABLE_STORAGE:
63 return CONTENT_SETTINGS_TYPE_DURABLE_STORAGE; 63 return CONTENT_SETTINGS_TYPE_DURABLE_STORAGE;
64 case PermissionType::MIDI: 64 case PermissionType::MIDI:
65 // This will hit the NOTREACHED below. 65 // This will hit the NOTREACHED below.
66 break; 66 break;
67 case PermissionType::AUDIO_CAPTURE:
68 return CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC;
69 case PermissionType::VIDEO_CAPTURE:
70 return CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA;
67 case PermissionType::NUM: 71 case PermissionType::NUM:
68 // This will hit the NOTREACHED below. 72 // This will hit the NOTREACHED below.
69 break; 73 break;
70 } 74 }
71 75
72 NOTREACHED() << "Unknown content setting for permission " 76 NOTREACHED() << "Unknown content setting for permission "
73 << static_cast<int>(permission); 77 << static_cast<int>(permission);
74 return CONTENT_SETTINGS_TYPE_DEFAULT; 78 return CONTENT_SETTINGS_TYPE_DEFAULT;
75 } 79 }
76 80
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 PermissionType permission, 216 PermissionType permission,
213 const GURL& requesting_origin, 217 const GURL& requesting_origin,
214 const GURL& embedding_origin) { 218 const GURL& embedding_origin) {
215 if (IsConstantPermission(permission)) 219 if (IsConstantPermission(permission))
216 return GetPermissionStatusForConstantPermission(permission); 220 return GetPermissionStatusForConstantPermission(permission);
217 221
218 PermissionContextBase* context = PermissionContext::Get(profile_, permission); 222 PermissionContextBase* context = PermissionContext::Get(profile_, permission);
219 if (!context) 223 if (!context)
220 return content::PERMISSION_STATUS_DENIED; 224 return content::PERMISSION_STATUS_DENIED;
221 225
222 return ContentSettingToPermissionStatus( 226 return ContentSettingToPermissionStatus(context->GetPermissionStatus(
223 context->GetPermissionStatus(requesting_origin.GetOrigin(), 227 requesting_origin.GetOrigin(), embedding_origin.GetOrigin()));
224 embedding_origin.GetOrigin()));
225 } 228 }
226 229
227 void PermissionManager::RegisterPermissionUsage(PermissionType permission, 230 void PermissionManager::RegisterPermissionUsage(PermissionType permission,
228 const GURL& requesting_origin, 231 const GURL& requesting_origin,
229 const GURL& embedding_origin) { 232 const GURL& embedding_origin) {
230 // This is required because constant permissions don't have a 233 // This is required because constant permissions don't have a
231 // ContentSettingsType. 234 // ContentSettingsType.
232 if (IsConstantPermission(permission)) 235 if (IsConstantPermission(permission))
233 return; 236 return;
234 237
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 // Add the callback to |callbacks| which will be run after the loop to 318 // Add the callback to |callbacks| which will be run after the loop to
316 // prevent re-entrance issues. 319 // prevent re-entrance issues.
317 callbacks.push_back( 320 callbacks.push_back(
318 base::Bind(subscription->callback, 321 base::Bind(subscription->callback,
319 ContentSettingToPermissionStatus(new_value))); 322 ContentSettingToPermissionStatus(new_value)));
320 } 323 }
321 324
322 for (const auto& callback : callbacks) 325 for (const auto& callback : callbacks)
323 callback.Run(); 326 callback.Run();
324 } 327 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698