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

Side by Side Diff: chrome/browser/media/webrtc/media_permission.cc

Issue 2746873004: Move ChromeOS login media access logic into a MediaAccessHandler (Closed)
Patch Set: Move SAML access logic into MediaAccessHandler Created 3 years, 9 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 2015 The Chromium Authors. All rights reserved. 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 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/media/webrtc/media_permission.h" 5 #include "chrome/browser/media/webrtc/media_permission.h"
6 6
7 #include "chrome/browser/media/webrtc/media_capture_devices_dispatcher.h"
8 #include "chrome/browser/media/webrtc/media_stream_device_permissions.h"
9 #include "chrome/browser/permissions/permission_context_base.h" 7 #include "chrome/browser/permissions/permission_context_base.h"
10 #include "chrome/browser/permissions/permission_manager.h" 8 #include "chrome/browser/permissions/permission_manager.h"
11 #include "chrome/browser/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
12 #include "chrome/common/pref_names.h" 10 #include "chrome/common/pref_names.h"
13 #include "content/public/browser/permission_manager.h" 11 #include "content/public/browser/permission_manager.h"
14 #include "content/public/browser/web_contents.h" 12 #include "content/public/browser/web_contents.h"
15 #include "content/public/common/url_constants.h" 13 #include "content/public/common/url_constants.h"
16 #include "extensions/common/constants.h" 14 #include "extensions/common/constants.h"
17 #include "third_party/WebKit/public/platform/modules/permissions/permission_stat us.mojom.h"
18
19 #if defined(OS_CHROMEOS)
20 #include "chrome/browser/chromeos/login/ui/login_display_host.h"
21 #include "chrome/browser/chromeos/login/ui/webui_login_view.h"
22 #include "chrome/browser/chromeos/settings/cros_settings.h"
23 #include "chromeos/settings/cros_settings_names.h"
24 #endif
25 15
26 MediaPermission::MediaPermission(ContentSettingsType content_type, 16 MediaPermission::MediaPermission(ContentSettingsType content_type,
27 const GURL& requesting_origin, 17 const GURL& requesting_origin,
28 const GURL& embedding_origin, 18 const GURL& embedding_origin,
29 Profile* profile, 19 Profile* profile,
30 content::WebContents* web_contents) 20 content::WebContents* web_contents)
31 : content_type_(content_type), 21 : content_type_(content_type),
32 requesting_origin_(requesting_origin), 22 requesting_origin_(requesting_origin),
33 embedding_origin_(embedding_origin), 23 embedding_origin_(embedding_origin),
34 profile_(profile), 24 profile_(profile),
(...skipping 13 matching lines...) Expand all
48 } 38 }
49 39
50 PermissionManager* permission_manager = PermissionManager::Get(profile_); 40 PermissionManager* permission_manager = PermissionManager::Get(profile_);
51 41
52 // Find out if the kill switch is on. Set the denial reason to kill switch. 42 // Find out if the kill switch is on. Set the denial reason to kill switch.
53 if (permission_manager->IsPermissionKillSwitchOn(content_type_)) { 43 if (permission_manager->IsPermissionKillSwitchOn(content_type_)) {
54 *denial_reason = content::MEDIA_DEVICE_KILL_SWITCH_ON; 44 *denial_reason = content::MEDIA_DEVICE_KILL_SWITCH_ON;
55 return CONTENT_SETTING_BLOCK; 45 return CONTENT_SETTING_BLOCK;
56 } 46 }
57 47
58 #if defined(OS_CHROMEOS)
59 // Special permissions if the request is coming from a ChromeOS login page.
60 chromeos::LoginDisplayHost* login_display_host =
61 chromeos::LoginDisplayHost::default_host();
62 chromeos::WebUILoginView* webui_login_view =
63 login_display_host ? login_display_host->GetWebUILoginView() : nullptr;
64 content::WebContents* login_web_contents =
65 webui_login_view ? webui_login_view->GetWebContents() : nullptr;
66 if (web_contents_ == login_web_contents) {
67 if (content_type_ == CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC) {
68 *denial_reason = content::MEDIA_DEVICE_PERMISSION_DENIED;
69 return CONTENT_SETTING_BLOCK;
70 }
71
72 const chromeos::CrosSettings* const settings =
73 chromeos::CrosSettings::Get();
74 if (!settings) {
75 *denial_reason = content::MEDIA_DEVICE_PERMISSION_DENIED;
76 return CONTENT_SETTING_BLOCK;
77 }
78
79 const base::Value* const raw_list_value =
80 settings->GetPref(chromeos::kLoginVideoCaptureAllowedUrls);
81 if (!raw_list_value) {
82 *denial_reason = content::MEDIA_DEVICE_PERMISSION_DENIED;
83 return CONTENT_SETTING_BLOCK;
84 }
85
86 const base::ListValue* list_value;
87 const bool is_list = raw_list_value->GetAsList(&list_value);
88 DCHECK(is_list);
89 for (const auto& base_value : *list_value) {
90 std::string value;
91 if (base_value->GetAsString(&value)) {
92 const ContentSettingsPattern pattern =
93 ContentSettingsPattern::FromString(value);
94 if (pattern == ContentSettingsPattern::Wildcard()) {
95 LOG(WARNING) << "Ignoring wildcard URL pattern: " << value;
96 continue;
97 }
98 if (pattern.IsValid() && pattern.Matches(requesting_origin_))
99 return CONTENT_SETTING_ALLOW;
100 }
101 }
102
103 *denial_reason = content::MEDIA_DEVICE_PERMISSION_DENIED;
104 return CONTENT_SETTING_BLOCK;
105 }
106 #endif // defined(OS_CHROMEOS)
107
108 // Check policy and content settings. 48 // Check policy and content settings.
109 ContentSetting content_setting = 49 ContentSetting content_setting =
110 permission_manager 50 permission_manager
111 ->GetPermissionStatus(content_type_, requesting_origin_, 51 ->GetPermissionStatus(content_type_, requesting_origin_,
112 embedding_origin_) 52 embedding_origin_)
113 .content_setting; 53 .content_setting;
114 if (content_setting == CONTENT_SETTING_BLOCK) 54 if (content_setting == CONTENT_SETTING_BLOCK)
115 *denial_reason = content::MEDIA_DEVICE_PERMISSION_DENIED; 55 *denial_reason = content::MEDIA_DEVICE_PERMISSION_DENIED;
116 return content_setting; 56 return content_setting;
117 } 57 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698