Chromium Code Reviews| 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/media_stream_device_permission_context.h" | |
| 6 #include "chrome/browser/media/media_stream_device_permissions.h" | |
| 7 #include "chrome/browser/profiles/profile.h" | |
| 8 #include "chrome/common/pref_names.h" | |
| 9 #include "components/content_settings/core/browser/host_content_settings_map.h" | |
| 10 | |
| 11 MediaStreamDevicePermissionContext::MediaStreamDevicePermissionContext( | |
| 12 Profile* profile, | |
| 13 const ContentSettingsType permission_type) | |
| 14 : PermissionContextBase(profile, permission_type), | |
| 15 permission_type_(permission_type) { | |
|
raymes
2015/08/27 05:54:18
I'd suggest naming this content_type_ (to distingu
xhwang
2015/08/27 19:25:17
+1, or just strictly follow the type name: content
guoweis_left_chromium
2015/08/27 23:18:34
Done.
| |
| 16 CHECK(permission_type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC || | |
|
raymes
2015/08/27 05:54:18
Should be DCHECK - use CHECK sparingly
guoweis_left_chromium
2015/08/27 23:18:34
Done.
| |
| 17 permission_type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA); | |
|
mlamouri (slow - plz ping)
2015/08/27 10:03:40
nit: you might want to check the member, not the a
guoweis_left_chromium
2015/08/27 23:18:34
Done.
| |
| 18 } | |
| 19 | |
| 20 MediaStreamDevicePermissionContext::~MediaStreamDevicePermissionContext() {} | |
| 21 | |
| 22 void MediaStreamDevicePermissionContext::RequestPermission( | |
| 23 content::WebContents* web_contents, | |
| 24 const PermissionRequestID& id, | |
| 25 const GURL& requesting_frame, | |
| 26 bool user_gesture, | |
| 27 const BrowserPermissionCallback& callback) { | |
| 28 NOTREACHED() << "RequestPermission is not implemented"; | |
|
mlamouri (slow - plz ping)
2015/08/27 10:03:40
This would only fail in DEBUG. Could you resolve t
guoweis_left_chromium
2015/08/27 23:18:34
Done.
| |
| 29 } | |
| 30 | |
| 31 ContentSetting MediaStreamDevicePermissionContext::GetPermissionStatus( | |
| 32 const GURL& requesting_origin, | |
| 33 const GURL& embedding_origin) const { | |
| 34 // TODO(raymes): Merge this policy check into content settings | |
| 35 // crbug.com/244389. | |
| 36 const char* policy_name = nullptr; | |
| 37 const char* urls_policy_name = nullptr; | |
| 38 if (permission_type_ == CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC) { | |
| 39 policy_name = prefs::kAudioCaptureAllowed; | |
| 40 urls_policy_name = prefs::kAudioCaptureAllowedUrls; | |
|
xhwang
2015/08/27 19:25:17
err, here we are using another set of names:
Audi
| |
| 41 } else if (permission_type_ == CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA) { | |
| 42 policy_name = prefs::kVideoCaptureAllowed; | |
| 43 urls_policy_name = prefs::kVideoCaptureAllowedUrls; | |
| 44 } else { | |
| 45 NOTREACHED(); | |
|
mlamouri (slow - plz ping)
2015/08/27 10:03:39
NOTREACHED() probably not needed, we are checking
guoweis_left_chromium
2015/08/27 23:18:34
Done.
| |
| 46 } | |
| 47 | |
| 48 MediaStreamDevicePolicy policy = GetDevicePolicy( | |
| 49 profile(), requesting_origin, policy_name, urls_policy_name); | |
| 50 | |
| 51 if (policy == ALWAYS_DENY) | |
| 52 return CONTENT_SETTING_BLOCK; | |
|
raymes
2015/08/27 05:54:18
nit: include components/content_settings/core/comm
guoweis_left_chromium
2015/08/27 23:18:34
Done.
| |
| 53 | |
| 54 if (policy == ALWAYS_ALLOW) | |
| 55 return CONTENT_SETTING_ALLOW; | |
| 56 | |
| 57 DCHECK_EQ(policy, POLICY_NOT_SET); | |
|
raymes
2015/08/27 05:54:18
nit: the arguments are in the wrong order
guoweis_left_chromium
2015/08/27 23:18:34
Done.
| |
| 58 // Check the content setting. | |
| 59 ContentSetting setting = PermissionContextBase::GetPermissionStatus( | |
| 60 requesting_origin, embedding_origin); | |
| 61 | |
| 62 if (setting == CONTENT_SETTING_DEFAULT) | |
| 63 return CONTENT_SETTING_ASK; | |
| 64 | |
| 65 return setting; | |
|
mlamouri (slow - plz ping)
2015/08/27 10:03:39
nit: you might want to do:
return setting == CONTE
guoweis_left_chromium
2015/08/27 23:18:34
Done.
| |
| 66 } | |
| 67 | |
| 68 void MediaStreamDevicePermissionContext::ResetPermission( | |
| 69 const GURL& requesting_origin, | |
| 70 const GURL& embedding_origin) { | |
| 71 NOTREACHED() << "ResetPermission is not implemented"; | |
| 72 } | |
| 73 | |
| 74 void MediaStreamDevicePermissionContext::CancelPermissionRequest( | |
| 75 content::WebContents* web_contents, | |
| 76 const PermissionRequestID& id) { | |
| 77 NOTREACHED() << "CancelPermissionRequest is not implemented"; | |
| 78 } | |
| 79 | |
| 80 bool MediaStreamDevicePermissionContext::IsRestrictedToSecureOrigins() const { | |
| 81 return true; | |
| 82 } | |
|
raymes
2015/08/27 05:54:18
Mounir: we actually can't do this yet. The reason
mlamouri (slow - plz ping)
2015/08/27 10:03:40
I don't think we should try to use PermissionConte
guoweis_left_chromium
2015/08/27 23:18:34
Are we saying to keep media_permission the same as
| |
| OLD | NEW |