OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "chrome/browser/media/webrtc/media_permission.h" | |
6 | |
7 #include "chrome/browser/permissions/permission_context_base.h" | |
8 #include "chrome/browser/permissions/permission_manager.h" | |
9 #include "chrome/browser/profiles/profile.h" | |
10 #include "chrome/common/pref_names.h" | |
11 #include "content/public/browser/permission_manager.h" | |
12 #include "content/public/browser/web_contents.h" | |
13 #include "content/public/common/url_constants.h" | |
14 #include "extensions/common/constants.h" | |
15 | |
16 MediaPermission::MediaPermission(ContentSettingsType content_type, | |
17 const GURL& requesting_origin, | |
18 const GURL& embedding_origin, | |
19 Profile* profile, | |
20 content::WebContents* web_contents) | |
21 : content_type_(content_type), | |
22 requesting_origin_(requesting_origin), | |
23 embedding_origin_(embedding_origin), | |
24 profile_(profile), | |
25 web_contents_(web_contents) { | |
26 // Currently |web_contents_| is only used on ChromeOS but it's not worth | |
27 // #ifdef'ing out all its usage, so just mark it used here. | |
28 (void)web_contents_; | |
29 } | |
30 | |
31 ContentSetting MediaPermission::GetPermissionStatus( | |
32 content::MediaStreamRequestResult* denial_reason) const { | |
33 DCHECK(!requesting_origin_.is_empty()); | |
34 | |
35 PermissionManager* permission_manager = PermissionManager::Get(profile_); | |
36 | |
37 // Find out if the kill switch is on. Set the denial reason to kill switch. | |
38 if (permission_manager->IsPermissionKillSwitchOn(content_type_)) { | |
39 *denial_reason = content::MEDIA_DEVICE_KILL_SWITCH_ON; | |
40 return CONTENT_SETTING_BLOCK; | |
41 } | |
42 | |
43 // Check policy and content settings. | |
44 ContentSetting content_setting = | |
45 permission_manager | |
46 ->GetPermissionStatus(content_type_, requesting_origin_, | |
47 embedding_origin_) | |
48 .content_setting; | |
49 if (content_setting == CONTENT_SETTING_BLOCK) | |
50 *denial_reason = content::MEDIA_DEVICE_PERMISSION_DENIED; | |
51 return content_setting; | |
52 } | |
OLD | NEW |