| 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 content::WebContents* web_contents, | 26 content::WebContents* web_contents, |
| 27 const PermissionRequestID& id, | 27 const PermissionRequestID& id, |
| 28 const GURL& requesting_frame, | 28 const GURL& requesting_frame, |
| 29 bool user_gesture, | 29 bool user_gesture, |
| 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::GetPermissionStatusInternal( | 35 ContentSetting MediaStreamDevicePermissionContext::GetPermissionStatusInternal( |
| 36 content::RenderFrameHost* render_frame_host, |
| 36 const GURL& requesting_origin, | 37 const GURL& requesting_origin, |
| 37 const GURL& embedding_origin) const { | 38 const GURL& embedding_origin) const { |
| 38 // TODO(raymes): Merge this policy check into content settings | 39 // TODO(raymes): Merge this policy check into content settings |
| 39 // crbug.com/244389. | 40 // crbug.com/244389. |
| 40 const char* policy_name = nullptr; | 41 const char* policy_name = nullptr; |
| 41 const char* urls_policy_name = nullptr; | 42 const char* urls_policy_name = nullptr; |
| 42 if (content_settings_type_ == CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC) { | 43 if (content_settings_type_ == CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC) { |
| 43 policy_name = prefs::kAudioCaptureAllowed; | 44 policy_name = prefs::kAudioCaptureAllowed; |
| 44 urls_policy_name = prefs::kAudioCaptureAllowedUrls; | 45 urls_policy_name = prefs::kAudioCaptureAllowedUrls; |
| 45 } else { | 46 } else { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 56 return CONTENT_SETTING_BLOCK; | 57 return CONTENT_SETTING_BLOCK; |
| 57 case ALWAYS_ALLOW: | 58 case ALWAYS_ALLOW: |
| 58 return CONTENT_SETTING_ALLOW; | 59 return CONTENT_SETTING_ALLOW; |
| 59 default: | 60 default: |
| 60 DCHECK_EQ(POLICY_NOT_SET, policy); | 61 DCHECK_EQ(POLICY_NOT_SET, policy); |
| 61 } | 62 } |
| 62 | 63 |
| 63 // Check the content setting. TODO(raymes): currently mic/camera permission | 64 // Check the content setting. TODO(raymes): currently mic/camera permission |
| 64 // doesn't consider the embedder. | 65 // doesn't consider the embedder. |
| 65 ContentSetting setting = PermissionContextBase::GetPermissionStatusInternal( | 66 ContentSetting setting = PermissionContextBase::GetPermissionStatusInternal( |
| 66 requesting_origin, requesting_origin); | 67 render_frame_host, requesting_origin, requesting_origin); |
| 67 | 68 |
| 68 if (setting == CONTENT_SETTING_DEFAULT) | 69 if (setting == CONTENT_SETTING_DEFAULT) |
| 69 setting = CONTENT_SETTING_ASK; | 70 setting = CONTENT_SETTING_ASK; |
| 70 | 71 |
| 71 return setting; | 72 return setting; |
| 72 } | 73 } |
| 73 | 74 |
| 74 void MediaStreamDevicePermissionContext::ResetPermission( | 75 void MediaStreamDevicePermissionContext::ResetPermission( |
| 75 const GURL& requesting_origin, | 76 const GURL& requesting_origin, |
| 76 const GURL& embedding_origin) { | 77 const GURL& embedding_origin) { |
| 77 NOTREACHED() << "ResetPermission is not implemented"; | 78 NOTREACHED() << "ResetPermission is not implemented"; |
| 78 } | 79 } |
| 79 | 80 |
| 80 void MediaStreamDevicePermissionContext::CancelPermissionRequest( | 81 void MediaStreamDevicePermissionContext::CancelPermissionRequest( |
| 81 content::WebContents* web_contents, | 82 content::WebContents* web_contents, |
| 82 const PermissionRequestID& id) { | 83 const PermissionRequestID& id) { |
| 83 NOTREACHED() << "CancelPermissionRequest is not implemented"; | 84 NOTREACHED() << "CancelPermissionRequest is not implemented"; |
| 84 } | 85 } |
| 85 | 86 |
| 86 bool MediaStreamDevicePermissionContext::IsRestrictedToSecureOrigins() const { | 87 bool MediaStreamDevicePermissionContext::IsRestrictedToSecureOrigins() const { |
| 87 // 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 |
| 88 // 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. |
| 89 // 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. |
| 90 return false; | 91 return false; |
| 91 } | 92 } |
| OLD | NEW |