| 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/media_stream_device_permission_context.h" | 5 #include "chrome/browser/media/media_stream_device_permission_context.h" |
| 6 #include "chrome/browser/media/media_stream_device_permissions.h" | 6 #include "chrome/browser/media/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 17 matching lines...) Expand all Loading... |
| 28 const PermissionRequestID& id, | 28 const PermissionRequestID& id, |
| 29 const GURL& requesting_frame, | 29 const GURL& requesting_frame, |
| 30 const BrowserPermissionCallback& callback) { | 30 const BrowserPermissionCallback& callback) { |
| 31 NOTREACHED() << "RequestPermission is not implemented"; | 31 NOTREACHED() << "RequestPermission is not implemented"; |
| 32 callback.Run(CONTENT_SETTING_BLOCK); | 32 callback.Run(CONTENT_SETTING_BLOCK); |
| 33 } | 33 } |
| 34 | 34 |
| 35 ContentSetting MediaStreamDevicePermissionContext::GetPermissionStatus( | 35 ContentSetting MediaStreamDevicePermissionContext::GetPermissionStatus( |
| 36 const GURL& requesting_origin, | 36 const GURL& requesting_origin, |
| 37 const GURL& embedding_origin) const { | 37 const GURL& embedding_origin) const { |
| 38 return GetPermissionStatusInternal(requesting_origin, embedding_origin, | |
| 39 false); | |
| 40 } | |
| 41 | |
| 42 ContentSetting MediaStreamDevicePermissionContext:: | |
| 43 GetPermissionStatusAllowingInsecureForPepper( | |
| 44 const GURL& requesting_origin, | |
| 45 const GURL& embedding_origin) const { | |
| 46 return GetPermissionStatusInternal(requesting_origin, embedding_origin, true); | |
| 47 } | |
| 48 | |
| 49 void MediaStreamDevicePermissionContext::ResetPermission( | |
| 50 const GURL& requesting_origin, | |
| 51 const GURL& embedding_origin) { | |
| 52 NOTREACHED() << "ResetPermission is not implemented"; | |
| 53 } | |
| 54 | |
| 55 void MediaStreamDevicePermissionContext::CancelPermissionRequest( | |
| 56 content::WebContents* web_contents, | |
| 57 const PermissionRequestID& id) { | |
| 58 NOTREACHED() << "CancelPermissionRequest is not implemented"; | |
| 59 } | |
| 60 | |
| 61 ContentSetting MediaStreamDevicePermissionContext::GetPermissionStatusInternal( | |
| 62 const GURL& requesting_origin, | |
| 63 const GURL& embedding_origin, | |
| 64 bool is_pepper_request) const { | |
| 65 // TODO(raymes): Merge this policy check into content settings | 38 // TODO(raymes): Merge this policy check into content settings |
| 66 // crbug.com/244389. | 39 // crbug.com/244389. |
| 67 const char* policy_name = nullptr; | 40 const char* policy_name = nullptr; |
| 68 const char* urls_policy_name = nullptr; | 41 const char* urls_policy_name = nullptr; |
| 69 if (content_settings_type_ == CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC) { | 42 if (content_settings_type_ == CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC) { |
| 70 policy_name = prefs::kAudioCaptureAllowed; | 43 policy_name = prefs::kAudioCaptureAllowed; |
| 71 urls_policy_name = prefs::kAudioCaptureAllowedUrls; | 44 urls_policy_name = prefs::kAudioCaptureAllowedUrls; |
| 72 } else { | 45 } else { |
| 73 DCHECK(content_settings_type_ == CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA); | 46 DCHECK(content_settings_type_ == CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA); |
| 74 policy_name = prefs::kVideoCaptureAllowed; | 47 policy_name = prefs::kVideoCaptureAllowed; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 88 } | 61 } |
| 89 | 62 |
| 90 // Check the content setting. TODO(raymes): currently mic/camera permission | 63 // Check the content setting. TODO(raymes): currently mic/camera permission |
| 91 // doesn't consider the embedder. | 64 // doesn't consider the embedder. |
| 92 ContentSetting setting = PermissionContextBase::GetPermissionStatus( | 65 ContentSetting setting = PermissionContextBase::GetPermissionStatus( |
| 93 requesting_origin, requesting_origin); | 66 requesting_origin, requesting_origin); |
| 94 | 67 |
| 95 if (setting == CONTENT_SETTING_DEFAULT) | 68 if (setting == CONTENT_SETTING_DEFAULT) |
| 96 setting = CONTENT_SETTING_ASK; | 69 setting = CONTENT_SETTING_ASK; |
| 97 | 70 |
| 98 // TODO(raymes): This is here for safety to ensure that we always ask the user | 71 return setting; |
| 99 // even if a content setting is set to "allow" if the origin is insecure. In | 72 } |
| 100 // reality we shouldn't really need to check this here as we should respect | |
| 101 // the user's content setting. The problem is that pepper requests allow | |
| 102 // insecure origins to be persisted. We should remove this after | |
| 103 // crbug.com/526324 is fixed. | |
| 104 if (!ShouldPersistContentSetting(setting, requesting_origin, | |
| 105 is_pepper_request) && | |
| 106 !requesting_origin.SchemeIs(extensions::kExtensionScheme) && | |
| 107 !requesting_origin.SchemeIs(content::kChromeUIScheme) && | |
| 108 !requesting_origin.SchemeIs(content::kChromeDevToolsScheme)) { | |
| 109 return CONTENT_SETTING_ASK; | |
| 110 } | |
| 111 | 73 |
| 112 return setting; | 74 void MediaStreamDevicePermissionContext::ResetPermission( |
| 75 const GURL& requesting_origin, |
| 76 const GURL& embedding_origin) { |
| 77 NOTREACHED() << "ResetPermission is not implemented"; |
| 78 } |
| 79 |
| 80 void MediaStreamDevicePermissionContext::CancelPermissionRequest( |
| 81 content::WebContents* web_contents, |
| 82 const PermissionRequestID& id) { |
| 83 NOTREACHED() << "CancelPermissionRequest is not implemented"; |
| 113 } | 84 } |
| 114 | 85 |
| 115 bool MediaStreamDevicePermissionContext::IsRestrictedToSecureOrigins() const { | 86 bool MediaStreamDevicePermissionContext::IsRestrictedToSecureOrigins() const { |
| 116 // Flash currently doesn't require secure origin to use mic/camera. If we | 87 // Flash currently doesn't require secure origin to use mic/camera. If we |
| 117 // return true here, it'll break the use case like http://tinychat.com. | 88 // return true here, it'll break the use case like http://tinychat.com. |
| 118 // TODO(raymes): Change this to true after crbug.com/526324 is fixed. | 89 // TODO(raymes): Change this to true after crbug.com/526324 is fixed. |
| 119 return false; | 90 return false; |
| 120 } | 91 } |
| OLD | NEW |