#include "extensions/renderer/bindings/api_binding.h"
#include <algorithm>
#include <string_view>
#include "base/check.h"
#include "base/functional/bind.h"
#include "base/memory/raw_ptr.h"
#include "base/ranges/algorithm.h"
#include "base/strings/strcat.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "base/values.h"
#include "extensions/renderer/bindings/api_binding_hooks.h"
#include "extensions/renderer/bindings/api_binding_types.h"
#include "extensions/renderer/bindings/api_binding_util.h"
#include "extensions/renderer/bindings/api_event_handler.h"
#include "extensions/renderer/bindings/api_invocation_errors.h"
#include "extensions/renderer/bindings/api_request_handler.h"
#include "extensions/renderer/bindings/api_signature.h"
#include "extensions/renderer/bindings/api_type_reference_map.h"
#include "extensions/renderer/bindings/binding_access_checker.h"
#include "extensions/renderer/bindings/declarative_event.h"
#include "gin/arguments.h"
#include "gin/handle.h"
#include "gin/per_context_data.h"
namespace extensions {
namespace {
std::string GetJSEnumEntryName(const std::string& original) { … }
std::unique_ptr<APISignature> GetAPISignatureFromDictionary(
const base::Value::Dict* dict,
BindingAccessChecker* access_checker) { … }
void RunAPIBindingHandlerCallback(
const v8::FunctionCallbackInfo<v8::Value>& info) { … }
}
struct APIBinding::MethodData { … };
struct APIBinding::EventData { … };
struct APIBinding::CustomPropertyData { … };
APIBinding::APIBinding(const std::string& api_name,
const base::Value::List* function_definitions,
const base::Value::List* type_definitions,
const base::Value::List* event_definitions,
const base::Value::Dict* property_definitions,
CreateCustomType create_custom_type,
OnSilentRequest on_silent_request,
std::unique_ptr<APIBindingHooks> binding_hooks,
APITypeReferenceMap* type_refs,
APIRequestHandler* request_handler,
APIEventHandler* event_handler,
BindingAccessChecker* access_checker)
: … { … }
APIBinding::~APIBinding() = default;
v8::Local<v8::Object> APIBinding::CreateInstance(
v8::Local<v8::Context> context) { … }
void APIBinding::InitializeTemplate(v8::Isolate* isolate) { … }
void APIBinding::DecorateTemplateWithProperties(
v8::Isolate* isolate,
v8::Local<v8::ObjectTemplate> object_template,
const base::Value::Dict& properties,
bool is_root) { … }
void APIBinding::GetEventObject(
v8::Local<v8::Name> property,
const v8::PropertyCallbackInfo<v8::Value>& info) { … }
void APIBinding::GetCustomPropertyObject(
v8::Local<v8::Name> property_name,
const v8::PropertyCallbackInfo<v8::Value>& info) { … }
void APIBinding::HandleCall(const std::string& name,
const APISignature* signature,
gin::Arguments* arguments) { … }
}