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

Side by Side 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: Fix. 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/ui/media_utils.h" 5 #include "chrome/browser/ui/media_utils.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/profiles/profile.h" 8 #include "chrome/browser/profiles/profile.h"
9 #include "content/public/browser/web_contents.h"
9 10
10 #if defined(ENABLE_EXTENSIONS) 11 #if defined(ENABLE_EXTENSIONS)
11 #include "chrome/browser/extensions/extension_service.h" 12 #include "chrome/browser/extensions/extension_service.h"
12 #include "extensions/browser/extension_system.h" 13 #include "extensions/browser/extension_system.h"
13 #include "extensions/common/constants.h" 14 #include "extensions/common/constants.h"
14 #endif 15 #endif
15 16
16 class Profile; 17 namespace {
17 18
18 namespace content { 19 #if defined(ENABLE_EXTENSIONS)
19 class WebContents; 20 const extensions::Extension* GetExtensionForOrigin(Profile* profile,
21 const GURL& security_origin) {
22 if (!security_origin.SchemeIs(extensions::kExtensionScheme))
23 return NULL;
24
25 ExtensionService* extensions_service =
26 extensions::ExtensionSystem::Get(profile)->extension_service();
27 const extensions::Extension* extension =
28 extensions_service->extensions()->GetByID(security_origin.host());
29 DCHECK(extension);
30 return extension;
20 } 31 }
32 #endif
33
34 } // namespace
21 35
22 void RequestMediaAccessPermission( 36 void RequestMediaAccessPermission(
23 content::WebContents* web_contents, 37 content::WebContents* web_contents,
24 Profile* profile, 38 Profile* profile,
25 const content::MediaStreamRequest& request, 39 const content::MediaStreamRequest& request,
26 const content::MediaResponseCallback& callback) { 40 const content::MediaResponseCallback& callback) {
27 const extensions::Extension* extension = NULL; 41 const extensions::Extension* extension = NULL;
28 #if defined(ENABLE_EXTENSIONS) 42 #if defined(ENABLE_EXTENSIONS)
29 GURL origin(request.security_origin); 43 extension = GetExtensionForOrigin(profile, request.security_origin);
30 if (origin.SchemeIs(extensions::kExtensionScheme)) {
31 ExtensionService* extensions_service =
32 extensions::ExtensionSystem::Get(profile)->extension_service();
33 extension = extensions_service->extensions()->GetByID(origin.host());
34 DCHECK(extension);
35 }
36 #endif 44 #endif
37
38 MediaCaptureDevicesDispatcher::GetInstance()->ProcessMediaAccessRequest( 45 MediaCaptureDevicesDispatcher::GetInstance()->ProcessMediaAccessRequest(
39 web_contents, request, callback, extension); 46 web_contents, request, callback, extension);
40 } 47 }
48
49 bool CheckMediaAccessPermission(content::WebContents* web_contents,
50 const GURL& security_origin,
51 content::MediaStreamType type) {
52 #if defined(ENABLE_EXTENSIONS)
53 Profile* profile =
54 Profile::FromBrowserContext(web_contents->GetBrowserContext());
55 const extensions::Extension* extension =
56 GetExtensionForOrigin(profile, security_origin);
57 if (extension) {
58 return MediaCaptureDevicesDispatcher::GetInstance()
59 ->CheckMediaAccessPermission(
60 web_contents, security_origin, type, extension);
61 } else {
sky 2014/09/17 15:46:47 nit: no else after a return (see style guide).
Henrik Grunell 2014/09/17 20:00:17 Done.
62 return MediaCaptureDevicesDispatcher::GetInstance()
63 ->CheckMediaAccessPermission(web_contents, security_origin, type);
64 }
65 #else
66 return MediaCaptureDevicesDispatcher::GetInstance()
67 ->CheckMediaAccessPermission(web_contents, security_origin, type);
68 #endif
69 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/media_utils.h ('k') | content/browser/frame_host/render_frame_host_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698