#include "components/permissions/request_type.h"
#include "base/check.h"
#include "base/containers/contains.h"
#include "base/containers/fixed_flat_set.h"
#include "base/feature_list.h"
#include "base/notreached.h"
#include "base/ranges/algorithm.h"
#include "build/build_config.h"
#include "components/permissions/features.h"
#include "components/permissions/permission_request.h"
#include "components/permissions/permissions_client.h"
#if BUILDFLAG(IS_ANDROID)
#include "components/resources/android/theme_resources.h"
#else
#include "components/permissions/vector_icons/vector_icons.h"
#include "components/vector_icons/vector_icons.h"
#include "ui/gfx/paint_vector_icon.h"
#include "ui/gfx/vector_icon_types.h"
#endif
namespace permissions {
namespace {
#if BUILDFLAG(IS_ANDROID)
int GetIconIdAndroid(RequestType type) {
switch (type) {
case RequestType::kAccessibilityEvents:
return IDR_ANDROID_INFOBAR_ACCESSIBILITY_EVENTS;
case RequestType::kArSession:
case RequestType::kVrSession:
return IDR_ANDROID_INFOBAR_VR_HEADSET;
case RequestType::kCameraStream:
return IDR_ANDROID_INFOBAR_MEDIA_STREAM_CAMERA;
case RequestType::kClipboard:
return IDR_ANDROID_INFOBAR_CLIPBOARD;
case RequestType::kDiskQuota:
return IDR_ANDROID_INFOBAR_FOLDER;
case RequestType::kGeolocation:
return IDR_ANDROID_INFOBAR_GEOLOCATION;
case RequestType::kHandTracking:
return IDR_ANDROID_INFOBAR_HAND_TRACKING;
case RequestType::kIdentityProvider:
return IDR_ANDROID_INFOBAR_IDENTITY_PROVIDER;
case RequestType::kIdleDetection:
return IDR_ANDROID_INFOBAR_IDLE_DETECTION;
case RequestType::kMicStream:
return IDR_ANDROID_INFOBAR_MEDIA_STREAM_MIC;
case RequestType::kMidiSysex:
return IDR_ANDROID_INFOBAR_MIDI;
case RequestType::kMultipleDownloads:
return IDR_ANDROID_INFOBAR_MULTIPLE_DOWNLOADS;
case RequestType::kNfcDevice:
return IDR_ANDROID_INFOBAR_NFC;
case RequestType::kNotifications:
return IDR_ANDROID_INFOBAR_NOTIFICATIONS;
case RequestType::kProtectedMediaIdentifier:
return IDR_ANDROID_INFOBAR_PROTECTED_MEDIA_IDENTIFIER;
case RequestType::kStorageAccess:
case RequestType::kTopLevelStorageAccess:
return IDR_ANDROID_STORAGE_ACCESS;
}
NOTREACHED_IN_MIGRATION();
return 0;
}
#endif
#if !BUILDFLAG(IS_ANDROID)
const gfx::VectorIcon& GetIconIdDesktop(RequestType type) { … }
const gfx::VectorIcon& GetBlockedIconIdDesktop(RequestType type) { … }
#endif
}
bool IsRequestablePermissionType(ContentSettingsType content_settings_type) { … }
std::optional<RequestType> ContentSettingsTypeToRequestTypeIfExists(
ContentSettingsType content_settings_type) { … }
RequestType ContentSettingsTypeToRequestType(
ContentSettingsType content_settings_type) { … }
std::optional<ContentSettingsType> RequestTypeToContentSettingsType(
RequestType request_type) { … }
bool IsConfirmationChipSupported(RequestType for_request_type) { … }
IconId GetIconId(RequestType type) { … }
#if !BUILDFLAG(IS_ANDROID)
IconId GetBlockedIconId(RequestType type) { … }
#endif
const char* PermissionKeyForRequestType(permissions::RequestType request_type) { … }
}