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

Unified Diff: chrome/browser/ui/media_utils.cc

Issue 562263002: Check media permissions through RenderFrameHostDelegate. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@render_frame_get_sources
Patch Set: git cl format. Don't blame me. Created 6 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 side-by-side diff with in-line comments
Download patch
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..c4801e8b4fca7abce45ef5ff401f71c7a7ae59e0 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"
@@ -15,26 +16,47 @@
class Profile;
-namespace content {
-class WebContents;
+namespace {
+
+const extensions::Extension* GetExtensionForOrigin(
+ Profile* profile,
+ const GURL& security_origin) {
+#if defined(ENABLE_EXTENSIONS)
sky 2014/09/12 16:19:14 How come you check ENABLE_EXTENSIONS here, but not
Henrik Grunell 2014/09/15 11:33:47 The ProcessMediaAccessRequest and CheckMediaAccess
+ 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;
+#else
+ return NULL;
+#endif
}
+} // namespace
+
void RequestMediaAccessPermission(
content::WebContents* web_contents,
Profile* profile,
const content::MediaStreamRequest& request,
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);
- }
-#endif
-
+ const extensions::Extension* extension =
+ GetExtensionForOrigin(profile, request.security_origin);
MediaCaptureDevicesDispatcher::GetInstance()->ProcessMediaAccessRequest(
web_contents, request, callback, extension);
}
+
+bool CheckMediaAccessPermission(content::WebContents* web_contents,
+ const GURL& security_origin,
+ content::MediaStreamType type) {
+ Profile* profile =
+ Profile::FromBrowserContext(web_contents->GetBrowserContext());
+ const extensions::Extension* extension =
+ GetExtensionForOrigin(profile, security_origin);
+ return MediaCaptureDevicesDispatcher::GetInstance()
+ ->CheckMediaAccessPermission(
+ web_contents, security_origin, type, extension);
+}

Powered by Google App Engine
This is Rietveld 408576698