chromium/components/permissions/request_type.cc

// Copyright 2020 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#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  // BUILDFLAG(IS_ANDROID)

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  // BUILDFLAG(IS_ANDROID)

#if !BUILDFLAG(IS_ANDROID)
// TODO(crbug.com/335848275): Migrate the icons in 2 steps.
// 1 - Copy contents of refresh icons into current non-refresh icons.
// 2 - In a separate change, remove the refresh icons.
const gfx::VectorIcon& GetIconIdDesktop(RequestType type) {}

const gfx::VectorIcon& GetBlockedIconIdDesktop(RequestType type) {}
#endif  // !BUILDFLAG(IS_ANDROID)

}  // namespace

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) {}

// Returns whether confirmation chips can be displayed
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) {}

}  // namespace permissions