From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: John Kleinschmidt <jkleinsc@electronjs.org>
Date: Fri, 6 Oct 2023 14:15:20 -0400
Subject: feat: allow passing of ObjectTemplate to ObjectTemplateBuilder

https://chromium-review.googlesource.com/c/chromium/src/+/4905829 removed the
ObjectTemplateBuilder constructor which allows passing in an ObjectTemplate.

Electron needs this constructor, namely for gin_helper::Constructible
objects.

diff --git a/gin/object_template_builder.cc b/gin/object_template_builder.cc
index 0e534259322a3200f0b42a5188c32aaff69ac9d0..d9ad61e61b7071118f298649d861a9193a2cff8c 100644
--- a/gin/object_template_builder.cc
+++ b/gin/object_template_builder.cc
@@ -216,6 +216,13 @@ ObjectTemplateBuilder::ObjectTemplateBuilder(v8::Isolate* isolate,
   template_->SetInternalFieldCount(kNumberOfInternalFields);
 }
 
+ObjectTemplateBuilder::ObjectTemplateBuilder(v8::Isolate* isolate,
+                                             const char* type_name,
+                                             v8::Local<v8::ObjectTemplate> tmpl)
+    : isolate_(isolate), type_name_(type_name), template_(tmpl) {
+  template_->SetInternalFieldCount(kNumberOfInternalFields);
+}
+
 ObjectTemplateBuilder::ObjectTemplateBuilder(
     const ObjectTemplateBuilder& other) = default;
 
diff --git a/gin/object_template_builder.h b/gin/object_template_builder.h
index 9d8f6e5de793ea419875d99a0b46898f2e40ead5..c803363b8050f4084c9250fce9b5b8b171082703 100644
--- a/gin/object_template_builder.h
+++ b/gin/object_template_builder.h
@@ -46,6 +46,9 @@ class GIN_EXPORT ObjectTemplateBuilder {
  public:
   explicit ObjectTemplateBuilder(v8::Isolate* isolate);
   ObjectTemplateBuilder(v8::Isolate* isolate, const char* type_name);
+  ObjectTemplateBuilder(v8::Isolate* isolate,
+                        const char* type_name,
+                        v8::Local<v8::ObjectTemplate> tmpl);
   ObjectTemplateBuilder(const ObjectTemplateBuilder& other);
   ~ObjectTemplateBuilder();
 
