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

Side by Side Diff: chrome/browser/ui/media_utils.cc

Issue 2642763003: Remove chrome/browser/ui/media_utils.{cc|h} (Closed)
Patch Set: rebase and address review comments Created 3 years, 11 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
« no previous file with comments | « chrome/browser/ui/media_utils.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/ui/media_utils.h"
6
7 #include "chrome/browser/media/webrtc/media_capture_devices_dispatcher.h"
8 #include "chrome/browser/profiles/profile.h"
9 #include "content/public/browser/web_contents.h"
10 #include "extensions/features/features.h"
11
12 #if BUILDFLAG(ENABLE_EXTENSIONS)
13 #include "extensions/browser/extension_registry.h"
14 #include "extensions/common/constants.h"
15 #endif
16
17 namespace {
18
19 #if BUILDFLAG(ENABLE_EXTENSIONS)
20 const extensions::Extension* GetExtensionForOrigin(Profile* profile,
21 const GURL& security_origin) {
22 if (!security_origin.SchemeIs(extensions::kExtensionScheme))
23 return NULL;
24
25 const extensions::Extension* extension =
26 extensions::ExtensionRegistry::Get(profile)->enabled_extensions().GetByID(
27 security_origin.host());
28 DCHECK(extension);
29 return extension;
30 }
31 #endif
32
33 } // namespace
34
35 void RequestMediaAccessPermission(
36 content::WebContents* web_contents,
37 Profile* profile,
38 const content::MediaStreamRequest& request,
39 const content::MediaResponseCallback& callback) {
40 const extensions::Extension* extension = NULL;
41 #if BUILDFLAG(ENABLE_EXTENSIONS)
42 extension = GetExtensionForOrigin(profile, request.security_origin);
43 #endif
44 MediaCaptureDevicesDispatcher::GetInstance()->ProcessMediaAccessRequest(
45 web_contents, request, callback, extension);
46 }
47
48 bool CheckMediaAccessPermission(content::WebContents* web_contents,
49 const GURL& security_origin,
50 content::MediaStreamType type) {
51 #if BUILDFLAG(ENABLE_EXTENSIONS)
52 Profile* profile =
53 Profile::FromBrowserContext(web_contents->GetBrowserContext());
54 const extensions::Extension* extension =
55 GetExtensionForOrigin(profile, security_origin);
56 if (extension) {
57 return MediaCaptureDevicesDispatcher::GetInstance()
58 ->CheckMediaAccessPermission(
59 web_contents, security_origin, type, extension);
60 }
61 return MediaCaptureDevicesDispatcher::GetInstance()
62 ->CheckMediaAccessPermission(web_contents, security_origin, type);
63 #else
64 return MediaCaptureDevicesDispatcher::GetInstance()
65 ->CheckMediaAccessPermission(web_contents, security_origin, type);
66 #endif
67 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/media_utils.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698