| OLD | NEW |
| 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_stream_device_permission_context.h" | 5 #include "chrome/browser/media/webrtc/media_stream_device_permission_context.h" |
| 6 #include "chrome/browser/media/webrtc/media_stream_device_permissions.h" | 6 #include "chrome/browser/media/webrtc/media_stream_device_permissions.h" |
| 7 #include "chrome/browser/profiles/profile.h" | 7 #include "chrome/browser/profiles/profile.h" |
| 8 #include "chrome/common/pref_names.h" | 8 #include "chrome/common/pref_names.h" |
| 9 #include "components/content_settings/core/browser/host_content_settings_map.h" | 9 #include "components/content_settings/core/browser/host_content_settings_map.h" |
| 10 #include "components/content_settings/core/common/content_settings.h" | 10 #include "components/content_settings/core/common/content_settings.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 void MediaStreamDevicePermissionContext::RequestPermission( | 26 void MediaStreamDevicePermissionContext::RequestPermission( |
| 27 content::WebContents* web_contents, | 27 content::WebContents* web_contents, |
| 28 const PermissionRequestID& id, | 28 const PermissionRequestID& id, |
| 29 const GURL& requesting_frame, | 29 const GURL& requesting_frame, |
| 30 bool user_gesture, | 30 bool user_gesture, |
| 31 const BrowserPermissionCallback& callback) { | 31 const BrowserPermissionCallback& callback) { |
| 32 NOTREACHED() << "RequestPermission is not implemented"; | 32 NOTREACHED() << "RequestPermission is not implemented"; |
| 33 callback.Run(CONTENT_SETTING_BLOCK); | 33 callback.Run(CONTENT_SETTING_BLOCK); |
| 34 } | 34 } |
| 35 | 35 |
| 36 ContentSetting MediaStreamDevicePermissionContext::GetPermissionStatus( | 36 ContentSetting MediaStreamDevicePermissionContext::GetPermissionStatusInternal( |
| 37 const GURL& requesting_origin, | 37 const GURL& requesting_origin, |
| 38 const GURL& embedding_origin) const { | 38 const GURL& embedding_origin) const { |
| 39 // TODO(raymes): Merge this policy check into content settings | 39 // TODO(raymes): Merge this policy check into content settings |
| 40 // crbug.com/244389. | 40 // crbug.com/244389. |
| 41 const char* policy_name = nullptr; | 41 const char* policy_name = nullptr; |
| 42 const char* urls_policy_name = nullptr; | 42 const char* urls_policy_name = nullptr; |
| 43 if (content_settings_type_ == CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC) { | 43 if (content_settings_type_ == CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC) { |
| 44 policy_name = prefs::kAudioCaptureAllowed; | 44 policy_name = prefs::kAudioCaptureAllowed; |
| 45 urls_policy_name = prefs::kAudioCaptureAllowedUrls; | 45 urls_policy_name = prefs::kAudioCaptureAllowedUrls; |
| 46 } else { | 46 } else { |
| 47 DCHECK(content_settings_type_ == CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA); | 47 DCHECK(content_settings_type_ == CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA); |
| 48 policy_name = prefs::kVideoCaptureAllowed; | 48 policy_name = prefs::kVideoCaptureAllowed; |
| 49 urls_policy_name = prefs::kVideoCaptureAllowedUrls; | 49 urls_policy_name = prefs::kVideoCaptureAllowedUrls; |
| 50 } | 50 } |
| 51 | 51 |
| 52 MediaStreamDevicePolicy policy = GetDevicePolicy( | 52 MediaStreamDevicePolicy policy = GetDevicePolicy( |
| 53 profile(), requesting_origin, policy_name, urls_policy_name); | 53 profile(), requesting_origin, policy_name, urls_policy_name); |
| 54 | 54 |
| 55 switch (policy) { | 55 switch (policy) { |
| 56 case ALWAYS_DENY: | 56 case ALWAYS_DENY: |
| 57 return CONTENT_SETTING_BLOCK; | 57 return CONTENT_SETTING_BLOCK; |
| 58 case ALWAYS_ALLOW: | 58 case ALWAYS_ALLOW: |
| 59 return CONTENT_SETTING_ALLOW; | 59 return CONTENT_SETTING_ALLOW; |
| 60 default: | 60 default: |
| 61 DCHECK_EQ(POLICY_NOT_SET, policy); | 61 DCHECK_EQ(POLICY_NOT_SET, policy); |
| 62 } | 62 } |
| 63 | 63 |
| 64 // Check the content setting. TODO(raymes): currently mic/camera permission | 64 // Check the content setting. TODO(raymes): currently mic/camera permission |
| 65 // doesn't consider the embedder. | 65 // doesn't consider the embedder. |
| 66 ContentSetting setting = PermissionContextBase::GetPermissionStatus( | 66 ContentSetting setting = PermissionContextBase::GetPermissionStatusInternal( |
| 67 requesting_origin, requesting_origin); | 67 requesting_origin, requesting_origin); |
| 68 | 68 |
| 69 if (setting == CONTENT_SETTING_DEFAULT) | 69 if (setting == CONTENT_SETTING_DEFAULT) |
| 70 setting = CONTENT_SETTING_ASK; | 70 setting = CONTENT_SETTING_ASK; |
| 71 | 71 |
| 72 return setting; | 72 return setting; |
| 73 } | 73 } |
| 74 | 74 |
| 75 void MediaStreamDevicePermissionContext::ResetPermission( | 75 void MediaStreamDevicePermissionContext::ResetPermission( |
| 76 const GURL& requesting_origin, | 76 const GURL& requesting_origin, |
| 77 const GURL& embedding_origin) { | 77 const GURL& embedding_origin) { |
| 78 NOTREACHED() << "ResetPermission is not implemented"; | 78 NOTREACHED() << "ResetPermission is not implemented"; |
| 79 } | 79 } |
| 80 | 80 |
| 81 void MediaStreamDevicePermissionContext::CancelPermissionRequest( | 81 void MediaStreamDevicePermissionContext::CancelPermissionRequest( |
| 82 content::WebContents* web_contents, | 82 content::WebContents* web_contents, |
| 83 const PermissionRequestID& id) { | 83 const PermissionRequestID& id) { |
| 84 NOTREACHED() << "CancelPermissionRequest is not implemented"; | 84 NOTREACHED() << "CancelPermissionRequest is not implemented"; |
| 85 } | 85 } |
| 86 | 86 |
| 87 bool MediaStreamDevicePermissionContext::IsRestrictedToSecureOrigins() const { | 87 bool MediaStreamDevicePermissionContext::IsRestrictedToSecureOrigins() const { |
| 88 // Flash currently doesn't require secure origin to use mic/camera. If we | 88 // Flash currently doesn't require secure origin to use mic/camera. If we |
| 89 // return true here, it'll break the use case like http://tinychat.com. | 89 // return true here, it'll break the use case like http://tinychat.com. |
| 90 // TODO(raymes): Change this to true after crbug.com/526324 is fixed. | 90 // TODO(raymes): Change this to true after crbug.com/526324 is fixed. |
| 91 return false; | 91 return false; |
| 92 } | 92 } |
| OLD | NEW |