1 // Copyright 2019 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 #ifndef CHROME_BROWSER_MEDIA_WEBRTC_SYSTEM_MEDIA_CAPTURE_PERMISSIONS_MAC_H_ 6 #define CHROME_BROWSER_MEDIA_WEBRTC_SYSTEM_MEDIA_CAPTURE_PERMISSIONS_MAC_H_ 7 8 #include "base/callback_forward.h" 9 10 namespace base { 11 class TaskTraits; 12 } 13 14 namespace system_media_permissions { 15 16 class MediaAuthorizationWrapper; 17 18 // System permission state. These are also used in stats - do not remove or 19 // re-arrange the values. 20 enum class SystemPermission { 21 kNotDetermined = 0, 22 kRestricted = 1, 23 kDenied = 2, 24 kAllowed = 3, 25 kMaxValue = kAllowed 26 }; 27 28 // On 10.14 and above: returns the system permission. 29 // On 10.13 and below: returns |SystemPermission::kAllowed|, since there are no 30 // system media capture permissions. 31 SystemPermission CheckSystemAudioCapturePermission(); 32 SystemPermission CheckSystemVideoCapturePermission(); 33 34 // On 10.15 and above: returns the system permission. 35 // On 10.14 and below: returns |SystemPermission::kAllowed|, since there are no 36 // system screen capture permissions. 37 SystemPermission CheckSystemScreenCapturePermission(); 38 39 // On 10.14 and above: requests system permission and returns. When requesting 40 // permission, the OS will show a user dialog and respond asynchronously. At the 41 // response, |callback| is posted with |traits|. 42 // On 10.13 and below: posts |callback| with |traits|, since there are no system 43 // media capture permissions. 44 // Note: these functions should really never be called for pre-10.14 since one 45 // would normally check the permission first, and only call this if it's not 46 // determined. 47 void RequestSystemAudioCapturePermisson(base::OnceClosure callback, 48 const base::TaskTraits& traits); 49 void RequestSystemVideoCapturePermisson(base::OnceClosure callback, 50 const base::TaskTraits& traits); 51 52 // Sets the wrapper object for OS calls. For test mocking purposes. 53 void SetMediaAuthorizationWrapperForTesting(MediaAuthorizationWrapper* wrapper); 54 55 } // namespace system_media_permissions 56 57 #endif // CHROME_BROWSER_MEDIA_WEBRTC_SYSTEM_MEDIA_CAPTURE_PERMISSIONS_MAC_H_ 58