#include "extensions/renderer/bindings/argument_spec.h"
#include <cmath>
#include <string_view>
#include "base/check.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "base/values.h"
#include "content/public/renderer/v8_value_converter.h"
#include "extensions/renderer/bindings/api_invocation_errors.h"
#include "extensions/renderer/bindings/api_type_reference_map.h"
#include "gin/converter.h"
#include "gin/data_object_builder.h"
#include "gin/dictionary.h"
namespace extensions {
namespace {
const char* GetV8ValueTypeString(v8::Local<v8::Value> value) { … }
template <class T>
bool CheckFundamentalBounds(T value,
const std::optional<int>& minimum,
const std::optional<int>& maximum,
std::string* error) { … }
}
ArgumentSpec::ArgumentSpec(const base::Value::Dict& dict) { … }
ArgumentSpec::ArgumentSpec(ArgumentType type) : … { … }
void ArgumentSpec::InitializeType(const base::Value::Dict& dict) { … }
ArgumentSpec::~ArgumentSpec() = default;
bool ArgumentSpec::IsCorrectType(v8::Local<v8::Value> value,
const APITypeReferenceMap& refs,
std::string* error) const { … }
bool ArgumentSpec::ParseArgument(v8::Local<v8::Context> context,
v8::Local<v8::Value> value,
const APITypeReferenceMap& refs,
std::unique_ptr<base::Value>* out_value,
v8::Local<v8::Value>* v8_out_value,
std::string* error) const { … }
const std::string& ArgumentSpec::GetTypeName() const { … }
bool ArgumentSpec::ParseArgumentToFundamental(
v8::Local<v8::Context> context,
v8::Local<v8::Value> value,
std::unique_ptr<base::Value>* out_value,
v8::Local<v8::Value>* v8_out_value,
std::string* error) const { … }
bool ArgumentSpec::ParseArgumentToObject(
v8::Local<v8::Context> context,
v8::Local<v8::Object> object,
const APITypeReferenceMap& refs,
std::unique_ptr<base::Value>* out_value,
v8::Local<v8::Value>* v8_out_value,
std::string* error) const { … }
bool ArgumentSpec::ParseArgumentToArray(v8::Local<v8::Context> context,
v8::Local<v8::Array> value,
const APITypeReferenceMap& refs,
std::unique_ptr<base::Value>* out_value,
v8::Local<v8::Value>* v8_out_value,
std::string* error) const { … }
bool ArgumentSpec::ParseArgumentToAny(v8::Local<v8::Context> context,
v8::Local<v8::Value> value,
std::unique_ptr<base::Value>* out_value,
v8::Local<v8::Value>* v8_out_value,
std::string* error) const { … }
bool ArgumentSpec::ParseArgumentToFunction(
v8::Local<v8::Context> context,
v8::Local<v8::Value> value,
std::unique_ptr<base::Value>* out_value,
v8::Local<v8::Value>* v8_out_value,
std::string* error) const { … }
std::string ArgumentSpec::GetInvalidTypeError(
v8::Local<v8::Value> value) const { … }
}