1 // Copyright 2020 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef COMPONENTS_PERMISSIONS_REQUEST_TYPE_H_
6 #define COMPONENTS_PERMISSIONS_REQUEST_TYPE_H_
8 #include "build/build_config.h"
9 #include "build/chromeos_buildflags.h"
10 #include "third_party/abseil-cpp/absl/types/optional.h"
12 enum class ContentSettingsType;
18 namespace permissions {
20 // The type of the request that will be seen by the user. Values are only
21 // defined on the platforms where they are used and should be kept alphabetized.
22 enum class RequestType {
25 #if !BUILDFLAG(IS_ANDROID)
30 kTopLevelStorageAccess,
32 #if !BUILDFLAG(IS_ANDROID)
37 #if !BUILDFLAG(IS_ANDROID)
44 #if BUILDFLAG(IS_ANDROID)
48 #if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_WIN)
49 kProtectedMediaIdentifier,
51 #if !BUILDFLAG(IS_ANDROID)
52 kRegisterProtocolHandler,
56 #if !BUILDFLAG(IS_ANDROID)
58 kMaxValue = kWindowManagement
60 kMaxValue = kVrSession
64 #if BUILDFLAG(IS_ANDROID)
65 // On Android, icons are represented with an IDR_ identifier.
68 // On desktop, we use a vector icon.
69 typedef const gfx::VectorIcon& IconId;
72 bool IsRequestablePermissionType(ContentSettingsType content_settings_type);
74 absl::optional<RequestType> ContentSettingsTypeToRequestTypeIfExists(
75 ContentSettingsType content_settings_type);
77 RequestType ContentSettingsTypeToRequestType(
78 ContentSettingsType content_settings_type);
80 absl::optional<ContentSettingsType> RequestTypeToContentSettingsType(
81 RequestType request_type);
83 // Returns whether confirmation chips can be displayed
84 bool IsConfirmationChipSupported(RequestType for_request_type);
86 // Returns the icon to display.
87 IconId GetIconId(RequestType type);
89 #if !BUILDFLAG(IS_ANDROID)
90 // Returns the blocked icon to display.
91 IconId GetBlockedIconId(RequestType type);
94 // Returns a unique human-readable string that can be used in dictionaries that
95 // are keyed by the RequestType.
96 const char* PermissionKeyForRequestType(permissions::RequestType request_type);
98 } // namespace permissions
100 #endif // COMPONENTS_PERMISSIONS_REQUEST_TYPE_H_