Chromium Code Reviews| Index: chrome/browser/ui/media_utils.cc |
| diff --git a/chrome/browser/ui/media_utils.cc b/chrome/browser/ui/media_utils.cc |
| index 7101cc44ea1be8ae9a351c8ec7b54cabeca5f4b1..8096d6e22bd6565082a5d40cd1b340d496f8d2e8 100644 |
| --- a/chrome/browser/ui/media_utils.cc |
| +++ b/chrome/browser/ui/media_utils.cc |
| @@ -6,6 +6,7 @@ |
| #include "chrome/browser/media/media_capture_devices_dispatcher.h" |
| #include "chrome/browser/profiles/profile.h" |
| +#include "content/public/browser/web_contents.h" |
| #if defined(ENABLE_EXTENSIONS) |
| #include "chrome/browser/extensions/extension_service.h" |
| @@ -13,11 +14,24 @@ |
| #include "extensions/common/constants.h" |
| #endif |
| -class Profile; |
| +namespace { |
| -namespace content { |
| -class WebContents; |
| +#if defined(ENABLE_EXTENSIONS) |
| +const extensions::Extension* GetExtensionForOrigin(Profile* profile, |
| + const GURL& security_origin) { |
| + if (!security_origin.SchemeIs(extensions::kExtensionScheme)) |
| + return NULL; |
| + |
| + ExtensionService* extensions_service = |
| + extensions::ExtensionSystem::Get(profile)->extension_service(); |
| + const extensions::Extension* extension = |
| + extensions_service->extensions()->GetByID(security_origin.host()); |
| + DCHECK(extension); |
| + return extension; |
| } |
| +#endif |
| + |
| +} // namespace |
| void RequestMediaAccessPermission( |
| content::WebContents* web_contents, |
| @@ -26,15 +40,22 @@ void RequestMediaAccessPermission( |
| const content::MediaResponseCallback& callback) { |
| const extensions::Extension* extension = NULL; |
| #if defined(ENABLE_EXTENSIONS) |
| - GURL origin(request.security_origin); |
| - if (origin.SchemeIs(extensions::kExtensionScheme)) { |
| - ExtensionService* extensions_service = |
| - extensions::ExtensionSystem::Get(profile)->extension_service(); |
| - extension = extensions_service->extensions()->GetByID(origin.host()); |
| - DCHECK(extension); |
| - } |
| + extension = GetExtensionForOrigin(profile, request.security_origin); |
| #endif |
| - |
| MediaCaptureDevicesDispatcher::GetInstance()->ProcessMediaAccessRequest( |
| web_contents, request, callback, extension); |
| } |
| + |
| +bool CheckMediaAccessPermission(content::WebContents* web_contents, |
| + const GURL& security_origin, |
| + content::MediaStreamType type) { |
| + const extensions::Extension* extension = NULL; |
|
sky
2014/09/16 16:33:25
If ENABLE_EXTENSIONS is false, why are you passing
Henrik Grunell
2014/09/16 17:14:15
Do you think yet another function is better or did
|
| +#if defined(ENABLE_EXTENSIONS) |
| + Profile* profile = |
| + Profile::FromBrowserContext(web_contents->GetBrowserContext()); |
| + extension = GetExtensionForOrigin(profile, security_origin); |
| +#endif |
| + return MediaCaptureDevicesDispatcher::GetInstance() |
| + ->CheckMediaAccessPermission( |
| + web_contents, security_origin, type, extension); |
| +} |