chore: remove native_mate (Part 5) (#20264)

* deprecate native_mate/native_mate/object_template_builder.h

* add gin_helper/object_template_builder.h

* add patch to avoid ambiguous error

* remove usage of object_template_builder_deprecated.h in a few files

* add note we should remove gin_helper/object_template_builder.h in future
This commit is contained in:
Cheng Zhao 2019-09-19 11:09:15 -04:00 committed by Shelley Vohr
parent 63f08fcdb0
commit 624ba4f642
39 changed files with 474 additions and 121 deletions

View file

@ -6,24 +6,22 @@
#include <map>
#include "gin/dictionary.h"
#include "native_mate/constructor.h"
#include "native_mate/object_template_builder.h"
#include "shell/browser/native_window.h"
#include "shell/common/gin_converters/callback_converter.h"
#include "shell/common/gin_converters/image_converter.h"
#include "shell/common/gin_helper/dictionary.h"
#include "shell/common/gin_helper/object_template_builder.h"
#include "shell/common/native_mate_converters/accelerator_converter.h"
#include "shell/common/native_mate_converters/image_converter.h"
#include "shell/common/native_mate_converters/string16_converter.h"
#include "shell/common/node_includes.h"
// TODO(zcbenz): Remove this after removing mate::ObjectTemplateBuilder.
#include "shell/common/native_mate_converters/callback_converter_deprecated.h"
namespace {
// We need this map to keep references to currently opened menus.
// Without this menus would be destroyed by js garbage collector
// even when they are still displayed.
std::map<uint32_t, v8::Global<v8::Object>> g_menus;
} // unnamed namespace
namespace electron {
@ -224,9 +222,9 @@ void Menu::OnMenuWillShow() {
// static
void Menu::BuildPrototype(v8::Isolate* isolate,
v8::Local<v8::FunctionTemplate> prototype) {
prototype->SetClassName(mate::StringToV8(isolate, "Menu"));
prototype->SetClassName(gin::StringToV8(isolate, "Menu"));
gin_helper::Destroyable::MakeDestroyable(isolate, prototype);
mate::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate())
gin_helper::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate())
.SetMethod("insertItem", &Menu::InsertItemAt)
.SetMethod("insertCheckItem", &Menu::InsertCheckItemAt)
.SetMethod("insertRadioItem", &Menu::InsertRadioItemAt)
@ -267,7 +265,7 @@ void Initialize(v8::Local<v8::Object> exports,
v8::Isolate* isolate = context->GetIsolate();
Menu::SetConstructor(isolate, base::BindRepeating(&Menu::New));
mate::Dictionary dict(isolate, exports);
gin_helper::Dictionary dict(isolate, exports);
dict.Set(
"Menu",
Menu::GetConstructor(isolate)->GetFunction(context).ToLocalChecked());