// third_party/blink/public/mojom/permissions/permission_status.mojom-data-view.h is auto generated by mojom_bindings_generator.py, do not edit

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

// This file defines XDataView for type traits and can be included in
// _mojom_traits.h definitions but otherwise please use .mojom-forward.h,
// .mojom-shared.h or .mojom.h.

// IWYU pragma: private
// IWYU pragma: friend "traits"

#ifndef THIRD_PARTY_BLINK_PUBLIC_MOJOM_PERMISSIONS_PERMISSION_STATUS_MOJOM_DATA_VIEW_H_
#define THIRD_PARTY_BLINK_PUBLIC_MOJOM_PERMISSIONS_PERMISSION_STATUS_MOJOM_DATA_VIEW_H_

#include <stdint.h>

#include <functional>
#include <iosfwd>
#include <type_traits>
#include <utility>
#include "mojo/public/cpp/bindings/array_data_view.h"
#include "mojo/public/cpp/bindings/string_data_view.h"
#include "mojo/public/cpp/bindings/lib/serialization.h"

#include "third_party/blink/public/mojom/permissions/permission_status.mojom-shared-internal.h"


namespace blink::mojom {
class PermissionStatusWithDetailsDataView;

class PermissionDetailsDataView;


}  // blink::mojom


namespace mojo {
namespace internal {

template <>
struct MojomTypeTraits<::blink::mojom::PermissionStatusWithDetailsDataView> {
  using Data = ::blink::mojom::internal::PermissionStatusWithDetails_Data;
  using DataAsArrayElement = Pointer<Data>;
  static constexpr MojomTypeCategory category = MojomTypeCategory::kStruct;
};

template <>
struct MojomTypeTraits<::blink::mojom::PermissionDetailsDataView> {
  using Data = ::blink::mojom::internal::PermissionDetails_Data;
  using DataAsArrayElement = Data;
  static constexpr MojomTypeCategory category = MojomTypeCategory::kUnion;
};

}  // namespace internal
}  // namespace mojo


namespace blink::mojom {


enum class PermissionStatus : int32_t {
  
  GRANTED = 0,
  
  DENIED = 1,
  
  ASK = 2,
  
  LAST = 2,
  kMinValue = 0,
  kMaxValue = 2,
};

COMPONENT_EXPORT(MOJOM_SHARED_BLINK_COMMON_EXPORT) std::ostream& operator<<(std::ostream& os, PermissionStatus value);
inline bool IsKnownEnumValue(PermissionStatus value) {
  return internal::PermissionStatus_Data::IsKnownValue(
      static_cast<int32_t>(value));
}

// Returns true if the enum has an infallible conversion from the mojom enum.
consteval bool HasInfallibleConversion(PermissionStatus) {
  return true;
}


enum class GeolocationAccuracy : int32_t {
  
  kPrecise = 0,
  
  kApproximate = 1,
  kMinValue = 0,
  kMaxValue = 1,
};

COMPONENT_EXPORT(MOJOM_SHARED_BLINK_COMMON_EXPORT) std::ostream& operator<<(std::ostream& os, GeolocationAccuracy value);
inline bool IsKnownEnumValue(GeolocationAccuracy value) {
  return internal::GeolocationAccuracy_Data::IsKnownValue(
      static_cast<int32_t>(value));
}

// Returns true if the enum has an infallible conversion from the mojom enum.
consteval bool HasInfallibleConversion(GeolocationAccuracy) {
  return true;
}


class PermissionStatusWithDetailsDataView {
 public:
  PermissionStatusWithDetailsDataView() = default;

  PermissionStatusWithDetailsDataView(
      internal::PermissionStatusWithDetails_Data* data,
      mojo::Message* message)
      : data_(data), message_(message) {}

  bool is_null() const { return !data_; }
  template <typename UserType>
  [[nodiscard]] bool ReadStatus(UserType* output) const {
    auto data_value = data_->status;
    return mojo::internal::Deserialize<::blink::mojom::PermissionStatus>(
        data_value, output);
  }
  PermissionStatus status() const {
    return ::mojo::internal::ToKnownEnumValueHelper(
          static_cast<::blink::mojom::PermissionStatus>(data_->status));
  }
  inline void GetDetailsDataView(
      PermissionDetailsDataView* output);

  template <typename UserType>
  [[nodiscard]] bool ReadDetails(UserType* output) {
    
static_assert(
    mojo::internal::IsValidUserTypeForOptionalValue<
        ::blink::mojom::PermissionDetailsDataView, UserType>(),
    "Attempting to read the optional `details` field into a type which "
    "cannot represent a null value. Either wrap the destination object "
    "with std::optional, ensure that any corresponding "
    "{Struct/Union/Array/String}Traits define the necessary IsNull and "
    "SetToNull methods, or use `MaybeReadDetails` instead "
    "of `ReadDetails if you're fine with null values being "
    "silently ignored in this case.");
    auto* pointer = !data_->details.is_null() ? &data_->details : nullptr;
    return mojo::internal::Deserialize<::blink::mojom::PermissionDetailsDataView>(
        pointer, output, message_);
  }
 private:
  internal::PermissionStatusWithDetails_Data* data_ = nullptr;
  mojo::Message* message_ = nullptr;
};


class PermissionDetailsDataView {
 public:
  using Tag = internal::PermissionDetails_Data::PermissionDetails_Tag;

  PermissionDetailsDataView() = default;

  PermissionDetailsDataView(
      internal::PermissionDetails_Data* data,
      mojo::Message* message)
      : data_(data) {}

  bool is_null() const {
    // For inlined unions, |data_| is always non-null. In that case we need to
    // check |data_->is_null()|.
    return !data_ || data_->is_null();
  }

  Tag tag() const { return data_->tag; }
  bool is_geolocation_accuracy() const { return data_->tag == Tag::kGeolocationAccuracy; }
  template <typename UserType>
  [[nodiscard]] bool ReadGeolocationAccuracy(UserType* output) const {
    CHECK(is_geolocation_accuracy());
    return mojo::internal::Deserialize<::blink::mojom::GeolocationAccuracy>(
        data_->data.f_geolocation_accuracy, output);
  }
  GeolocationAccuracy geolocation_accuracy() const {
    CHECK(is_geolocation_accuracy());
    // TODO(dcheng): This seems incorrect, as it bypasses enum traits.
    return ::mojo::internal::ToKnownEnumValueHelper(
        static_cast<::blink::mojom::GeolocationAccuracy>(data_->data.f_geolocation_accuracy));
  }

 private:
  internal::PermissionDetails_Data* data_ = nullptr;
};



}  // blink::mojom

#endif  // THIRD_PARTY_BLINK_PUBLIC_MOJOM_PERMISSIONS_PERMISSION_STATUS_MOJOM_DATA_VIEW_H_