request_type.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. // Copyright 2020 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_PERMISSIONS_REQUEST_TYPE_H_
  5. #define COMPONENTS_PERMISSIONS_REQUEST_TYPE_H_
  6. #include "build/build_config.h"
  7. #include "build/chromeos_buildflags.h"
  8. #include "third_party/abseil-cpp/absl/types/optional.h"
  9. enum class ContentSettingsType;
  10. namespace gfx {
  11. struct VectorIcon;
  12. }
  13. namespace permissions {
  14. // The type of the request that will be seen by the user. Values are only
  15. // defined on the platforms where they are used and should be kept alphabetized.
  16. enum class RequestType {
  17. kAccessibilityEvents,
  18. kArSession,
  19. #if !BUILDFLAG(IS_ANDROID)
  20. kCameraPanTiltZoom,
  21. #endif
  22. kCameraStream,
  23. kClipboard,
  24. kDiskQuota,
  25. #if !BUILDFLAG(IS_ANDROID)
  26. kLocalFonts,
  27. #endif
  28. kGeolocation,
  29. kIdleDetection,
  30. kMicStream,
  31. kMidiSysex,
  32. kMultipleDownloads,
  33. #if BUILDFLAG(IS_ANDROID)
  34. kNfcDevice,
  35. #endif
  36. kNotifications,
  37. #if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_WIN)
  38. kProtectedMediaIdentifier,
  39. #endif
  40. #if !BUILDFLAG(IS_ANDROID)
  41. kRegisterProtocolHandler,
  42. kSecurityAttestation,
  43. #endif
  44. kStorageAccess,
  45. #if !BUILDFLAG(IS_ANDROID)
  46. kU2fApiRequest,
  47. #endif
  48. kVrSession,
  49. #if !BUILDFLAG(IS_ANDROID)
  50. kWindowPlacement,
  51. kMaxValue = kWindowPlacement
  52. #else
  53. kMaxValue = kVrSession
  54. #endif
  55. };
  56. #if BUILDFLAG(IS_ANDROID)
  57. // On Android, icons are represented with an IDR_ identifier.
  58. using IconId = int;
  59. #else
  60. // On desktop, we use a vector icon.
  61. typedef const gfx::VectorIcon& IconId;
  62. #endif
  63. bool IsRequestablePermissionType(ContentSettingsType content_settings_type);
  64. RequestType ContentSettingsTypeToRequestType(
  65. ContentSettingsType content_settings_type);
  66. absl::optional<ContentSettingsType> RequestTypeToContentSettingsType(
  67. RequestType request_type);
  68. // Returns the icon to display.
  69. IconId GetIconId(RequestType type);
  70. #if !BUILDFLAG(IS_ANDROID)
  71. // Returns the blocked icon to display.
  72. IconId GetBlockedIconId(RequestType type);
  73. #endif
  74. // Returns a unique human-readable string that can be used in dictionaries that
  75. // are keyed by the RequestType.
  76. const char* PermissionKeyForRequestType(permissions::RequestType request_type);
  77. } // namespace permissions
  78. #endif // COMPONENTS_PERMISSIONS_REQUEST_TYPE_H_