permission_context_utils.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. // Copyright 2021 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. #ifndef COMPONENTS_EMBEDDER_SUPPORT_PERMISSION_CONTEXT_UTILS_H_
  5. #define COMPONENTS_EMBEDDER_SUPPORT_PERMISSION_CONTEXT_UTILS_H_
  6. #include "base/memory/raw_ptr.h"
  7. #include "build/build_config.h"
  8. #include "components/permissions/contexts/camera_pan_tilt_zoom_permission_context.h"
  9. #include "components/permissions/contexts/geolocation_permission_context.h"
  10. #include "components/permissions/contexts/nfc_permission_context.h"
  11. #include "components/permissions/permission_manager.h"
  12. namespace content {
  13. class BrowserContext;
  14. } // namespace content
  15. #if BUILDFLAG(IS_MAC)
  16. namespace device {
  17. class GeolocationManager;
  18. } // namespace device
  19. #endif // BUILDFLAG(IS_MAC)
  20. namespace webrtc {
  21. class MediaStreamDeviceEnumerator;
  22. } // namespace webrtc
  23. namespace embedder_support {
  24. // Contains all delegates & helper classes needed to construct all default
  25. // permission contexts via CreateDefaultPermissionContexts().
  26. struct PermissionContextDelegates {
  27. PermissionContextDelegates();
  28. PermissionContextDelegates(PermissionContextDelegates&&);
  29. PermissionContextDelegates& operator=(PermissionContextDelegates&&);
  30. ~PermissionContextDelegates();
  31. std::unique_ptr<permissions::CameraPanTiltZoomPermissionContext::Delegate>
  32. camera_pan_tilt_zoom_permission_context_delegate;
  33. std::unique_ptr<permissions::GeolocationPermissionContext::Delegate>
  34. geolocation_permission_context_delegate;
  35. #if BUILDFLAG(IS_MAC)
  36. raw_ptr<device::GeolocationManager> geolocation_manager;
  37. #endif // BUILDFLAG(IS_MAC)
  38. raw_ptr<webrtc::MediaStreamDeviceEnumerator> media_stream_device_enumerator;
  39. std::unique_ptr<permissions::NfcPermissionContext::Delegate>
  40. nfc_permission_context_delegate;
  41. };
  42. // Creates default permission contexts shared between Content embedders.
  43. // Embedders are expected to populate all fields of |delegates| which are then
  44. // being used to create the specific permission contexts.
  45. permissions::PermissionManager::PermissionContextMap
  46. CreateDefaultPermissionContexts(content::BrowserContext* browser_context,
  47. PermissionContextDelegates delegates);
  48. } // namespace embedder_support
  49. #endif // COMPONENTS_EMBEDDER_SUPPORT_PERMISSION_CONTEXT_UTILS_H_