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 CHECK(permission_type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC || | |
| 16 permission_type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA); | |
| 17 } | |
| 18 | |
| 19 MediaStreamDevicePermissionContext::~MediaStreamDevicePermissionContext() {} | |
| 20 | |
| 21 bool MediaStreamDevicePermissionContext::IsRestrictedToSecureOrigins() const { | |
|
raymes
2015/08/26 03:07:36
Please keep functions in the same order as the hea
guoweis_left_chromium
2015/08/26 22:29:57
Done.
| |
| 22 return true; | |
| 23 } | |
| 24 | |
| 25 void MediaStreamDevicePermissionContext::RequestPermission( | |
| 26 content::WebContents* web_contents, | |
| 27 const PermissionRequestID& id, | |
| 28 const GURL& requesting_frame, | |
| 29 bool user_gesture, | |
| 30 const BrowserPermissionCallback& callback) { | |
| 31 CHECK(0) << "RequestPermission is not implemented"; | |
|
raymes
2015/08/26 03:07:36
We would typically use NOTREACHED() here. (and bel
guoweis_left_chromium
2015/08/26 22:29:57
Done.
| |
| 32 } | |
| 33 | |
| 34 ContentSetting MediaStreamDevicePermissionContext::GetPermissionStatus( | |
| 35 const GURL& requesting_origin, | |
| 36 const GURL& embedding_origin) const { | |
| 37 // TODO(raymes): Merge this policy check into content settings | |
| 38 // crbug.com/244389. | |
| 39 const char* policy_name = nullptr; | |
| 40 const char* urls_policy_name = nullptr; | |
| 41 if (content_settings_type() == CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC) { | |
| 42 policy_name = prefs::kAudioCaptureAllowed; | |
| 43 urls_policy_name = prefs::kAudioCaptureAllowedUrls; | |
| 44 } else if (content_settings_type() == | |
| 45 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA) { | |
| 46 policy_name = prefs::kVideoCaptureAllowed; | |
| 47 urls_policy_name = prefs::kVideoCaptureAllowedUrls; | |
| 48 } else { | |
| 49 NOTREACHED(); | |
| 50 } | |
| 51 | |
| 52 // TODO(guoweis): why are we using embedding_origin? | |
|
raymes
2015/08/26 03:07:36
You tell me: why are we using embedding origin :)?
mlamouri (slow - plz ping)
2015/08/26 13:49:34
If embedder.com has an iframe to website.com and w
guoweis_left_chromium
2015/08/26 22:29:57
Done.
| |
| 53 MediaStreamDevicePolicy policy = GetDevicePolicy( | |
| 54 profile(), embedding_origin, policy_name, urls_policy_name); | |
| 55 | |
| 56 if (policy == ALWAYS_DENY) | |
| 57 return CONTENT_SETTING_BLOCK; | |
| 58 | |
| 59 if (policy == ALWAYS_ALLOW) | |
| 60 return CONTENT_SETTING_ALLOW; | |
| 61 | |
| 62 DCHECK(policy == POLICY_NOT_SET); | |
|
raymes
2015/08/26 03:07:36
DCHECK_EQ
guoweis_left_chromium
2015/08/26 22:29:57
Done.
| |
| 63 // Check the content setting. | |
| 64 ContentSetting setting = | |
| 65 profile()->GetHostContentSettingsMap()->GetContentSetting( | |
| 66 requesting_origin, embedding_origin, content_settings_type(), | |
|
raymes
2015/08/26 03:07:36
This should use requesting_origin, requesting_orig
mlamouri (slow - plz ping)
2015/08/26 13:49:34
Could you just call PermissionContextBase::GetPerm
guoweis_left_chromium
2015/08/26 22:29:57
Done.
raymes
2015/08/27 05:54:18
This will break the current behavior for the media
| |
| 67 content_settings::ResourceIdentifier()); | |
| 68 | |
| 69 if (setting == CONTENT_SETTING_DEFAULT) | |
| 70 return CONTENT_SETTING_ASK; | |
| 71 | |
| 72 return setting; | |
| 73 } | |
| 74 | |
| 75 void MediaStreamDevicePermissionContext::ResetPermission( | |
| 76 const GURL& requesting_origin, | |
| 77 const GURL& embedding_origin) { | |
| 78 CHECK(0) << "ResetPermission is not implemented"; | |
| 79 } | |
| 80 | |
| 81 void MediaStreamDevicePermissionContext::CancelPermissionRequest( | |
| 82 content::WebContents* web_contents, | |
| 83 const PermissionRequestID& id) { | |
| 84 CHECK(0) << "CancelPermissionRequest is not implemented"; | |
| 85 } | |
| OLD | NEW |