// third_party/blink/public/mojom/choosers/date_time_chooser.mojom.h is auto generated by mojom_bindings_generator.py, do not edit

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

#ifndef THIRD_PARTY_BLINK_PUBLIC_MOJOM_CHOOSERS_DATE_TIME_CHOOSER_MOJOM_H_
#define THIRD_PARTY_BLINK_PUBLIC_MOJOM_CHOOSERS_DATE_TIME_CHOOSER_MOJOM_H_

#include <stdint.h>

#include <limits>
#include <optional>
#include <type_traits>
#include <utility>
#include "mojo/public/cpp/bindings/clone_traits.h"
#include "mojo/public/cpp/bindings/equals_traits.h"
#include "mojo/public/cpp/bindings/struct_ptr.h"
#include "mojo/public/cpp/bindings/struct_traits.h"
#include "mojo/public/cpp/bindings/union_traits.h"
#include "mojo/public/cpp/bindings/lib/serialization.h"

#include "third_party/perfetto/include/perfetto/tracing/traced_value_forward.h"

#include "third_party/blink/public/mojom/choosers/date_time_chooser.mojom-features.h"  // IWYU pragma: export
#include "third_party/blink/public/mojom/choosers/date_time_chooser.mojom-shared.h"  // IWYU pragma: export
#include "third_party/blink/public/mojom/choosers/date_time_chooser.mojom-forward.h"  // IWYU pragma: export
#include "mojo/public/mojom/base/string16.mojom.h"
#include "ui/base/ime/mojom/ime_types.mojom.h"
#include <string>
#include <vector>

#include "mojo/public/cpp/bindings/lib/control_message_handler.h"
#include "mojo/public/cpp/bindings/raw_ptr_impl_ref_traits.h"


#include "third_party/blink/public/common/common_export.h"




namespace blink::mojom {

class DateTimeChooserProxy;

template <typename ImplRefTraits>
class DateTimeChooserStub;

class DateTimeChooserRequestValidator;
class DateTimeChooserResponseValidator;


class BLINK_COMMON_EXPORT DateTimeChooser
    : public DateTimeChooserInterfaceBase {
 public:
  using IPCStableHashFunction = uint32_t(*)();
  static constexpr const char* Name_ = "blink.mojom.DateTimeChooser";
  static IPCStableHashFunction MessageToMethodInfo_(mojo::Message& message);
  static const char* MessageToMethodName_(mojo::Message& message);
  static constexpr uint32_t Version_ = 0;
  static constexpr bool PassesAssociatedKinds_ = false;
  static constexpr bool HasUninterruptableMethods_ = false;

  using Base_ = DateTimeChooserInterfaceBase;
  using Proxy_ = DateTimeChooserProxy;

  template <typename ImplRefTraits>
  using Stub_ = DateTimeChooserStub<ImplRefTraits>;

  using RequestValidator_ = DateTimeChooserRequestValidator;
  using ResponseValidator_ = DateTimeChooserResponseValidator;
  enum MethodMinVersions : uint32_t {
    kOpenDateTimeDialogMinVersion = 0,
    kCloseDateTimeDialogMinVersion = 0,
  };

// crbug.com/1340245 - this causes binary size bloat on Fuchsia, and we're OK
// with not having this data in traces there.
#if !BUILDFLAG(IS_FUCHSIA)
  struct OpenDateTimeDialog_Sym {
    NOINLINE static uint32_t IPCStableHash();
  };
  struct CloseDateTimeDialog_Sym {
    NOINLINE static uint32_t IPCStableHash();
  };
#endif // !BUILDFLAG(IS_FUCHSIA)
  virtual ~DateTimeChooser() = default;

  using OpenDateTimeDialogCallback = base::OnceCallback<void(bool, double)>;
  using OpenDateTimeDialogMojoCallback = base::OnceCallback<void(bool, double)>;

  virtual void OpenDateTimeDialog(DateTimeDialogValuePtr value, OpenDateTimeDialogCallback callback) = 0;

  virtual void CloseDateTimeDialog() = 0;
};



class BLINK_COMMON_EXPORT DateTimeChooserProxy
    : public DateTimeChooser {
 public:
  using InterfaceType = DateTimeChooser;

  explicit DateTimeChooserProxy(mojo::MessageReceiverWithResponder* receiver);
  
  void OpenDateTimeDialog(DateTimeDialogValuePtr value, OpenDateTimeDialogCallback callback) final;
  
  void CloseDateTimeDialog() final;

 private:
  mojo::MessageReceiverWithResponder* receiver_;
};
class BLINK_COMMON_EXPORT DateTimeChooserStubDispatch {
 public:
  static bool Accept(DateTimeChooser* impl, mojo::Message* message);
  static bool AcceptWithResponder(
      DateTimeChooser* impl,
      mojo::Message* message,
      std::unique_ptr<mojo::MessageReceiverWithStatus> responder);
};

template <typename ImplRefTraits =
              mojo::RawPtrImplRefTraits<DateTimeChooser>>
class DateTimeChooserStub
    : public mojo::MessageReceiverWithResponderStatus {
 public:
  using ImplPointerType = typename ImplRefTraits::PointerType;

  DateTimeChooserStub() = default;
  ~DateTimeChooserStub() override = default;

  void set_sink(ImplPointerType sink) { sink_ = std::move(sink); }
  ImplPointerType& sink() { return sink_; }

  bool Accept(mojo::Message* message) override {
    if (ImplRefTraits::IsNull(sink_))
      return false;
    return DateTimeChooserStubDispatch::Accept(
        ImplRefTraits::GetRawPointer(&sink_), message);
  }

  bool AcceptWithResponder(
      mojo::Message* message,
      std::unique_ptr<mojo::MessageReceiverWithStatus> responder) override {
    if (ImplRefTraits::IsNull(sink_))
      return false;
    return DateTimeChooserStubDispatch::AcceptWithResponder(
        ImplRefTraits::GetRawPointer(&sink_), message, std::move(responder));
  }

 private:
  ImplPointerType sink_;
};
class BLINK_COMMON_EXPORT DateTimeChooserRequestValidator : public mojo::MessageReceiver {
 public:
  bool Accept(mojo::Message* message) override;
};
class BLINK_COMMON_EXPORT DateTimeChooserResponseValidator : public mojo::MessageReceiver {
 public:
  bool Accept(mojo::Message* message) override;
};









class BLINK_COMMON_EXPORT DateTimeSuggestion {
 public:
  template <typename T>
  using EnableIfSame = std::enable_if_t<std::is_same<DateTimeSuggestion, T>::value>;
  using DataView = DateTimeSuggestionDataView;
  using Data_ = internal::DateTimeSuggestion_Data;

  template <typename... Args>
  static DateTimeSuggestionPtr New(Args&&... args) {
    return DateTimeSuggestionPtr(
        std::in_place, std::forward<Args>(args)...);
  }

  template <typename U>
  static DateTimeSuggestionPtr From(const U& u) {
    return mojo::TypeConverter<DateTimeSuggestionPtr, U>::Convert(u);
  }

  template <typename U>
  U To() const {
    return mojo::TypeConverter<U, DateTimeSuggestion>::Convert(*this);
  }


  DateTimeSuggestion();

  DateTimeSuggestion(
      double value,
      const ::std::u16string& localized_value,
      const ::std::u16string& label);


  ~DateTimeSuggestion();

  // Clone() is a template so it is only instantiated if it is used. Thus, the
  // bindings generator does not need to know whether Clone() or copy
  // constructor/assignment are available for members.
  template <typename StructPtrType = DateTimeSuggestionPtr>
  DateTimeSuggestionPtr Clone() const;

  // Equals() is a template so it is only instantiated if it is used. Thus, the
  // bindings generator does not need to know whether Equals() or == operator
  // are available for members.
  template <typename T, DateTimeSuggestion::EnableIfSame<T>* = nullptr>
  bool Equals(const T& other) const;

  template <typename T, DateTimeSuggestion::EnableIfSame<T>* = nullptr>
  bool operator==(const T& rhs) const { return Equals(rhs); }

  template <typename T, DateTimeSuggestion::EnableIfSame<T>* = nullptr>
  bool operator!=(const T& rhs) const { return !operator==(rhs); }

  template <mojo::internal::SendValidation send_validation, typename UserType>
  static std::vector<uint8_t> Serialize(UserType* input) {
    return mojo::internal::SerializeImpl<
        DateTimeSuggestion::DataView, std::vector<uint8_t>, send_validation>(input);
  }

  template <typename UserType>
  static std::vector<uint8_t> Serialize(UserType* input) {
    return mojo::internal::SerializeImpl<
        DateTimeSuggestion::DataView, std::vector<uint8_t>>(input);
  }

  template <typename UserType>
  static mojo::Message SerializeAsMessage(UserType* input) {
    return mojo::internal::SerializeAsMessageImpl<
        DateTimeSuggestion::DataView>(input);
  }

  // The returned Message is serialized only if the message is moved
  // cross-process or cross-language. Otherwise if the message is Deserialized
  // as the same UserType |input| will just be moved to |output| in
  // DeserializeFromMessage.
  template <typename UserType>
  static mojo::Message WrapAsMessage(UserType input) {
    return mojo::Message(std::make_unique<
        internal::DateTimeSuggestion_UnserializedMessageContext<
            UserType, DateTimeSuggestion::DataView>>(0, 0, std::move(input)),
        MOJO_CREATE_MESSAGE_FLAG_NONE);
  }

  template <typename UserType>
  static bool Deserialize(const void* data,
                          size_t data_num_bytes,
                          UserType* output) {
    mojo::Message message;
    return mojo::internal::DeserializeImpl<DateTimeSuggestion::DataView>(
        message, data, data_num_bytes, output, Validate);
  }

  template <typename UserType>
  static bool Deserialize(base::span<const uint8_t> input,
                          UserType* output) {
    return DateTimeSuggestion::Deserialize(
        input.empty() ? nullptr : input.data(), input.size(), output);
  }

  template <typename UserType>
  static bool DeserializeFromMessage(mojo::Message input,
                                     UserType* output) {
    auto context = input.TakeUnserializedContext<
        internal::DateTimeSuggestion_UnserializedMessageContext<
            UserType, DateTimeSuggestion::DataView>>();
    if (context) {
      *output = std::move(context->TakeData());
      return true;
    }
    input.SerializeIfNecessary();
    return mojo::internal::DeserializeImpl<DateTimeSuggestion::DataView>(
        input, input.payload(), input.payload_num_bytes(), output, Validate);
  }

  
  double value;
  
  ::std::u16string localized_value;
  
  ::std::u16string label;

  // Serialise this struct into a trace.
  void WriteIntoTrace(perfetto::TracedValue traced_context) const;

 private:
  static bool Validate(const void* data,
                       mojo::internal::ValidationContext* validation_context);
};

// The comparison operators are templates, so they are only instantiated if they
// are used. Thus, the bindings generator does not need to know whether
// comparison operators are available for members.
template <typename T, DateTimeSuggestion::EnableIfSame<T>* = nullptr>
bool operator<(const T& lhs, const T& rhs);

template <typename T, DateTimeSuggestion::EnableIfSame<T>* = nullptr>
bool operator<=(const T& lhs, const T& rhs) {
  return !(rhs < lhs);
}

template <typename T, DateTimeSuggestion::EnableIfSame<T>* = nullptr>
bool operator>(const T& lhs, const T& rhs) {
  return rhs < lhs;
}

template <typename T, DateTimeSuggestion::EnableIfSame<T>* = nullptr>
bool operator>=(const T& lhs, const T& rhs) {
  return !(lhs < rhs);
}





class BLINK_COMMON_EXPORT DateTimeDialogValue {
 public:
  template <typename T>
  using EnableIfSame = std::enable_if_t<std::is_same<DateTimeDialogValue, T>::value>;
  using DataView = DateTimeDialogValueDataView;
  using Data_ = internal::DateTimeDialogValue_Data;

  template <typename... Args>
  static DateTimeDialogValuePtr New(Args&&... args) {
    return DateTimeDialogValuePtr(
        std::in_place, std::forward<Args>(args)...);
  }

  template <typename U>
  static DateTimeDialogValuePtr From(const U& u) {
    return mojo::TypeConverter<DateTimeDialogValuePtr, U>::Convert(u);
  }

  template <typename U>
  U To() const {
    return mojo::TypeConverter<U, DateTimeDialogValue>::Convert(*this);
  }


  DateTimeDialogValue();

  DateTimeDialogValue(
      ::ui::TextInputType dialog_type,
      double dialog_value,
      double minimum,
      double maximum,
      double step,
      std::vector<DateTimeSuggestionPtr> suggestions);

DateTimeDialogValue(const DateTimeDialogValue&) = delete;
DateTimeDialogValue& operator=(const DateTimeDialogValue&) = delete;

  ~DateTimeDialogValue();

  // Clone() is a template so it is only instantiated if it is used. Thus, the
  // bindings generator does not need to know whether Clone() or copy
  // constructor/assignment are available for members.
  template <typename StructPtrType = DateTimeDialogValuePtr>
  DateTimeDialogValuePtr Clone() const;

  // Equals() is a template so it is only instantiated if it is used. Thus, the
  // bindings generator does not need to know whether Equals() or == operator
  // are available for members.
  template <typename T, DateTimeDialogValue::EnableIfSame<T>* = nullptr>
  bool Equals(const T& other) const;

  template <typename T, DateTimeDialogValue::EnableIfSame<T>* = nullptr>
  bool operator==(const T& rhs) const { return Equals(rhs); }

  template <typename T, DateTimeDialogValue::EnableIfSame<T>* = nullptr>
  bool operator!=(const T& rhs) const { return !operator==(rhs); }

  template <mojo::internal::SendValidation send_validation, typename UserType>
  static std::vector<uint8_t> Serialize(UserType* input) {
    return mojo::internal::SerializeImpl<
        DateTimeDialogValue::DataView, std::vector<uint8_t>, send_validation>(input);
  }

  template <typename UserType>
  static std::vector<uint8_t> Serialize(UserType* input) {
    return mojo::internal::SerializeImpl<
        DateTimeDialogValue::DataView, std::vector<uint8_t>>(input);
  }

  template <typename UserType>
  static mojo::Message SerializeAsMessage(UserType* input) {
    return mojo::internal::SerializeAsMessageImpl<
        DateTimeDialogValue::DataView>(input);
  }

  // The returned Message is serialized only if the message is moved
  // cross-process or cross-language. Otherwise if the message is Deserialized
  // as the same UserType |input| will just be moved to |output| in
  // DeserializeFromMessage.
  template <typename UserType>
  static mojo::Message WrapAsMessage(UserType input) {
    return mojo::Message(std::make_unique<
        internal::DateTimeDialogValue_UnserializedMessageContext<
            UserType, DateTimeDialogValue::DataView>>(0, 0, std::move(input)),
        MOJO_CREATE_MESSAGE_FLAG_NONE);
  }

  template <typename UserType>
  static bool Deserialize(const void* data,
                          size_t data_num_bytes,
                          UserType* output) {
    mojo::Message message;
    return mojo::internal::DeserializeImpl<DateTimeDialogValue::DataView>(
        message, data, data_num_bytes, output, Validate);
  }

  template <typename UserType>
  static bool Deserialize(base::span<const uint8_t> input,
                          UserType* output) {
    return DateTimeDialogValue::Deserialize(
        input.empty() ? nullptr : input.data(), input.size(), output);
  }

  template <typename UserType>
  static bool DeserializeFromMessage(mojo::Message input,
                                     UserType* output) {
    auto context = input.TakeUnserializedContext<
        internal::DateTimeDialogValue_UnserializedMessageContext<
            UserType, DateTimeDialogValue::DataView>>();
    if (context) {
      *output = std::move(context->TakeData());
      return true;
    }
    input.SerializeIfNecessary();
    return mojo::internal::DeserializeImpl<DateTimeDialogValue::DataView>(
        input, input.payload(), input.payload_num_bytes(), output, Validate);
  }

  
  ::ui::TextInputType dialog_type;
  
  double dialog_value;
  
  double minimum;
  
  double maximum;
  
  double step;
  
  std::vector<DateTimeSuggestionPtr> suggestions;

  // Serialise this struct into a trace.
  void WriteIntoTrace(perfetto::TracedValue traced_context) const;

 private:
  static bool Validate(const void* data,
                       mojo::internal::ValidationContext* validation_context);
};

// The comparison operators are templates, so they are only instantiated if they
// are used. Thus, the bindings generator does not need to know whether
// comparison operators are available for members.
template <typename T, DateTimeDialogValue::EnableIfSame<T>* = nullptr>
bool operator<(const T& lhs, const T& rhs);

template <typename T, DateTimeDialogValue::EnableIfSame<T>* = nullptr>
bool operator<=(const T& lhs, const T& rhs) {
  return !(rhs < lhs);
}

template <typename T, DateTimeDialogValue::EnableIfSame<T>* = nullptr>
bool operator>(const T& lhs, const T& rhs) {
  return rhs < lhs;
}

template <typename T, DateTimeDialogValue::EnableIfSame<T>* = nullptr>
bool operator>=(const T& lhs, const T& rhs) {
  return !(lhs < rhs);
}

template <typename StructPtrType>
DateTimeSuggestionPtr DateTimeSuggestion::Clone() const {
  return New(
      mojo::Clone(value),
      mojo::Clone(localized_value),
      mojo::Clone(label)
  );
}

template <typename T, DateTimeSuggestion::EnableIfSame<T>*>
bool DateTimeSuggestion::Equals(const T& other_struct) const {
  if (!mojo::Equals(this->value, other_struct.value))
    return false;
  if (!mojo::Equals(this->localized_value, other_struct.localized_value))
    return false;
  if (!mojo::Equals(this->label, other_struct.label))
    return false;
  return true;
}

template <typename T, DateTimeSuggestion::EnableIfSame<T>*>
bool operator<(const T& lhs, const T& rhs) {
  if (lhs.value < rhs.value)
    return true;
  if (rhs.value < lhs.value)
    return false;
  if (lhs.localized_value < rhs.localized_value)
    return true;
  if (rhs.localized_value < lhs.localized_value)
    return false;
  if (lhs.label < rhs.label)
    return true;
  if (rhs.label < lhs.label)
    return false;
  return false;
}
template <typename StructPtrType>
DateTimeDialogValuePtr DateTimeDialogValue::Clone() const {
  return New(
      mojo::Clone(dialog_type),
      mojo::Clone(dialog_value),
      mojo::Clone(minimum),
      mojo::Clone(maximum),
      mojo::Clone(step),
      mojo::Clone(suggestions)
  );
}

template <typename T, DateTimeDialogValue::EnableIfSame<T>*>
bool DateTimeDialogValue::Equals(const T& other_struct) const {
  if (!mojo::Equals(this->dialog_type, other_struct.dialog_type))
    return false;
  if (!mojo::Equals(this->dialog_value, other_struct.dialog_value))
    return false;
  if (!mojo::Equals(this->minimum, other_struct.minimum))
    return false;
  if (!mojo::Equals(this->maximum, other_struct.maximum))
    return false;
  if (!mojo::Equals(this->step, other_struct.step))
    return false;
  if (!mojo::Equals(this->suggestions, other_struct.suggestions))
    return false;
  return true;
}

template <typename T, DateTimeDialogValue::EnableIfSame<T>*>
bool operator<(const T& lhs, const T& rhs) {
  if (lhs.dialog_type < rhs.dialog_type)
    return true;
  if (rhs.dialog_type < lhs.dialog_type)
    return false;
  if (lhs.dialog_value < rhs.dialog_value)
    return true;
  if (rhs.dialog_value < lhs.dialog_value)
    return false;
  if (lhs.minimum < rhs.minimum)
    return true;
  if (rhs.minimum < lhs.minimum)
    return false;
  if (lhs.maximum < rhs.maximum)
    return true;
  if (rhs.maximum < lhs.maximum)
    return false;
  if (lhs.step < rhs.step)
    return true;
  if (rhs.step < lhs.step)
    return false;
  if (lhs.suggestions < rhs.suggestions)
    return true;
  if (rhs.suggestions < lhs.suggestions)
    return false;
  return false;
}


}  // blink::mojom

namespace mojo {


template <>
struct BLINK_COMMON_EXPORT StructTraits<::blink::mojom::DateTimeSuggestion::DataView,
                                         ::blink::mojom::DateTimeSuggestionPtr> {
  static bool IsNull(const ::blink::mojom::DateTimeSuggestionPtr& input) { return !input; }
  static void SetToNull(::blink::mojom::DateTimeSuggestionPtr* output) { output->reset(); }

  static decltype(::blink::mojom::DateTimeSuggestion::value) value(
      const ::blink::mojom::DateTimeSuggestionPtr& input) {
    return input->value;
  }

  static const decltype(::blink::mojom::DateTimeSuggestion::localized_value)& localized_value(
      const ::blink::mojom::DateTimeSuggestionPtr& input) {
    return input->localized_value;
  }

  static const decltype(::blink::mojom::DateTimeSuggestion::label)& label(
      const ::blink::mojom::DateTimeSuggestionPtr& input) {
    return input->label;
  }

  static bool Read(::blink::mojom::DateTimeSuggestion::DataView input, ::blink::mojom::DateTimeSuggestionPtr* output);
};


template <>
struct BLINK_COMMON_EXPORT StructTraits<::blink::mojom::DateTimeDialogValue::DataView,
                                         ::blink::mojom::DateTimeDialogValuePtr> {
  static bool IsNull(const ::blink::mojom::DateTimeDialogValuePtr& input) { return !input; }
  static void SetToNull(::blink::mojom::DateTimeDialogValuePtr* output) { output->reset(); }

  static decltype(::blink::mojom::DateTimeDialogValue::dialog_type) dialog_type(
      const ::blink::mojom::DateTimeDialogValuePtr& input) {
    return input->dialog_type;
  }

  static decltype(::blink::mojom::DateTimeDialogValue::dialog_value) dialog_value(
      const ::blink::mojom::DateTimeDialogValuePtr& input) {
    return input->dialog_value;
  }

  static decltype(::blink::mojom::DateTimeDialogValue::minimum) minimum(
      const ::blink::mojom::DateTimeDialogValuePtr& input) {
    return input->minimum;
  }

  static decltype(::blink::mojom::DateTimeDialogValue::maximum) maximum(
      const ::blink::mojom::DateTimeDialogValuePtr& input) {
    return input->maximum;
  }

  static decltype(::blink::mojom::DateTimeDialogValue::step) step(
      const ::blink::mojom::DateTimeDialogValuePtr& input) {
    return input->step;
  }

  static const decltype(::blink::mojom::DateTimeDialogValue::suggestions)& suggestions(
      const ::blink::mojom::DateTimeDialogValuePtr& input) {
    return input->suggestions;
  }

  static bool Read(::blink::mojom::DateTimeDialogValue::DataView input, ::blink::mojom::DateTimeDialogValuePtr* output);
};

}  // namespace mojo

#endif  // THIRD_PARTY_BLINK_PUBLIC_MOJOM_CHOOSERS_DATE_TIME_CHOOSER_MOJOM_H_