Browse Source

chore: remove native_mate (Part 12) (#20869)

* refactor: move mate::Event to gin

* refactor: move mate::Locker to gin

* refactor: convert contextBridge to gin

* refactor: convert contentTracing to gin

* refactor: remove callback converter of native_mate

* refactor: remove file_dialog_converter and native_window_converter from native_mate

* refactor: convert webFrame to gin

* refactor: move blink_converter to gin

* refactor: remove net_converter from native_mate

* refactor: remove event_emitter_caller_deprecated

* refactor: remove gurl_converter from native_mate

* refactor: remove file_path and string16_converter from native_mate

* refactor: remove image_converter from native_mate

* refactor: move value_converter to gin
Cheng Zhao 5 years ago
parent
commit
3ae3233e65
96 changed files with 622 additions and 1711 deletions
  1. 10 22
      filenames.gni
  2. 0 3
      native_mate/BUILD.gn
  3. 0 17
      native_mate/native_mate/dictionary.h
  4. 0 35
      native_mate/native_mate/persistent_dictionary.cc
  5. 0 51
      native_mate/native_mate/persistent_dictionary.h
  6. 0 102
      native_mate/native_mate/scoped_persistent.h
  7. 1 1
      shell/browser/api/atom_api_app.cc
  8. 1 1
      shell/browser/api/atom_api_browser_window.cc
  9. 13 14
      shell/browser/api/atom_api_content_tracing.cc
  10. 1 1
      shell/browser/api/atom_api_cookies.cc
  11. 2 2
      shell/browser/api/atom_api_debugger.cc
  12. 1 1
      shell/browser/api/atom_api_event.cc
  13. 1 1
      shell/browser/api/atom_api_menu.h
  14. 1 1
      shell/browser/api/atom_api_menu_mac.mm
  15. 1 1
      shell/browser/api/atom_api_menu_views.cc
  16. 1 1
      shell/browser/api/atom_api_session.cc
  17. 1 1
      shell/browser/api/atom_api_system_preferences.cc
  18. 1 1
      shell/browser/api/atom_api_system_preferences_mac.mm
  19. 7 6
      shell/browser/api/atom_api_top_level_window.cc
  20. 2 2
      shell/browser/api/atom_api_top_level_window.h
  21. 8 8
      shell/browser/api/atom_api_web_contents.cc
  22. 1 1
      shell/browser/api/atom_api_web_request.cc
  23. 1 1
      shell/browser/api/atom_api_web_view_manager.cc
  24. 24 23
      shell/browser/api/event.cc
  25. 16 12
      shell/browser/api/event.h
  26. 3 2
      shell/browser/api/gpuinfo_manager.cc
  27. 0 1
      shell/browser/api/gpuinfo_manager.h
  28. 1 1
      shell/browser/auto_updater_mac.mm
  29. 62 1
      shell/browser/login_handler.cc
  30. 3 2
      shell/browser/native_window.cc
  31. 3 7
      shell/browser/native_window.h
  32. 2 2
      shell/browser/native_window_mac.h
  33. 5 4
      shell/browser/native_window_mac.mm
  34. 1 1
      shell/browser/net/atom_url_loader_factory.cc
  35. 0 1
      shell/browser/net/cert_verifier_client.cc
  36. 2 2
      shell/browser/printing/print_preview_message_handler.cc
  37. 1 1
      shell/browser/renderer_host/electron_render_message_filter.cc
  38. 12 13
      shell/browser/ui/cocoa/atom_touch_bar.h
  39. 41 42
      shell/browser/ui/cocoa/atom_touch_bar.mm
  40. 0 1
      shell/browser/web_contents_permission_helper.cc
  41. 1 1
      shell/browser/web_contents_preferences.cc
  42. 0 1
      shell/browser/web_view_guest_delegate.cc
  43. 8 10
      shell/common/api/atom_api_asar.cc
  44. 28 21
      shell/common/api/atom_api_clipboard.cc
  45. 28 19
      shell/common/api/atom_api_clipboard.h
  46. 5 6
      shell/common/api/atom_api_command_line.cc
  47. 1 1
      shell/common/api/atom_api_native_image.cc
  48. 1 2
      shell/common/api/atom_api_shell.cc
  49. 13 15
      shell/common/api/electron_bindings.cc
  50. 6 7
      shell/common/api/electron_bindings.h
  51. 0 38
      shell/common/api/event_emitter_caller_deprecated.cc
  52. 0 73
      shell/common/api/event_emitter_caller_deprecated.h
  53. 1 3
      shell/common/api/remote/remote_object_freer.cc
  54. 41 41
      shell/common/gin_converters/blink_converter.cc
  55. 6 6
      shell/common/gin_converters/blink_converter.h
  56. 0 79
      shell/common/gin_converters/blink_converter_gin_adapter.h
  57. 3 3
      shell/common/gin_converters/content_converter.cc
  58. 1 0
      shell/common/gin_converters/file_path_converter.h
  59. 1 59
      shell/common/gin_converters/net_converter.cc
  60. 0 11
      shell/common/gin_converters/net_converter.h
  61. 4 4
      shell/common/gin_converters/value_converter.cc
  62. 6 31
      shell/common/gin_converters/value_converter.h
  63. 0 56
      shell/common/gin_converters/value_converter_gin_adapter.h
  64. 1 1
      shell/common/gin_helper/callback.cc
  65. 4 4
      shell/common/gin_helper/callback.h
  66. 20 0
      shell/common/gin_helper/dictionary.h
  67. 2 3
      shell/common/gin_helper/event_emitter.cc
  68. 5 8
      shell/common/gin_helper/event_emitter.h
  69. 1 1
      shell/common/gin_helper/event_emitter_caller.cc
  70. 3 5
      shell/common/gin_helper/locker.cc
  71. 5 5
      shell/common/gin_helper/locker.h
  72. 32 0
      shell/common/gin_helper/persistent_dictionary.cc
  73. 64 0
      shell/common/gin_helper/persistent_dictionary.h
  74. 2 2
      shell/common/gin_helper/trackable_object.cc
  75. 0 162
      shell/common/native_mate_converters/callback_converter_deprecated.cc
  76. 0 185
      shell/common/native_mate_converters/callback_converter_deprecated.h
  77. 0 41
      shell/common/native_mate_converters/file_dialog_converter.h
  78. 0 28
      shell/common/native_mate_converters/file_path_converter.h
  79. 0 27
      shell/common/native_mate_converters/gurl_converter.h
  80. 0 37
      shell/common/native_mate_converters/image_converter.h
  81. 0 24
      shell/common/native_mate_converters/native_window_converter.h
  82. 0 75
      shell/common/native_mate_converters/net_converter.h
  83. 0 87
      shell/common/native_mate_converters/once_callback.h
  84. 0 33
      shell/common/native_mate_converters/string16_converter.h
  85. 2 2
      shell/common/node_bindings.cc
  86. 1 1
      shell/common/v8_value_converter.cc
  87. 3 3
      shell/common/v8_value_converter.h
  88. 37 34
      shell/renderer/api/atom_api_context_bridge.cc
  89. 10 13
      shell/renderer/api/atom_api_context_bridge.h
  90. 7 7
      shell/renderer/api/atom_api_renderer_ipc.cc
  91. 10 10
      shell/renderer/api/atom_api_spell_check_client.cc
  92. 4 4
      shell/renderer/api/atom_api_spell_check_client.h
  93. 14 15
      shell/renderer/api/atom_api_web_frame.cc
  94. 9 14
      shell/renderer/atom_sandboxed_renderer_client.cc
  95. 2 2
      shell/renderer/electron_api_service_impl.cc
  96. 0 1
      shell/renderer/renderer_client_base.cc

+ 10 - 22
filenames.gni

@@ -430,11 +430,7 @@ filenames = {
     "shell/common/api/electron_bindings.cc",
     "shell/common/api/electron_bindings.h",
     "shell/common/api/constructor.h",
-    "shell/common/api/event_emitter_caller_deprecated.cc",
-    "shell/common/api/event_emitter_caller_deprecated.h",
     "shell/common/api/features.cc",
-    "shell/common/api/locker.cc",
-    "shell/common/api/locker.h",
     "shell/common/asar/archive.cc",
     "shell/common/asar/archive.h",
     "shell/common/asar/asar_util.cc",
@@ -466,6 +462,8 @@ filenames = {
     "shell/common/crash_reporter/win/crash_service_main.h",
     "shell/common/gin_converters/accelerator_converter.cc",
     "shell/common/gin_converters/accelerator_converter.h",
+    "shell/common/gin_converters/blink_converter.cc",
+    "shell/common/gin_converters/blink_converter.h",
     "shell/common/gin_converters/callback_converter.h",
     "shell/common/gin_converters/content_converter.cc",
     "shell/common/gin_converters/content_converter.h",
@@ -483,8 +481,8 @@ filenames = {
     "shell/common/gin_converters/net_converter.cc",
     "shell/common/gin_converters/net_converter.h",
     "shell/common/gin_converters/std_converter.h",
-    "shell/common/gin_converters/blink_converter_gin_adapter.h",
-    "shell/common/gin_converters/value_converter_gin_adapter.h",
+    "shell/common/gin_converters/value_converter.cc",
+    "shell/common/gin_converters/value_converter.h",
     "shell/common/gin_helper/arguments.cc",
     "shell/common/gin_helper/arguments.h",
     "shell/common/gin_helper/callback.cc",
@@ -500,8 +498,12 @@ filenames = {
     "shell/common/gin_helper/event_emitter.h",
     "shell/common/gin_helper/function_template.cc",
     "shell/common/gin_helper/function_template.h",
+    "shell/common/gin_helper/locker.cc",
+    "shell/common/gin_helper/locker.h",
     "shell/common/gin_helper/object_template_builder.cc",
     "shell/common/gin_helper/object_template_builder.h",
+    "shell/common/gin_helper/persistent_dictionary.cc",
+    "shell/common/gin_helper/persistent_dictionary.h",
     "shell/common/gin_helper/trackable_object.cc",
     "shell/common/gin_helper/trackable_object.h",
     "shell/common/heap_snapshot.cc",
@@ -515,22 +517,6 @@ filenames = {
     "shell/common/mouse_util.h",
     "shell/common/mac/main_application_bundle.h",
     "shell/common/mac/main_application_bundle.mm",
-    "shell/common/native_mate_converters/blink_converter.cc",
-    "shell/common/native_mate_converters/blink_converter.h",
-    "shell/common/native_mate_converters/callback_converter_deprecated.cc",
-    "shell/common/native_mate_converters/callback_converter_deprecated.h",
-    "shell/common/native_mate_converters/file_dialog_converter.h",
-    "shell/common/native_mate_converters/file_path_converter.h",
-    "shell/common/native_mate_converters/gurl_converter.h",
-    "shell/common/native_mate_converters/image_converter.h",
-    "shell/common/native_mate_converters/native_window_converter.h",
-    "shell/common/native_mate_converters/net_converter.h",
-    "shell/common/native_mate_converters/once_callback.h",
-    "shell/common/native_mate_converters/string16_converter.h",
-    "shell/common/native_mate_converters/v8_value_converter.cc",
-    "shell/common/native_mate_converters/v8_value_converter.h",
-    "shell/common/native_mate_converters/value_converter.cc",
-    "shell/common/native_mate_converters/value_converter.h",
     "shell/common/node_bindings.cc",
     "shell/common/node_bindings.h",
     "shell/common/node_bindings_linux.cc",
@@ -552,6 +538,8 @@ filenames = {
     "shell/common/promise_util.cc",
     "shell/common/skia_util.h",
     "shell/common/skia_util.cc",
+    "shell/common/v8_value_converter.cc",
+    "shell/common/v8_value_converter.h",
     "shell/renderer/api/context_bridge/render_frame_context_bridge_store.cc",
     "shell/renderer/api/context_bridge/render_frame_context_bridge_store.h",
     "shell/renderer/api/atom_api_context_bridge.cc",

+ 0 - 3
native_mate/BUILD.gn

@@ -25,9 +25,6 @@ source_set("native_mate") {
     "native_mate/handle.h",
     "native_mate/object_template_builder.cc",
     "native_mate/object_template_builder_deprecated.h",
-    "native_mate/persistent_dictionary.cc",
-    "native_mate/persistent_dictionary.h",
-    "native_mate/scoped_persistent.h",
     "native_mate/wrappable.cc",
     "native_mate/wrappable.h",
     "native_mate/wrappable_base.h",

+ 0 - 17
native_mate/native_mate/dictionary.h

@@ -40,12 +40,6 @@ class Dictionary {
 
   static Dictionary CreateEmpty(v8::Isolate* isolate);
 
-  bool Has(base::StringPiece key) const {
-    v8::Local<v8::Context> context = isolate_->GetCurrentContext();
-    v8::Local<v8::String> v8_key = StringToV8(isolate_, key);
-    return internal::IsTrue(GetHandle()->Has(context, v8_key));
-  }
-
   template <typename T>
   bool Get(base::StringPiece key, T* out) const {
     // Check for existence before getting, otherwise this method will always
@@ -82,17 +76,6 @@ class Dictionary {
     return !result.IsNothing() && result.FromJust();
   }
 
-  template <typename T>
-  bool SetReadOnlyNonConfigurable(base::StringPiece key, T val) {
-    v8::Local<v8::Value> v8_value;
-    if (!TryConvertToV8(isolate_, val, &v8_value))
-      return false;
-    v8::Maybe<bool> result = GetHandle()->DefineOwnProperty(
-        isolate_->GetCurrentContext(), StringToV8(isolate_, key), v8_value,
-        static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontDelete));
-    return !result.IsNothing() && result.FromJust();
-  }
-
   template <typename T>
   bool SetMethod(base::StringPiece key, const T& callback) {
     return GetHandle()

+ 0 - 35
native_mate/native_mate/persistent_dictionary.cc

@@ -1,35 +0,0 @@
-// Copyright 2014 Cheng Zhao. All rights reserved.
-// Use of this source code is governed by MIT license that can be found in the
-// LICENSE file.
-
-#include "native_mate/persistent_dictionary.h"
-
-namespace mate {
-
-PersistentDictionary::PersistentDictionary() = default;
-
-PersistentDictionary::PersistentDictionary(v8::Isolate* isolate,
-                                           v8::Local<v8::Object> object)
-    : handle_(new RefCountedPersistent<v8::Object>(isolate, object)) {
-  isolate_ = isolate;
-}
-
-PersistentDictionary::PersistentDictionary(const PersistentDictionary& other) =
-    default;
-
-PersistentDictionary::~PersistentDictionary() = default;
-
-v8::Local<v8::Object> PersistentDictionary::GetHandle() const {
-  return handle_->NewHandle();
-}
-
-bool Converter<PersistentDictionary>::FromV8(v8::Isolate* isolate,
-                                             v8::Local<v8::Value> val,
-                                             PersistentDictionary* out) {
-  if (!val->IsObject())
-    return false;
-  *out = PersistentDictionary(isolate, v8::Local<v8::Object>::Cast(val));
-  return true;
-}
-
-}  // namespace mate

+ 0 - 51
native_mate/native_mate/persistent_dictionary.h

@@ -1,51 +0,0 @@
-// Copyright 2014 Cheng Zhao. All rights reserved.
-// Use of this source code is governed by MIT license that can be found in the
-// LICENSE file.
-
-#ifndef NATIVE_MATE_NATIVE_MATE_PERSISTENT_DICTIONARY_H_
-#define NATIVE_MATE_NATIVE_MATE_PERSISTENT_DICTIONARY_H_
-
-#include "native_mate/dictionary.h"
-#include "native_mate/scoped_persistent.h"
-
-namespace mate {
-
-// Like Dictionary, but stores object in persistent handle so you can keep it
-// safely on heap.
-class PersistentDictionary : public Dictionary {
- public:
-  PersistentDictionary();
-  PersistentDictionary(v8::Isolate* isolate, v8::Local<v8::Object> object);
-  PersistentDictionary(const PersistentDictionary& other);
-  ~PersistentDictionary() override;
-
-  v8::Local<v8::Object> GetHandle() const override;
-
- private:
-  scoped_refptr<RefCountedPersistent<v8::Object>> handle_;
-};
-
-template <>
-struct Converter<PersistentDictionary> {
-  static bool FromV8(v8::Isolate* isolate,
-                     v8::Local<v8::Value> val,
-                     PersistentDictionary* out);
-};
-
-}  // namespace mate
-
-namespace gin {
-
-// Keep compatibility with gin.
-template <>
-struct Converter<mate::PersistentDictionary> {
-  static bool FromV8(v8::Isolate* isolate,
-                     v8::Local<v8::Value> val,
-                     mate::PersistentDictionary* out) {
-    return mate::ConvertFromV8(isolate, val, out);
-  }
-};
-
-}  // namespace gin
-
-#endif  // NATIVE_MATE_NATIVE_MATE_PERSISTENT_DICTIONARY_H_

+ 0 - 102
native_mate/native_mate/scoped_persistent.h

@@ -1,102 +0,0 @@
-// Copyright 2014 Cheng Zhao. All rights reserved.
-// Use of this source code is governed by MIT license that can be found in the
-// LICENSE file.
-
-#ifndef NATIVE_MATE_NATIVE_MATE_SCOPED_PERSISTENT_H_
-#define NATIVE_MATE_NATIVE_MATE_SCOPED_PERSISTENT_H_
-
-#include "base/memory/ref_counted.h"
-#include "native_mate/converter.h"
-#include "v8/include/v8.h"
-
-namespace mate {
-
-// A v8::Persistent handle to a V8 value which destroys and clears the
-// underlying handle on destruction.
-template <typename T>
-class ScopedPersistent {
- public:
-  ScopedPersistent() : isolate_(v8::Isolate::GetCurrent()) {}
-
-  ScopedPersistent(v8::Isolate* isolate, v8::Local<v8::Value> handle)
-      : isolate_(isolate) {
-    reset(isolate, v8::Local<T>::Cast(handle));
-  }
-
-  ~ScopedPersistent() { reset(); }
-
-  void reset(v8::Isolate* isolate, v8::Local<T> handle) {
-    if (!handle.IsEmpty()) {
-      isolate_ = isolate;
-      handle_.Reset(isolate, handle);
-    } else {
-      reset();
-    }
-  }
-
-  void reset() { handle_.Reset(); }
-
-  bool IsEmpty() const { return handle_.IsEmpty(); }
-
-  v8::Local<T> NewHandle() const { return NewHandle(isolate_); }
-
-  v8::Local<T> NewHandle(v8::Isolate* isolate) const {
-    if (handle_.IsEmpty())
-      return v8::Local<T>();
-    return v8::Local<T>::New(isolate, handle_);
-  }
-
-  template <typename P, typename C>
-  void SetWeak(P* parameter, C callback) {
-    handle_.SetWeak(parameter, callback);
-  }
-
-  v8::Isolate* isolate() const { return isolate_; }
-
- private:
-  v8::Isolate* isolate_ = nullptr;
-  v8::Persistent<T> handle_;
-
-  DISALLOW_COPY_AND_ASSIGN(ScopedPersistent);
-};
-
-template <typename T>
-class RefCountedPersistent : public ScopedPersistent<T>,
-                             public base::RefCounted<RefCountedPersistent<T>> {
- public:
-  RefCountedPersistent() = default;
-
-  RefCountedPersistent(v8::Isolate* isolate, v8::Local<v8::Value> handle)
-      : ScopedPersistent<T>(isolate, handle) {}
-
- protected:
-  friend class base::RefCounted<RefCountedPersistent<T>>;
-
-  ~RefCountedPersistent() = default;
-
- private:
-  DISALLOW_COPY_AND_ASSIGN(RefCountedPersistent);
-};
-
-template <typename T>
-struct Converter<ScopedPersistent<T>> {
-  static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
-                                   const ScopedPersistent<T>& val) {
-    return val.NewHandle(isolate);
-  }
-
-  static bool FromV8(v8::Isolate* isolate,
-                     v8::Local<v8::Value> val,
-                     ScopedPersistent<T>* out) {
-    v8::Local<T> converted;
-    if (!Converter<v8::Local<T>>::FromV8(isolate, val, &converted))
-      return false;
-
-    out->reset(isolate, converted);
-    return true;
-  }
-};
-
-}  // namespace mate
-
-#endif  // NATIVE_MATE_NATIVE_MATE_SCOPED_PERSISTENT_H_

+ 1 - 1
shell/browser/api/atom_api_app.cc

@@ -48,7 +48,7 @@
 #include "shell/common/gin_converters/gurl_converter.h"
 #include "shell/common/gin_converters/image_converter.h"
 #include "shell/common/gin_converters/net_converter.h"
-#include "shell/common/gin_converters/value_converter_gin_adapter.h"
+#include "shell/common/gin_converters/value_converter.h"
 #include "shell/common/gin_helper/dictionary.h"
 #include "shell/common/gin_helper/object_template_builder.h"
 #include "shell/common/node_includes.h"

+ 1 - 1
shell/browser/api/atom_api_browser_window.cc

@@ -18,7 +18,7 @@
 #include "shell/browser/window_list.h"
 #include "shell/common/api/constructor.h"
 #include "shell/common/color_util.h"
-#include "shell/common/gin_converters/value_converter_gin_adapter.h"
+#include "shell/common/gin_converters/value_converter.h"
 #include "shell/common/gin_helper/dictionary.h"
 #include "shell/common/gin_helper/object_template_builder.h"
 #include "shell/common/node_includes.h"

+ 13 - 14
shell/browser/api/atom_api_content_tracing.cc

@@ -6,21 +6,20 @@
 #include <string>
 #include <utility>
 
-#include "base/bind.h"
 #include "base/files/file_util.h"
 #include "base/optional.h"
 #include "base/threading/thread_restrictions.h"
 #include "content/public/browser/tracing_controller.h"
-#include "native_mate/dictionary.h"
-#include "shell/common/native_mate_converters/callback_converter_deprecated.h"
-#include "shell/common/native_mate_converters/file_path_converter.h"
-#include "shell/common/native_mate_converters/value_converter.h"
+#include "shell/common/gin_converters/callback_converter.h"
+#include "shell/common/gin_converters/file_path_converter.h"
+#include "shell/common/gin_converters/value_converter.h"
+#include "shell/common/gin_helper/dictionary.h"
 #include "shell/common/node_includes.h"
 #include "shell/common/promise_util.h"
 
 using content::TracingController;
 
-namespace mate {
+namespace gin {
 
 template <>
 struct Converter<base::trace_event::TraceConfig> {
@@ -31,7 +30,7 @@ struct Converter<base::trace_event::TraceConfig> {
     // has to be checked first because none of the fields
     // in the `memory_dump_config` dict below are mandatory
     // and we cannot check the config format.
-    Dictionary options;
+    gin_helper::Dictionary options;
     if (ConvertFromV8(isolate, val, &options)) {
       std::string category_filter, trace_options;
       if (options.Get("categoryFilter", &category_filter) &&
@@ -51,7 +50,7 @@ struct Converter<base::trace_event::TraceConfig> {
   }
 };
 
-}  // namespace mate
+}  // namespace gin
 
 namespace {
 
@@ -79,7 +78,7 @@ void StopTracing(electron::util::Promise<base::FilePath> promise,
   }
 }
 
-v8::Local<v8::Promise> StopRecording(mate::Arguments* args) {
+v8::Local<v8::Promise> StopRecording(gin_helper::Arguments* args) {
   electron::util::Promise<base::FilePath> promise(args->isolate());
   v8::Local<v8::Promise> handle = promise.GetHandle();
 
@@ -131,18 +130,18 @@ v8::Local<v8::Promise> StartTracing(
 }
 
 void OnTraceBufferUsageAvailable(
-    electron::util::Promise<mate::Dictionary> promise,
+    electron::util::Promise<gin_helper::Dictionary> promise,
     float percent_full,
     size_t approximate_count) {
-  mate::Dictionary dict = mate::Dictionary::CreateEmpty(promise.isolate());
+  gin_helper::Dictionary dict = gin::Dictionary::CreateEmpty(promise.isolate());
   dict.Set("percentage", percent_full);
   dict.Set("value", approximate_count);
 
-  promise.Resolve(dict);
+  promise.ResolveWithGin(dict);
 }
 
 v8::Local<v8::Promise> GetTraceBufferUsage(v8::Isolate* isolate) {
-  electron::util::Promise<mate::Dictionary> promise(isolate);
+  electron::util::Promise<gin_helper::Dictionary> promise(isolate);
   v8::Local<v8::Promise> handle = promise.GetHandle();
 
   // Note: This method always succeeds.
@@ -155,7 +154,7 @@ void Initialize(v8::Local<v8::Object> exports,
                 v8::Local<v8::Value> unused,
                 v8::Local<v8::Context> context,
                 void* priv) {
-  mate::Dictionary dict(context->GetIsolate(), exports);
+  gin_helper::Dictionary dict(context->GetIsolate(), exports);
   dict.SetMethod("getCategories", &GetCategories);
   dict.SetMethod("startRecording", &StartTracing);
   dict.SetMethod("stopRecording", &StopRecording);

+ 1 - 1
shell/browser/api/atom_api_cookies.cc

@@ -21,7 +21,7 @@
 #include "shell/browser/atom_browser_context.h"
 #include "shell/browser/cookie_change_notifier.h"
 #include "shell/common/gin_converters/gurl_converter.h"
-#include "shell/common/gin_converters/value_converter_gin_adapter.h"
+#include "shell/common/gin_converters/value_converter.h"
 #include "shell/common/gin_helper/dictionary.h"
 #include "shell/common/gin_helper/object_template_builder.h"
 

+ 2 - 2
shell/browser/api/atom_api_debugger.cc

@@ -12,7 +12,7 @@
 #include "base/json/json_writer.h"
 #include "content/public/browser/devtools_agent_host.h"
 #include "content/public/browser/web_contents.h"
-#include "shell/common/gin_converters/value_converter_gin_adapter.h"
+#include "shell/common/gin_converters/value_converter.h"
 #include "shell/common/gin_helper/dictionary.h"
 #include "shell/common/gin_helper/object_template_builder.h"
 #include "shell/common/node_includes.h"
@@ -80,7 +80,7 @@ void Debugger::DispatchProtocolMessage(DevToolsAgentHost* agent_host,
       if (dict->GetDictionary("result", &result_body)) {
         result.Swap(result_body);
       }
-      promise.Resolve(result);
+      promise.ResolveWithGin(result);
     }
   }
 }

+ 1 - 1
shell/browser/api/atom_api_event.cc

@@ -20,7 +20,7 @@ void Initialize(v8::Local<v8::Object> exports,
                 void* priv) {
   gin_helper::Dictionary dict(context->GetIsolate(), exports);
   dict.SetMethod("createWithSender", &CreateWithSender);
-  dict.SetMethod("createEmpty", &mate::Event::Create);
+  dict.SetMethod("createEmpty", &gin_helper::Event::Create);
 }
 
 }  // namespace

+ 1 - 1
shell/browser/api/atom_api_menu.h

@@ -12,7 +12,7 @@
 #include "gin/arguments.h"
 #include "shell/browser/api/atom_api_top_level_window.h"
 #include "shell/browser/ui/atom_menu_model.h"
-#include "shell/common/api/locker.h"
+#include "shell/common/gin_helper/locker.h"
 #include "shell/common/gin_helper/trackable_object.h"
 
 namespace electron {

+ 1 - 1
shell/browser/api/atom_api_menu_mac.mm

@@ -56,7 +56,7 @@ void MenuMac::PopupOnUI(const base::WeakPtr<NativeWindow>& native_window,
                         int y,
                         int positioning_item,
                         base::Closure callback) {
-  mate::Locker locker(isolate());
+  gin_helper::Locker locker(isolate());
   v8::HandleScope handle_scope(isolate());
 
   if (!native_window)

+ 1 - 1
shell/browser/api/atom_api_menu_views.cc

@@ -25,7 +25,7 @@ void MenuViews::PopupAt(TopLevelWindow* window,
                         int y,
                         int positioning_item,
                         const base::Closure& callback) {
-  mate::Locker locker(isolate());
+  gin_helper::Locker locker(isolate());
   v8::HandleScope handle_scope(isolate());
 
   auto* native_window = static_cast<NativeWindowViews*>(window->window());

+ 1 - 1
shell/browser/api/atom_api_session.cc

@@ -57,7 +57,7 @@
 #include "shell/common/gin_converters/file_path_converter.h"
 #include "shell/common/gin_converters/gurl_converter.h"
 #include "shell/common/gin_converters/net_converter.h"
-#include "shell/common/gin_converters/value_converter_gin_adapter.h"
+#include "shell/common/gin_converters/value_converter.h"
 #include "shell/common/gin_helper/dictionary.h"
 #include "shell/common/gin_helper/object_template_builder.h"
 #include "shell/common/node_includes.h"

+ 1 - 1
shell/browser/api/atom_api_system_preferences.cc

@@ -5,7 +5,7 @@
 #include "shell/browser/api/atom_api_system_preferences.h"
 
 #include "shell/common/gin_converters/callback_converter.h"
-#include "shell/common/gin_converters/value_converter_gin_adapter.h"
+#include "shell/common/gin_converters/value_converter.h"
 #include "shell/common/gin_helper/dictionary.h"
 #include "shell/common/gin_helper/object_template_builder.h"
 #include "shell/common/node_includes.h"

+ 1 - 1
shell/browser/api/atom_api_system_preferences_mac.mm

@@ -27,7 +27,7 @@
 #include "shell/browser/ui/cocoa/NSColor+Hex.h"
 #include "shell/common/deprecate_util.h"
 #include "shell/common/gin_converters/gurl_converter.h"
-#include "shell/common/gin_converters/value_converter_gin_adapter.h"
+#include "shell/common/gin_converters/value_converter.h"
 #include "ui/native_theme/native_theme.h"
 
 namespace gin {

+ 7 - 6
shell/browser/api/atom_api_top_level_window.cc

@@ -5,11 +5,11 @@
 #include "shell/browser/api/atom_api_top_level_window.h"
 
 #include <string>
+#include <utility>
 #include <vector>
 
 #include "electron/buildflags/buildflags.h"
 #include "gin/dictionary.h"
-#include "native_mate/persistent_dictionary.h"
 #include "shell/browser/api/atom_api_browser_view.h"
 #include "shell/browser/api/atom_api_menu.h"
 #include "shell/browser/api/atom_api_view.h"
@@ -20,9 +20,10 @@
 #include "shell/common/gin_converters/gfx_converter.h"
 #include "shell/common/gin_converters/image_converter.h"
 #include "shell/common/gin_converters/native_window_converter.h"
-#include "shell/common/gin_converters/value_converter_gin_adapter.h"
+#include "shell/common/gin_converters/value_converter.h"
 #include "shell/common/gin_helper/dictionary.h"
 #include "shell/common/gin_helper/object_template_builder.h"
+#include "shell/common/gin_helper/persistent_dictionary.h"
 #include "shell/common/node_includes.h"
 #include "shell/common/options_switches.h"
 
@@ -809,8 +810,8 @@ void TopLevelWindow::SetVibrancy(v8::Isolate* isolate,
 }
 
 void TopLevelWindow::SetTouchBar(
-    const std::vector<mate::PersistentDictionary>& items) {
-  window_->SetTouchBar(items);
+    std::vector<gin_helper::PersistentDictionary> items) {
+  window_->SetTouchBar(std::move(items));
 }
 
 void TopLevelWindow::RefreshTouchBarItem(const std::string& item_id) {
@@ -818,8 +819,8 @@ void TopLevelWindow::RefreshTouchBarItem(const std::string& item_id) {
 }
 
 void TopLevelWindow::SetEscapeTouchBarItem(
-    const mate::PersistentDictionary& item) {
-  window_->SetEscapeTouchBarItem(item);
+    gin_helper::PersistentDictionary item) {
+  window_->SetEscapeTouchBarItem(std::move(item));
 }
 
 void TopLevelWindow::SelectPreviousTab() {

+ 2 - 2
shell/browser/api/atom_api_top_level_window.h

@@ -184,9 +184,9 @@ class TopLevelWindow : public gin_helper::TrackableObject<TopLevelWindow>,
   bool IsVisibleOnAllWorkspaces();
   void SetAutoHideCursor(bool auto_hide);
   virtual void SetVibrancy(v8::Isolate* isolate, v8::Local<v8::Value> value);
-  void SetTouchBar(const std::vector<mate::PersistentDictionary>& items);
+  void SetTouchBar(std::vector<gin_helper::PersistentDictionary> items);
   void RefreshTouchBarItem(const std::string& item_id);
-  void SetEscapeTouchBarItem(const mate::PersistentDictionary& item);
+  void SetEscapeTouchBarItem(gin_helper::PersistentDictionary item);
   void SelectPreviousTab();
   void SelectNextTab();
   void MergeAllWindows();

+ 8 - 8
shell/browser/api/atom_api_web_contents.cc

@@ -70,7 +70,7 @@
 #include "shell/browser/web_view_guest_delegate.h"
 #include "shell/common/api/atom_api_native_image.h"
 #include "shell/common/color_util.h"
-#include "shell/common/gin_converters/blink_converter_gin_adapter.h"
+#include "shell/common/gin_converters/blink_converter.h"
 #include "shell/common/gin_converters/callback_converter.h"
 #include "shell/common/gin_converters/content_converter.h"
 #include "shell/common/gin_converters/file_path_converter.h"
@@ -78,7 +78,7 @@
 #include "shell/common/gin_converters/gurl_converter.h"
 #include "shell/common/gin_converters/image_converter.h"
 #include "shell/common/gin_converters/net_converter.h"
-#include "shell/common/gin_converters/value_converter_gin_adapter.h"
+#include "shell/common/gin_converters/value_converter.h"
 #include "shell/common/gin_helper/dictionary.h"
 #include "shell/common/gin_helper/object_template_builder.h"
 #include "shell/common/mouse_util.h"
@@ -1023,7 +1023,7 @@ void WebContents::Message(bool internal,
                           blink::CloneableMessage arguments) {
   // webContents.emit('-ipc-message', new Event(), internal, channel,
   // arguments);
-  EmitWithSender("-ipc-message", bindings_.dispatch_context(), base::nullopt,
+  EmitWithSender("-ipc-message", bindings_.dispatch_context(), InvokeCallback(),
                  internal, channel, std::move(arguments));
 }
 
@@ -1064,7 +1064,7 @@ void WebContents::MessageHost(const std::string& channel,
                               blink::CloneableMessage arguments) {
   // webContents.emit('ipc-message-host', new Event(), channel, args);
   EmitWithSender("ipc-message-host", bindings_.dispatch_context(),
-                 base::nullopt, channel, std::move(arguments));
+                 InvokeCallback(), channel, std::move(arguments));
 }
 
 #if BUILDFLAG(ENABLE_REMOTE_MODULE)
@@ -1075,7 +1075,7 @@ void WebContents::DereferenceRemoteJSObject(const std::string& context_id,
   args.Append(context_id);
   args.Append(object_id);
   args.Append(ref_count);
-  EmitWithSender("-ipc-message", bindings_.dispatch_context(), base::nullopt,
+  EmitWithSender("-ipc-message", bindings_.dispatch_context(), InvokeCallback(),
                  /* internal */ true, "ELECTRON_BROWSER_DEREFERENCE",
                  std::move(args));
 }
@@ -2071,10 +2071,10 @@ void WebContents::SendInputEvent(v8::Isolate* isolate,
 
   content::RenderWidgetHost* rwh = view->GetRenderWidgetHost();
   blink::WebInputEvent::Type type =
-      mate::GetWebInputEventType(isolate, input_event);
+      gin::GetWebInputEventType(isolate, input_event);
   if (blink::WebInputEvent::IsMouseEventType(type)) {
     blink::WebMouseEvent mouse_event;
-    if (mate::ConvertFromV8(isolate, input_event, &mouse_event)) {
+    if (gin::ConvertFromV8(isolate, input_event, &mouse_event)) {
       if (IsOffScreen()) {
 #if BUILDFLAG(ENABLE_OSR)
         GetOffScreenRenderWidgetHostView()->SendMouseEvent(mouse_event);
@@ -2094,7 +2094,7 @@ void WebContents::SendInputEvent(v8::Isolate* isolate,
     }
   } else if (type == blink::WebInputEvent::kMouseWheel) {
     blink::WebMouseWheelEvent mouse_wheel_event;
-    if (mate::ConvertFromV8(isolate, input_event, &mouse_wheel_event)) {
+    if (gin::ConvertFromV8(isolate, input_event, &mouse_wheel_event)) {
       if (IsOffScreen()) {
 #if BUILDFLAG(ENABLE_OSR)
         GetOffScreenRenderWidgetHostView()->SendMouseWheelEvent(

+ 1 - 1
shell/browser/api/atom_api_web_request.cc

@@ -20,7 +20,7 @@
 #include "shell/common/gin_converters/gurl_converter.h"
 #include "shell/common/gin_converters/net_converter.h"
 #include "shell/common/gin_converters/std_converter.h"
-#include "shell/common/gin_converters/value_converter_gin_adapter.h"
+#include "shell/common/gin_converters/value_converter.h"
 
 namespace gin {
 

+ 1 - 1
shell/browser/api/atom_api_web_view_manager.cc

@@ -7,7 +7,7 @@
 #include "shell/browser/web_contents_zoom_controller.h"
 #include "shell/browser/web_view_manager.h"
 #include "shell/common/gin_converters/content_converter.h"
-#include "shell/common/gin_converters/value_converter_gin_adapter.h"
+#include "shell/common/gin_converters/value_converter.h"
 #include "shell/common/gin_helper/dictionary.h"
 #include "shell/common/node_includes.h"
 #include "shell/common/options_switches.h"

+ 24 - 23
shell/browser/api/event.cc

@@ -6,26 +6,26 @@
 
 #include <utility>
 
-#include "native_mate/object_template_builder_deprecated.h"
-#include "shell/common/native_mate_converters/blink_converter.h"
+#include "gin/object_template_builder.h"
+#include "shell/common/gin_converters/blink_converter.h"
 
-namespace mate {
+namespace gin_helper {
 
-Event::Event(v8::Isolate* isolate) {
-  Init(isolate);
-}
+gin::WrapperInfo Event::kWrapperInfo = {gin::kEmbedderNativeGin};
+
+Event::Event() {}
 
 Event::~Event() = default;
 
-void Event::SetCallback(base::Optional<InvokeCallback> callback) {
+void Event::SetCallback(InvokeCallback callback) {
   DCHECK(!callback_);
   callback_ = std::move(callback);
 }
 
 void Event::PreventDefault(v8::Isolate* isolate) {
-  GetWrapper()
-      ->Set(isolate->GetCurrentContext(),
-            StringToV8(isolate, "defaultPrevented"), v8::True(isolate))
+  v8::Local<v8::Object> self = GetWrapper(isolate).ToLocalChecked();
+  self->Set(isolate->GetCurrentContext(),
+            gin::StringToV8(isolate, "defaultPrevented"), v8::True(isolate))
       .Check();
 }
 
@@ -34,27 +34,28 @@ bool Event::SendReply(v8::Isolate* isolate, v8::Local<v8::Value> result) {
     return false;
 
   blink::CloneableMessage message;
-  if (!ConvertFromV8(isolate, result, &message)) {
+  if (!gin::ConvertFromV8(isolate, result, &message)) {
     return false;
   }
 
-  std::move(*callback_).Run(std::move(message));
-  callback_.reset();
+  std::move(callback_).Run(std::move(message));
   return true;
 }
 
-// static
-Handle<Event> Event::Create(v8::Isolate* isolate) {
-  return mate::CreateHandle(isolate, new Event(isolate));
+gin::ObjectTemplateBuilder Event::GetObjectTemplateBuilder(
+    v8::Isolate* isolate) {
+  return gin::Wrappable<Event>::GetObjectTemplateBuilder(isolate)
+      .SetMethod("preventDefault", &Event::PreventDefault)
+      .SetMethod("sendReply", &Event::SendReply);
+}
+
+const char* Event::GetTypeName() {
+  return "WebRequest";
 }
 
 // static
-void Event::BuildPrototype(v8::Isolate* isolate,
-                           v8::Local<v8::FunctionTemplate> prototype) {
-  prototype->SetClassName(mate::StringToV8(isolate, "Event"));
-  mate::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate())
-      .SetMethod("preventDefault", &Event::PreventDefault)
-      .SetMethod("sendReply", &Event::SendReply);
+gin::Handle<Event> Event::Create(v8::Isolate* isolate) {
+  return gin::CreateHandle(isolate, new Event());
 }
 
-}  // namespace mate
+}  // namespace gin_helper

+ 16 - 12
shell/browser/api/event.h

@@ -5,27 +5,26 @@
 #ifndef SHELL_BROWSER_API_EVENT_H_
 #define SHELL_BROWSER_API_EVENT_H_
 
-#include "base/optional.h"
 #include "electron/shell/common/api/api.mojom.h"
-#include "native_mate/handle.h"
-#include "native_mate/wrappable.h"
+#include "gin/handle.h"
+#include "gin/wrappable.h"
 
 namespace IPC {
 class Message;
 }
 
-namespace mate {
+namespace gin_helper {
 
-class Event : public Wrappable<Event> {
+class Event : public gin::Wrappable<Event> {
  public:
   using InvokeCallback = electron::mojom::ElectronBrowser::InvokeCallback;
-  static Handle<Event> Create(v8::Isolate* isolate);
 
-  static void BuildPrototype(v8::Isolate* isolate,
-                             v8::Local<v8::FunctionTemplate> prototype);
+  static gin::WrapperInfo kWrapperInfo;
+
+  static gin::Handle<Event> Create(v8::Isolate* isolate);
 
   // Pass the callback to be invoked.
-  void SetCallback(base::Optional<InvokeCallback> callback);
+  void SetCallback(InvokeCallback callback);
 
   // event.PreventDefault().
   void PreventDefault(v8::Isolate* isolate);
@@ -35,16 +34,21 @@ class Event : public Wrappable<Event> {
   bool SendReply(v8::Isolate* isolate, v8::Local<v8::Value> result);
 
  protected:
-  explicit Event(v8::Isolate* isolate);
+  Event();
   ~Event() override;
 
+  // gin::Wrappable:
+  gin::ObjectTemplateBuilder GetObjectTemplateBuilder(
+      v8::Isolate* isolate) override;
+  const char* GetTypeName() override;
+
  private:
   // Replyer for the synchronous messages.
-  base::Optional<InvokeCallback> callback_;
+  InvokeCallback callback_;
 
   DISALLOW_COPY_AND_ASSIGN(Event);
 };
 
-}  // namespace mate
+}  // namespace gin_helper
 
 #endif  // SHELL_BROWSER_API_EVENT_H_

+ 3 - 2
shell/browser/api/gpuinfo_manager.cc

@@ -11,6 +11,7 @@
 #include "content/public/browser/browser_thread.h"
 #include "gpu/config/gpu_info_collector.h"
 #include "shell/browser/api/gpu_info_enumerator.h"
+#include "shell/common/gin_converters/value_converter.h"
 
 namespace electron {
 
@@ -46,7 +47,7 @@ void GPUInfoManager::ProcessCompleteInfo() {
   // We have received the complete information, resolve all promises that
   // were waiting for this info.
   for (auto& promise : complete_info_promise_set_) {
-    promise.Resolve(*result);
+    promise.ResolveWithGin(*result);
   }
   complete_info_promise_set_.clear();
 }
@@ -86,7 +87,7 @@ void GPUInfoManager::FetchBasicInfo(
     util::Promise<base::DictionaryValue> promise) {
   gpu::GPUInfo gpu_info;
   CollectBasicGraphicsInfo(&gpu_info);
-  promise.Resolve(*EnumerateGPUInfo(gpu_info));
+  promise.ResolveWithGin(*EnumerateGPUInfo(gpu_info));
 }
 
 std::unique_ptr<base::DictionaryValue> GPUInfoManager::EnumerateGPUInfo(

+ 0 - 1
shell/browser/api/gpuinfo_manager.h

@@ -12,7 +12,6 @@
 #include "content/browser/gpu/gpu_data_manager_impl.h"  // nogncheck
 #include "content/public/browser/gpu_data_manager.h"
 #include "content/public/browser/gpu_data_manager_observer.h"
-#include "shell/common/native_mate_converters/value_converter.h"
 #include "shell/common/promise_util.h"
 
 namespace electron {

+ 1 - 1
shell/browser/auto_updater_mac.mm

@@ -16,7 +16,7 @@
 #include "base/time/time.h"
 #include "gin/arguments.h"
 #include "shell/browser/browser.h"
-#include "shell/common/gin_converters/value_converter_gin_adapter.h"
+#include "shell/common/gin_converters/value_converter.h"
 #include "shell/common/gin_helper/dictionary.h"
 #include "shell/common/gin_helper/error_thrower.h"
 

+ 62 - 1
shell/browser/login_handler.cc

@@ -5,7 +5,9 @@
 #include "shell/browser/login_handler.h"
 
 #include <memory>
+#include <string>
 #include <utility>
+#include <vector>
 
 #include "base/task/post_task.h"
 #include "base/values.h"
@@ -13,13 +15,71 @@
 #include "content/public/browser/browser_thread.h"
 #include "content/public/browser/web_contents.h"
 #include "net/base/auth.h"
+#include "net/base/upload_bytes_element_reader.h"
+#include "net/base/upload_data_stream.h"
+#include "net/base/upload_element_reader.h"
+#include "net/base/upload_file_element_reader.h"
 #include "shell/browser/browser.h"
-#include "shell/common/native_mate_converters/net_converter.h"
+#include "shell/common/gin_converters/net_converter.h"
 
 using content::BrowserThread;
 
 namespace electron {
 
+namespace {
+
+void GetUploadData(base::ListValue* upload_data_list,
+                   const net::URLRequest* request) {
+  const net::UploadDataStream* upload_data = request->get_upload_for_testing();
+  if (!upload_data)
+    return;
+  const std::vector<std::unique_ptr<net::UploadElementReader>>* readers =
+      upload_data->GetElementReaders();
+  for (const auto& reader : *readers) {
+    auto upload_data_dict = std::make_unique<base::DictionaryValue>();
+    if (reader->AsBytesReader()) {
+      const net::UploadBytesElementReader* bytes_reader =
+          reader->AsBytesReader();
+      auto bytes = std::make_unique<base::Value>(
+          std::vector<char>(bytes_reader->bytes(),
+                            bytes_reader->bytes() + bytes_reader->length()));
+      upload_data_dict->Set("bytes", std::move(bytes));
+    } else if (reader->AsFileReader()) {
+      const net::UploadFileElementReader* file_reader = reader->AsFileReader();
+      auto file_path = file_reader->path().AsUTF8Unsafe();
+      upload_data_dict->SetKey("file", base::Value(file_path));
+    }
+    // else {
+    //   const storage::UploadBlobElementReader* blob_reader =
+    //       static_cast<storage::UploadBlobElementReader*>(reader.get());
+    //   upload_data_dict->SetString("blobUUID", blob_reader->uuid());
+    // }
+    upload_data_list->Append(std::move(upload_data_dict));
+  }
+}
+
+void FillRequestDetails(base::DictionaryValue* details,
+                        const net::URLRequest* request) {
+  details->SetString("method", request->method());
+  std::string url;
+  if (!request->url_chain().empty())
+    url = request->url().spec();
+  details->SetKey("url", base::Value(url));
+  details->SetString("referrer", request->referrer());
+  auto list = std::make_unique<base::ListValue>();
+  GetUploadData(list.get(), request);
+  if (!list->empty())
+    details->Set("uploadData", std::move(list));
+  auto headers_value = std::make_unique<base::DictionaryValue>();
+  for (net::HttpRequestHeaders::Iterator it(request->extra_request_headers());
+       it.GetNext();) {
+    headers_value->SetString(it.name(), it.value());
+  }
+  details->Set("headers", std::move(headers_value));
+}
+
+}  // namespace
+
 LoginHandler::LoginHandler(net::URLRequest* request,
                            const net::AuthChallengeInfo& auth_info,
                            // net::NetworkDelegate::AuthCallback callback,
@@ -32,6 +92,7 @@ LoginHandler::LoginHandler(net::URLRequest* request,
 
   std::unique_ptr<base::DictionaryValue> request_details(
       new base::DictionaryValue);
+  // TODO(zcbenz): Use the converters from net_converter.
   FillRequestDetails(request_details.get(), request);
 
   // TODO(deepak1556): fix with network service

+ 3 - 2
shell/browser/native_window.cc

@@ -15,6 +15,7 @@
 #include "shell/browser/window_list.h"
 #include "shell/common/color_util.h"
 #include "shell/common/gin_helper/dictionary.h"
+#include "shell/common/gin_helper/persistent_dictionary.h"
 #include "shell/common/options_switches.h"
 #include "ui/views/widget/widget.h"
 
@@ -346,12 +347,12 @@ bool NativeWindow::AddTabbedWindow(NativeWindow* window) {
 void NativeWindow::SetVibrancy(const std::string& filename) {}
 
 void NativeWindow::SetTouchBar(
-    const std::vector<mate::PersistentDictionary>& items) {}
+    std::vector<gin_helper::PersistentDictionary> items) {}
 
 void NativeWindow::RefreshTouchBarItem(const std::string& item_id) {}
 
 void NativeWindow::SetEscapeTouchBarItem(
-    const mate::PersistentDictionary& item) {}
+    gin_helper::PersistentDictionary item) {}
 
 void NativeWindow::SetAutoHideMenuBar(bool auto_hide) {}
 

+ 3 - 7
shell/browser/native_window.h

@@ -39,11 +39,8 @@ class Size;
 
 namespace gin_helper {
 class Dictionary;
-}
-
-namespace mate {
 class PersistentDictionary;
-}
+}  // namespace gin_helper
 
 namespace electron {
 
@@ -198,10 +195,9 @@ class NativeWindow : public base::SupportsUserData,
   virtual void SetVibrancy(const std::string& type);
 
   // Touchbar API
-  virtual void SetTouchBar(
-      const std::vector<mate::PersistentDictionary>& items);
+  virtual void SetTouchBar(std::vector<gin_helper::PersistentDictionary> items);
   virtual void RefreshTouchBarItem(const std::string& item_id);
-  virtual void SetEscapeTouchBarItem(const mate::PersistentDictionary& item);
+  virtual void SetEscapeTouchBarItem(gin_helper::PersistentDictionary item);
 
   // Native Tab API
   virtual void SelectPreviousTab();

+ 2 - 2
shell/browser/native_window_mac.h

@@ -133,9 +133,9 @@ class NativeWindowMac : public NativeWindow {
 
   void SetVibrancy(const std::string& type) override;
   void SetTouchBar(
-      const std::vector<mate::PersistentDictionary>& items) override;
+      std::vector<gin_helper::PersistentDictionary> items) override;
   void RefreshTouchBarItem(const std::string& item_id) override;
-  void SetEscapeTouchBarItem(const mate::PersistentDictionary& item) override;
+  void SetEscapeTouchBarItem(gin_helper::PersistentDictionary item) override;
   void SetGTKDarkThemeEnabled(bool use_dark_theme) override {}
 
   gfx::Rect ContentBoundsToWindowBounds(const gfx::Rect& bounds) const override;

+ 5 - 4
shell/browser/native_window_mac.mm

@@ -1462,12 +1462,12 @@ void NativeWindowMac::SetVibrancy(const std::string& type) {
 }
 
 void NativeWindowMac::SetTouchBar(
-    const std::vector<mate::PersistentDictionary>& items) {
+    std::vector<gin_helper::PersistentDictionary> items) {
   if (@available(macOS 10.12.2, *)) {
     touch_bar_.reset([[AtomTouchBar alloc]
         initWithDelegate:window_delegate_.get()
                   window:this
-                settings:items]);
+                settings:std::move(items)]);
     [window_ setTouchBar:nil];
   }
 }
@@ -1480,10 +1480,11 @@ void NativeWindowMac::RefreshTouchBarItem(const std::string& item_id) {
 }
 
 void NativeWindowMac::SetEscapeTouchBarItem(
-    const mate::PersistentDictionary& item) {
+    gin_helper::PersistentDictionary item) {
   if (@available(macOS 10.12.2, *)) {
     if (touch_bar_ && [window_ touchBar])
-      [touch_bar_ setEscapeTouchBarItem:item forTouchBar:[window_ touchBar]];
+      [touch_bar_ setEscapeTouchBarItem:std::move(item)
+                            forTouchBar:[window_ touchBar]];
   }
 }
 

+ 1 - 1
shell/browser/net/atom_url_loader_factory.cc

@@ -27,7 +27,7 @@
 #include "shell/common/gin_converters/file_path_converter.h"
 #include "shell/common/gin_converters/gurl_converter.h"
 #include "shell/common/gin_converters/net_converter.h"
-#include "shell/common/gin_converters/value_converter_gin_adapter.h"
+#include "shell/common/gin_converters/value_converter.h"
 
 #include "shell/common/node_includes.h"
 

+ 0 - 1
shell/browser/net/cert_verifier_client.cc

@@ -5,7 +5,6 @@
 #include <utility>
 
 #include "shell/browser/net/cert_verifier_client.h"
-#include "shell/common/native_mate_converters/net_converter.h"
 
 namespace electron {
 

+ 2 - 2
shell/browser/printing/print_preview_message_handler.cc

@@ -23,7 +23,7 @@
 #include "content/public/browser/browser_thread.h"
 #include "content/public/browser/render_frame_host.h"
 #include "content/public/browser/web_contents.h"
-#include "shell/common/api/locker.h"
+#include "shell/common/gin_helper/locker.h"
 
 #include "shell/common/node_includes.h"
 
@@ -175,7 +175,7 @@ void PrintPreviewMessageHandler::ResolvePromise(
   util::Promise<v8::Local<v8::Value>> promise = GetPromise(request_id);
 
   v8::Isolate* isolate = promise.isolate();
-  mate::Locker locker(isolate);
+  gin_helper::Locker locker(isolate);
   v8::HandleScope handle_scope(isolate);
   v8::Context::Scope context_scope(
       v8::Local<v8::Context>::New(isolate, promise.GetContext()));

+ 1 - 1
shell/browser/renderer_host/electron_render_message_filter.cc

@@ -19,7 +19,7 @@
 #include "content/public/browser/browser_context.h"
 #include "shell/browser/api/atom_api_session.h"
 #include "shell/browser/atom_browser_context.h"
-#include "shell/common/native_mate_converters/gurl_converter.h"
+#include "shell/common/gin_converters/gurl_converter.h"
 
 using content::BrowserThread;
 

+ 12 - 13
shell/browser/ui/cocoa/atom_touch_bar.h

@@ -12,35 +12,34 @@
 #include <vector>
 
 #include "base/mac/scoped_nsobject.h"
-#include "native_mate/constructor.h"
-#include "native_mate/persistent_dictionary.h"
 #include "shell/browser/native_window.h"
+#include "shell/common/gin_helper/persistent_dictionary.h"
 
 @interface AtomTouchBar : NSObject <NSScrubberDelegate,
                                     NSScrubberDataSource,
                                     NSScrubberFlowLayoutDelegate> {
  @protected
-  std::vector<mate::PersistentDictionary> ordered_settings_;
-  std::map<std::string, mate::PersistentDictionary> settings_;
+  std::vector<gin_helper::PersistentDictionary> ordered_settings_;
+  std::map<std::string, gin_helper::PersistentDictionary> settings_;
   id<NSTouchBarDelegate> delegate_;
   electron::NativeWindow* window_;
 }
 
 - (id)initWithDelegate:(id<NSTouchBarDelegate>)delegate
                 window:(electron::NativeWindow*)window
-              settings:(const std::vector<mate::PersistentDictionary>&)settings;
+              settings:(std::vector<gin_helper::PersistentDictionary>)settings;
 
 - (NSTouchBar*)makeTouchBar API_AVAILABLE(macosx(10.12.2));
 - (NSTouchBar*)touchBarFromItemIdentifiers:(NSMutableArray*)items
     API_AVAILABLE(macosx(10.12.2));
 - (NSMutableArray*)identifiersFromSettings:
-    (const std::vector<mate::PersistentDictionary>&)settings;
+    (const std::vector<gin_helper::PersistentDictionary>&)settings;
 - (void)refreshTouchBarItem:(NSTouchBar*)touchBar
                          id:(const std::string&)item_id
     API_AVAILABLE(macosx(10.12.2));
 - (void)addNonDefaultTouchBarItems:
-    (const std::vector<mate::PersistentDictionary>&)items;
-- (void)setEscapeTouchBarItem:(const mate::PersistentDictionary&)item
+    (const std::vector<gin_helper::PersistentDictionary>&)items;
+- (void)setEscapeTouchBarItem:(gin_helper::PersistentDictionary)item
                   forTouchBar:(NSTouchBar*)touchBar
     API_AVAILABLE(macosx(10.12.2));
 
@@ -80,19 +79,19 @@
 
 // Helpers to update touch bar items
 - (void)updateButton:(NSCustomTouchBarItem*)item
-        withSettings:(const mate::PersistentDictionary&)settings
+        withSettings:(const gin_helper::PersistentDictionary&)settings
     API_AVAILABLE(macosx(10.12.2));
 - (void)updateLabel:(NSCustomTouchBarItem*)item
-       withSettings:(const mate::PersistentDictionary&)settings
+       withSettings:(const gin_helper::PersistentDictionary&)settings
     API_AVAILABLE(macosx(10.12.2));
 - (void)updateColorPicker:(NSColorPickerTouchBarItem*)item
-             withSettings:(const mate::PersistentDictionary&)settings
+             withSettings:(const gin_helper::PersistentDictionary&)settings
     API_AVAILABLE(macosx(10.12.2));
 - (void)updateSlider:(NSSliderTouchBarItem*)item
-        withSettings:(const mate::PersistentDictionary&)settings
+        withSettings:(const gin_helper::PersistentDictionary&)settings
     API_AVAILABLE(macosx(10.12.2));
 - (void)updatePopover:(NSPopoverTouchBarItem*)item
-         withSettings:(const mate::PersistentDictionary&)settings
+         withSettings:(const gin_helper::PersistentDictionary&)settings
     API_AVAILABLE(macosx(10.12.2));
 
 @end

+ 41 - 42
shell/browser/ui/cocoa/atom_touch_bar.mm

@@ -9,7 +9,7 @@
 
 #include "base/strings/sys_string_conversions.h"
 #include "shell/common/color_util.h"
-#include "shell/common/native_mate_converters/image_converter.h"
+#include "shell/common/gin_converters/image_converter.h"
 #include "skia/ext/skia_utils_mac.h"
 #include "ui/gfx/image/image.h"
 
@@ -37,12 +37,11 @@ static NSString* const ImageScrubberItemIdentifier = @"scrubber.image.item";
 
 - (id)initWithDelegate:(id<NSTouchBarDelegate>)delegate
                 window:(electron::NativeWindow*)window
-              settings:
-                  (const std::vector<mate::PersistentDictionary>&)settings {
+              settings:(std::vector<gin_helper::PersistentDictionary>)settings {
   if ((self = [super init])) {
     delegate_ = delegate;
     window_ = window;
-    ordered_settings_ = settings;
+    ordered_settings_ = std::move(settings);
   }
   return self;
 }
@@ -61,7 +60,7 @@ static NSString* const ImageScrubberItemIdentifier = @"scrubber.image.item";
 }
 
 - (NSMutableArray*)identifiersFromSettings:
-    (const std::vector<mate::PersistentDictionary>&)dicts {
+    (const std::vector<gin_helper::PersistentDictionary>&)dicts {
   NSMutableArray* identifiers = [NSMutableArray array];
 
   if (@available(macOS 10.12.2, *)) {
@@ -133,7 +132,7 @@ static NSString* const ImageScrubberItemIdentifier = @"scrubber.image.item";
 - (void)refreshTouchBarItem:(NSTouchBar*)touchBar
                          id:(NSTouchBarItemIdentifier)identifier
                    withType:(const std::string&)item_type
-               withSettings:(const mate::PersistentDictionary&)settings
+               withSettings:(const gin_helper::PersistentDictionary&)settings
     API_AVAILABLE(macosx(10.12.2)) {
   NSTouchBarItem* item = [touchBar itemForIdentifier:identifier];
   if (!item)
@@ -161,11 +160,11 @@ static NSString* const ImageScrubberItemIdentifier = @"scrubber.image.item";
 }
 
 - (void)addNonDefaultTouchBarItems:
-    (const std::vector<mate::PersistentDictionary>&)items {
+    (const std::vector<gin_helper::PersistentDictionary>&)items {
   [self identifiersFromSettings:items];
 }
 
-- (void)setEscapeTouchBarItem:(const mate::PersistentDictionary&)item
+- (void)setEscapeTouchBarItem:(gin_helper::PersistentDictionary)item
                   forTouchBar:(NSTouchBar*)touchBar {
   if (![touchBar
           respondsToSelector:@selector(escapeKeyReplacementItemIdentifier)])
@@ -177,7 +176,7 @@ static NSString* const ImageScrubberItemIdentifier = @"scrubber.image.item";
     identifier = [self identifierFromID:item_id type:type];
   }
   if (identifier) {
-    [self addNonDefaultTouchBarItems:{item}];
+    [self addNonDefaultTouchBarItems:{std::move(item)}];
     touchBar.escapeKeyReplacementItemIdentifier = identifier;
   } else {
     touchBar.escapeKeyReplacementItemIdentifier = nil;
@@ -189,7 +188,7 @@ static NSString* const ImageScrubberItemIdentifier = @"scrubber.image.item";
   if (![self hasItemWithID:item_id])
     return;
 
-  mate::PersistentDictionary settings = settings_[item_id];
+  gin_helper::PersistentDictionary settings = settings_[item_id];
   std::string item_type;
   settings.Get("type", &item_type);
 
@@ -197,7 +196,7 @@ static NSString* const ImageScrubberItemIdentifier = @"scrubber.image.item";
   if (!identifier)
     return;
 
-  std::vector<mate::Dictionary> parents;
+  std::vector<gin_helper::Dictionary> parents;
   settings.Get("_parents", &parents);
   for (auto& parent : parents) {
     std::string parent_type;
@@ -339,7 +338,7 @@ static NSString* const ImageScrubberItemIdentifier = @"scrubber.image.item";
   if (![self hasItemWithID:s_id])
     return nil;
 
-  mate::PersistentDictionary settings = settings_[s_id];
+  gin_helper::PersistentDictionary settings = settings_[s_id];
   base::scoped_nsobject<NSCustomTouchBarItem> item(
       [[NSCustomTouchBarItem alloc] initWithIdentifier:identifier]);
   NSButton* button = [NSButton buttonWithTitle:@""
@@ -352,7 +351,7 @@ static NSString* const ImageScrubberItemIdentifier = @"scrubber.image.item";
 }
 
 - (void)updateButton:(NSCustomTouchBarItem*)item
-        withSettings:(const mate::PersistentDictionary&)settings {
+        withSettings:(const gin_helper::PersistentDictionary&)settings {
   NSButton* button = (NSButton*)item.view;
 
   std::string backgroundColor;
@@ -393,7 +392,7 @@ static NSString* const ImageScrubberItemIdentifier = @"scrubber.image.item";
   if (![self hasItemWithID:s_id])
     return nil;
 
-  mate::PersistentDictionary settings = settings_[s_id];
+  gin_helper::PersistentDictionary settings = settings_[s_id];
   base::scoped_nsobject<NSCustomTouchBarItem> item(
       [[NSCustomTouchBarItem alloc] initWithIdentifier:identifier]);
   [item setView:[NSTextField labelWithString:@""]];
@@ -402,7 +401,7 @@ static NSString* const ImageScrubberItemIdentifier = @"scrubber.image.item";
 }
 
 - (void)updateLabel:(NSCustomTouchBarItem*)item
-       withSettings:(const mate::PersistentDictionary&)settings {
+       withSettings:(const gin_helper::PersistentDictionary&)settings {
   NSTextField* text_field = (NSTextField*)item.view;
 
   std::string label;
@@ -427,7 +426,7 @@ static NSString* const ImageScrubberItemIdentifier = @"scrubber.image.item";
   if (![self hasItemWithID:s_id])
     return nil;
 
-  mate::PersistentDictionary settings = settings_[s_id];
+  gin_helper::PersistentDictionary settings = settings_[s_id];
   base::scoped_nsobject<NSColorPickerTouchBarItem> item(
       [[NSColorPickerTouchBarItem alloc] initWithIdentifier:identifier]);
   [item setTarget:self];
@@ -437,7 +436,7 @@ static NSString* const ImageScrubberItemIdentifier = @"scrubber.image.item";
 }
 
 - (void)updateColorPicker:(NSColorPickerTouchBarItem*)item
-             withSettings:(const mate::PersistentDictionary&)settings {
+             withSettings:(const gin_helper::PersistentDictionary&)settings {
   std::vector<std::string> colors;
   if (settings.Get("availableColors", &colors) && !colors.empty()) {
     NSColorList* color_list =
@@ -462,7 +461,7 @@ static NSString* const ImageScrubberItemIdentifier = @"scrubber.image.item";
   if (![self hasItemWithID:s_id])
     return nil;
 
-  mate::PersistentDictionary settings = settings_[s_id];
+  gin_helper::PersistentDictionary settings = settings_[s_id];
   base::scoped_nsobject<NSSliderTouchBarItem> item(
       [[NSSliderTouchBarItem alloc] initWithIdentifier:identifier]);
   [item setTarget:self];
@@ -472,7 +471,7 @@ static NSString* const ImageScrubberItemIdentifier = @"scrubber.image.item";
 }
 
 - (void)updateSlider:(NSSliderTouchBarItem*)item
-        withSettings:(const mate::PersistentDictionary&)settings {
+        withSettings:(const gin_helper::PersistentDictionary&)settings {
   std::string label;
   settings.Get("label", &label);
   item.label = base::SysUTF8ToNSString(label);
@@ -495,7 +494,7 @@ static NSString* const ImageScrubberItemIdentifier = @"scrubber.image.item";
   if (![self hasItemWithID:s_id])
     return nil;
 
-  mate::PersistentDictionary settings = settings_[s_id];
+  gin_helper::PersistentDictionary settings = settings_[s_id];
   base::scoped_nsobject<NSPopoverTouchBarItem> item(
       [[NSPopoverTouchBarItem alloc] initWithIdentifier:identifier]);
   [self updatePopover:item withSettings:settings];
@@ -503,7 +502,7 @@ static NSString* const ImageScrubberItemIdentifier = @"scrubber.image.item";
 }
 
 - (void)updatePopover:(NSPopoverTouchBarItem*)item
-         withSettings:(const mate::PersistentDictionary&)settings {
+         withSettings:(const gin_helper::PersistentDictionary&)settings {
   std::string label;
   settings.Get("label", &label);
   item.collapsedRepresentationLabel = base::SysUTF8ToNSString(label);
@@ -517,8 +516,8 @@ static NSString* const ImageScrubberItemIdentifier = @"scrubber.image.item";
   settings.Get("showCloseButton", &showCloseButton);
   item.showsCloseButton = showCloseButton;
 
-  mate::PersistentDictionary child;
-  std::vector<mate::PersistentDictionary> items;
+  gin_helper::PersistentDictionary child;
+  std::vector<gin_helper::PersistentDictionary> items;
   if (settings.Get("child", &child) && child.Get("ordereredItems", &items)) {
     item.popoverTouchBar =
         [self touchBarFromItemIdentifiers:[self identifiersFromSettings:items]];
@@ -530,12 +529,12 @@ static NSString* const ImageScrubberItemIdentifier = @"scrubber.image.item";
   std::string s_id([id UTF8String]);
   if (![self hasItemWithID:s_id])
     return nil;
-  mate::PersistentDictionary settings = settings_[s_id];
+  gin_helper::PersistentDictionary settings = settings_[s_id];
 
-  mate::PersistentDictionary child;
+  gin_helper::PersistentDictionary child;
   if (!settings.Get("child", &child))
     return nil;
-  std::vector<mate::PersistentDictionary> items;
+  std::vector<gin_helper::PersistentDictionary> items;
   if (!child.Get("ordereredItems", &items))
     return nil;
 
@@ -556,12 +555,12 @@ static NSString* const ImageScrubberItemIdentifier = @"scrubber.image.item";
 }
 
 - (void)updateGroup:(NSGroupTouchBarItem*)item
-       withSettings:(const mate::PersistentDictionary&)settings
+       withSettings:(const gin_helper::PersistentDictionary&)settings
     API_AVAILABLE(macosx(10.12.2)) {
-  mate::PersistentDictionary child;
+  gin_helper::PersistentDictionary child;
   if (!settings.Get("child", &child))
     return;
-  std::vector<mate::PersistentDictionary> items;
+  std::vector<gin_helper::PersistentDictionary> items;
   if (!child.Get("ordereredItems", &items))
     return;
 
@@ -576,7 +575,7 @@ static NSString* const ImageScrubberItemIdentifier = @"scrubber.image.item";
   if (![self hasItemWithID:s_id])
     return nil;
 
-  mate::PersistentDictionary settings = settings_[s_id];
+  gin_helper::PersistentDictionary settings = settings_[s_id];
   base::scoped_nsobject<NSCustomTouchBarItem> item(
       [[NSCustomTouchBarItem alloc] initWithIdentifier:identifier]);
 
@@ -593,7 +592,7 @@ static NSString* const ImageScrubberItemIdentifier = @"scrubber.image.item";
 }
 
 - (void)updateSegmentedControl:(NSCustomTouchBarItem*)item
-                  withSettings:(const mate::PersistentDictionary&)settings
+                  withSettings:(const gin_helper::PersistentDictionary&)settings
     API_AVAILABLE(macosx(10.12.2)) {
   NSSegmentedControl* control = item.view;
 
@@ -625,7 +624,7 @@ static NSString* const ImageScrubberItemIdentifier = @"scrubber.image.item";
   else
     control.trackingMode = NSSegmentSwitchTrackingSelectOne;
 
-  std::vector<mate::Dictionary> segments;
+  std::vector<gin_helper::Dictionary> segments;
   settings.Get("segments", &segments);
 
   control.segmentCount = segments.size();
@@ -661,7 +660,7 @@ static NSString* const ImageScrubberItemIdentifier = @"scrubber.image.item";
   if (![self hasItemWithID:s_id])
     return nil;
 
-  mate::PersistentDictionary settings = settings_[s_id];
+  gin_helper::PersistentDictionary settings = settings_[s_id];
   base::scoped_nsobject<NSCustomTouchBarItem> item(
       [[NSCustomTouchBarItem alloc] initWithIdentifier:identifier]);
 
@@ -684,7 +683,7 @@ static NSString* const ImageScrubberItemIdentifier = @"scrubber.image.item";
 }
 
 - (void)updateScrubber:(NSCustomTouchBarItem*)item
-          withSettings:(const mate::PersistentDictionary&)settings
+          withSettings:(const gin_helper::PersistentDictionary&)settings
     API_AVAILABLE(macosx(10.12.2)) {
   NSScrubber* scrubber = item.view;
 
@@ -738,8 +737,8 @@ static NSString* const ImageScrubberItemIdentifier = @"scrubber.image.item";
   if (![self hasItemWithID:s_id])
     return 0;
 
-  mate::PersistentDictionary settings = settings_[s_id];
-  std::vector<mate::PersistentDictionary> items;
+  gin_helper::PersistentDictionary settings = settings_[s_id];
+  std::vector<gin_helper::PersistentDictionary> items;
   settings.Get("items", &items);
   return items.size();
 }
@@ -751,15 +750,15 @@ static NSString* const ImageScrubberItemIdentifier = @"scrubber.image.item";
   if (![self hasItemWithID:s_id])
     return nil;
 
-  mate::PersistentDictionary settings = settings_[s_id];
-  std::vector<mate::PersistentDictionary> items;
+  gin_helper::PersistentDictionary settings = settings_[s_id];
+  std::vector<gin_helper::PersistentDictionary> items;
   if (!settings.Get("items", &items))
     return nil;
 
   if (index >= static_cast<NSInteger>(items.size()))
     return nil;
 
-  mate::PersistentDictionary item = items[index];
+  gin_helper::PersistentDictionary item = items[index];
 
   NSScrubberItemView* itemView;
   std::string title;
@@ -795,15 +794,15 @@ static NSString* const ImageScrubberItemIdentifier = @"scrubber.image.item";
   if (![self hasItemWithID:s_id])
     return defaultSize;
 
-  mate::PersistentDictionary settings = settings_[s_id];
-  std::vector<mate::PersistentDictionary> items;
+  gin_helper::PersistentDictionary settings = settings_[s_id];
+  std::vector<gin_helper::PersistentDictionary> items;
   if (!settings.Get("items", &items))
     return defaultSize;
 
   if (itemIndex >= static_cast<NSInteger>(items.size()))
     return defaultSize;
 
-  mate::PersistentDictionary item = items[itemIndex];
+  gin_helper::PersistentDictionary item = items[itemIndex];
   std::string title;
 
   if (item.Get("label", &title)) {

+ 0 - 1
shell/browser/web_contents_permission_helper.cc

@@ -12,7 +12,6 @@
 #include "content/public/browser/render_process_host.h"
 #include "shell/browser/atom_permission_manager.h"
 #include "shell/browser/media/media_stream_devices_controller.h"
-#include "shell/common/native_mate_converters/gurl_converter.h"
 
 namespace {
 

+ 1 - 1
shell/browser/web_contents_preferences.cc

@@ -23,7 +23,7 @@
 #include "services/service_manager/sandbox/switches.h"
 #include "shell/browser/native_window.h"
 #include "shell/browser/web_view_manager.h"
-#include "shell/common/gin_converters/value_converter_gin_adapter.h"
+#include "shell/common/gin_converters/value_converter.h"
 #include "shell/common/gin_helper/dictionary.h"
 #include "shell/common/options_switches.h"
 

+ 0 - 1
shell/browser/web_view_guest_delegate.cc

@@ -14,7 +14,6 @@
 #include "content/public/browser/render_widget_host.h"
 #include "content/public/browser/render_widget_host_view.h"
 #include "shell/browser/api/atom_api_web_contents.h"
-#include "shell/common/native_mate_converters/gurl_converter.h"
 #include "third_party/blink/public/common/page/page_zoom.h"
 
 namespace electron {

+ 8 - 10
shell/common/api/atom_api_asar.cc

@@ -6,15 +6,13 @@
 
 #include <vector>
 
-#include "native_mate/arguments.h"
-#include "native_mate/dictionary.h"
-#include "native_mate/object_template_builder_deprecated.h"
 #include "native_mate/wrappable.h"
 #include "shell/common/asar/archive.h"
 #include "shell/common/asar/asar_util.h"
 #include "shell/common/gin_converters/callback_converter.h"
+#include "shell/common/gin_converters/file_path_converter.h"
 #include "shell/common/gin_helper/dictionary.h"
-#include "shell/common/native_mate_converters/file_path_converter.h"
+#include "shell/common/gin_helper/object_template_builder.h"
 #include "shell/common/node_includes.h"
 #include "shell/common/node_util.h"
 namespace {
@@ -31,8 +29,8 @@ class Archive : public mate::Wrappable<Archive> {
 
   static void BuildPrototype(v8::Isolate* isolate,
                              v8::Local<v8::FunctionTemplate> prototype) {
-    prototype->SetClassName(mate::StringToV8(isolate, "Archive"));
-    mate::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate())
+    prototype->SetClassName(gin::StringToV8(isolate, "Archive"));
+    gin_helper::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate())
         .SetProperty("path", &Archive::GetPath)
         .SetMethod("getFileInfo", &Archive::GetFileInfo)
         .SetMethod("stat", &Archive::Stat)
@@ -84,7 +82,7 @@ class Archive : public mate::Wrappable<Archive> {
     std::vector<base::FilePath> files;
     if (!archive_ || !archive_->Readdir(path, &files))
       return v8::False(isolate);
-    return mate::ConvertToV8(isolate, files);
+    return gin::ConvertToV8(isolate, files);
   }
 
   // Returns the path of file with symbol link resolved.
@@ -93,7 +91,7 @@ class Archive : public mate::Wrappable<Archive> {
     base::FilePath realpath;
     if (!archive_ || !archive_->Realpath(path, &realpath))
       return v8::False(isolate);
-    return mate::ConvertToV8(isolate, realpath);
+    return gin::ConvertToV8(isolate, realpath);
   }
 
   // Copy the file out into a temporary file and returns the new path.
@@ -102,7 +100,7 @@ class Archive : public mate::Wrappable<Archive> {
     base::FilePath new_path;
     if (!archive_ || !archive_->CopyFileOut(path, &new_path))
       return v8::False(isolate);
-    return mate::ConvertToV8(isolate, new_path);
+    return gin::ConvertToV8(isolate, new_path);
   }
 
   // Return the file descriptor.
@@ -130,7 +128,7 @@ void InitAsarSupport(v8::Isolate* isolate, v8::Local<v8::Value> require) {
 
 v8::Local<v8::Value> SplitPath(v8::Isolate* isolate,
                                const base::FilePath& path) {
-  mate::Dictionary dict = mate::Dictionary::CreateEmpty(isolate);
+  gin_helper::Dictionary dict = gin::Dictionary::CreateEmpty(isolate);
   base::FilePath asar_path, file_path;
   if (asar::GetAsarArchivePath(path, &asar_path, &file_path, true)) {
     dict.Set("isAsar", true);

+ 28 - 21
shell/common/api/atom_api_clipboard.cc

@@ -5,8 +5,8 @@
 #include "shell/common/api/atom_api_clipboard.h"
 
 #include "base/strings/utf_string_conversions.h"
-#include "shell/common/native_mate_converters/image_converter.h"
-#include "shell/common/native_mate_converters/string16_converter.h"
+#include "shell/common/gin_converters/image_converter.h"
+#include "shell/common/gin_helper/dictionary.h"
 #include "shell/common/node_includes.h"
 #include "third_party/skia/include/core/SkBitmap.h"
 #include "third_party/skia/include/core/SkImageInfo.h"
@@ -18,7 +18,7 @@ namespace electron {
 
 namespace api {
 
-ui::ClipboardBuffer Clipboard::GetClipboardBuffer(mate::Arguments* args) {
+ui::ClipboardBuffer Clipboard::GetClipboardBuffer(gin_helper::Arguments* args) {
   std::string type;
   if (args->GetNext(&type) && type == "selection")
     return ui::ClipboardBuffer::kSelection;
@@ -26,7 +26,8 @@ ui::ClipboardBuffer Clipboard::GetClipboardBuffer(mate::Arguments* args) {
     return ui::ClipboardBuffer::kCopyPaste;
 }
 
-std::vector<base::string16> Clipboard::AvailableFormats(mate::Arguments* args) {
+std::vector<base::string16> Clipboard::AvailableFormats(
+    gin_helper::Arguments* args) {
   std::vector<base::string16> format_types;
   bool ignore;
   ui::Clipboard* clipboard = ui::Clipboard::GetForCurrentThread();
@@ -35,7 +36,8 @@ std::vector<base::string16> Clipboard::AvailableFormats(mate::Arguments* args) {
   return format_types;
 }
 
-bool Clipboard::Has(const std::string& format_string, mate::Arguments* args) {
+bool Clipboard::Has(const std::string& format_string,
+                    gin_helper::Arguments* args) {
   ui::Clipboard* clipboard = ui::Clipboard::GetForCurrentThread();
   ui::ClipboardFormatType format(
       ui::ClipboardFormatType::GetType(format_string));
@@ -53,7 +55,7 @@ std::string Clipboard::Read(const std::string& format_string) {
 }
 
 v8::Local<v8::Value> Clipboard::ReadBuffer(const std::string& format_string,
-                                           mate::Arguments* args) {
+                                           gin_helper::Arguments* args) {
   std::string data = Read(format_string);
   return node::Buffer::Copy(args->isolate(), data.data(), data.length())
       .ToLocalChecked();
@@ -61,7 +63,7 @@ v8::Local<v8::Value> Clipboard::ReadBuffer(const std::string& format_string,
 
 void Clipboard::WriteBuffer(const std::string& format,
                             const v8::Local<v8::Value> buffer,
-                            mate::Arguments* args) {
+                            gin_helper::Arguments* args) {
   if (!node::Buffer::HasInstance(buffer)) {
     args->ThrowError("buffer must be a node Buffer");
     return;
@@ -76,7 +78,8 @@ void Clipboard::WriteBuffer(const std::string& format,
       mojo_base::BigBuffer(payload_span));
 }
 
-void Clipboard::Write(const mate::Dictionary& data, mate::Arguments* args) {
+void Clipboard::Write(const gin_helper::Dictionary& data,
+                      gin_helper::Arguments* args) {
   ui::ScopedClipboardWriter writer(GetClipboardBuffer(args));
   base::string16 text, html, bookmark;
   gfx::Image image;
@@ -100,7 +103,7 @@ void Clipboard::Write(const mate::Dictionary& data, mate::Arguments* args) {
     writer.WriteImage(image.AsBitmap());
 }
 
-base::string16 Clipboard::ReadText(mate::Arguments* args) {
+base::string16 Clipboard::ReadText(gin_helper::Arguments* args) {
   base::string16 data;
   ui::Clipboard* clipboard = ui::Clipboard::GetForCurrentThread();
   auto type = GetClipboardBuffer(args);
@@ -116,24 +119,25 @@ base::string16 Clipboard::ReadText(mate::Arguments* args) {
   return data;
 }
 
-void Clipboard::WriteText(const base::string16& text, mate::Arguments* args) {
+void Clipboard::WriteText(const base::string16& text,
+                          gin_helper::Arguments* args) {
   ui::ScopedClipboardWriter writer(GetClipboardBuffer(args));
   writer.WriteText(text);
 }
 
-base::string16 Clipboard::ReadRTF(mate::Arguments* args) {
+base::string16 Clipboard::ReadRTF(gin_helper::Arguments* args) {
   std::string data;
   ui::Clipboard* clipboard = ui::Clipboard::GetForCurrentThread();
   clipboard->ReadRTF(GetClipboardBuffer(args), &data);
   return base::UTF8ToUTF16(data);
 }
 
-void Clipboard::WriteRTF(const std::string& text, mate::Arguments* args) {
+void Clipboard::WriteRTF(const std::string& text, gin_helper::Arguments* args) {
   ui::ScopedClipboardWriter writer(GetClipboardBuffer(args));
   writer.WriteRTF(text);
 }
 
-base::string16 Clipboard::ReadHTML(mate::Arguments* args) {
+base::string16 Clipboard::ReadHTML(gin_helper::Arguments* args) {
   base::string16 data;
   base::string16 html;
   std::string url;
@@ -145,15 +149,17 @@ base::string16 Clipboard::ReadHTML(mate::Arguments* args) {
   return data;
 }
 
-void Clipboard::WriteHTML(const base::string16& html, mate::Arguments* args) {
+void Clipboard::WriteHTML(const base::string16& html,
+                          gin_helper::Arguments* args) {
   ui::ScopedClipboardWriter writer(GetClipboardBuffer(args));
   writer.WriteHTML(html, std::string());
 }
 
-v8::Local<v8::Value> Clipboard::ReadBookmark(mate::Arguments* args) {
+v8::Local<v8::Value> Clipboard::ReadBookmark(gin_helper::Arguments* args) {
   base::string16 title;
   std::string url;
-  mate::Dictionary dict = mate::Dictionary::CreateEmpty(args->isolate());
+  gin_helper::Dictionary dict =
+      gin_helper::Dictionary::CreateEmpty(args->isolate());
   ui::Clipboard* clipboard = ui::Clipboard::GetForCurrentThread();
   clipboard->ReadBookmark(&title, &url);
   dict.Set("title", title);
@@ -163,18 +169,19 @@ v8::Local<v8::Value> Clipboard::ReadBookmark(mate::Arguments* args) {
 
 void Clipboard::WriteBookmark(const base::string16& title,
                               const std::string& url,
-                              mate::Arguments* args) {
+                              gin_helper::Arguments* args) {
   ui::ScopedClipboardWriter writer(GetClipboardBuffer(args));
   writer.WriteBookmark(title, url);
 }
 
-gfx::Image Clipboard::ReadImage(mate::Arguments* args) {
+gfx::Image Clipboard::ReadImage(gin_helper::Arguments* args) {
   ui::Clipboard* clipboard = ui::Clipboard::GetForCurrentThread();
   SkBitmap bitmap = clipboard->ReadImage(GetClipboardBuffer(args));
   return gfx::Image::CreateFrom1xBitmap(bitmap);
 }
 
-void Clipboard::WriteImage(const gfx::Image& image, mate::Arguments* args) {
+void Clipboard::WriteImage(const gfx::Image& image,
+                           gin_helper::Arguments* args) {
   ui::ScopedClipboardWriter writer(GetClipboardBuffer(args));
   SkBitmap orig = image.AsBitmap();
   SkBitmap bmp;
@@ -192,7 +199,7 @@ base::string16 Clipboard::ReadFindText() {
 }
 #endif
 
-void Clipboard::Clear(mate::Arguments* args) {
+void Clipboard::Clear(gin_helper::Arguments* args) {
   ui::Clipboard::GetForCurrentThread()->Clear(GetClipboardBuffer(args));
 }
 
@@ -206,7 +213,7 @@ void Initialize(v8::Local<v8::Object> exports,
                 v8::Local<v8::Value> unused,
                 v8::Local<v8::Context> context,
                 void* priv) {
-  mate::Dictionary dict(context->GetIsolate(), exports);
+  gin_helper::Dictionary dict(context->GetIsolate(), exports);
   dict.SetMethod("availableFormats",
                  &electron::api::Clipboard::AvailableFormats);
   dict.SetMethod("has", &electron::api::Clipboard::Has);

+ 28 - 19
shell/common/api/atom_api_clipboard.h

@@ -8,10 +8,14 @@
 #include <string>
 #include <vector>
 
-#include "native_mate/arguments.h"
-#include "native_mate/dictionary.h"
 #include "ui/base/clipboard/clipboard.h"
 #include "ui/gfx/image/image.h"
+#include "v8/include/v8.h"
+
+namespace gin_helper {
+class Arguments;
+class Dictionary;
+}  // namespace gin_helper
 
 namespace electron {
 
@@ -19,39 +23,44 @@ namespace api {
 
 class Clipboard {
  public:
-  static ui::ClipboardBuffer GetClipboardBuffer(mate::Arguments* args);
-  static std::vector<base::string16> AvailableFormats(mate::Arguments* args);
-  static bool Has(const std::string& format_string, mate::Arguments* args);
-  static void Clear(mate::Arguments* args);
+  static ui::ClipboardBuffer GetClipboardBuffer(gin_helper::Arguments* args);
+  static std::vector<base::string16> AvailableFormats(
+      gin_helper::Arguments* args);
+  static bool Has(const std::string& format_string,
+                  gin_helper::Arguments* args);
+  static void Clear(gin_helper::Arguments* args);
 
   static std::string Read(const std::string& format_string);
-  static void Write(const mate::Dictionary& data, mate::Arguments* args);
+  static void Write(const gin_helper::Dictionary& data,
+                    gin_helper::Arguments* args);
 
-  static base::string16 ReadText(mate::Arguments* args);
-  static void WriteText(const base::string16& text, mate::Arguments* args);
+  static base::string16 ReadText(gin_helper::Arguments* args);
+  static void WriteText(const base::string16& text,
+                        gin_helper::Arguments* args);
 
-  static base::string16 ReadRTF(mate::Arguments* args);
-  static void WriteRTF(const std::string& text, mate::Arguments* args);
+  static base::string16 ReadRTF(gin_helper::Arguments* args);
+  static void WriteRTF(const std::string& text, gin_helper::Arguments* args);
 
-  static base::string16 ReadHTML(mate::Arguments* args);
-  static void WriteHTML(const base::string16& html, mate::Arguments* args);
+  static base::string16 ReadHTML(gin_helper::Arguments* args);
+  static void WriteHTML(const base::string16& html,
+                        gin_helper::Arguments* args);
 
-  static v8::Local<v8::Value> ReadBookmark(mate::Arguments* args);
+  static v8::Local<v8::Value> ReadBookmark(gin_helper::Arguments* args);
   static void WriteBookmark(const base::string16& title,
                             const std::string& url,
-                            mate::Arguments* args);
+                            gin_helper::Arguments* args);
 
-  static gfx::Image ReadImage(mate::Arguments* args);
-  static void WriteImage(const gfx::Image& image, mate::Arguments* args);
+  static gfx::Image ReadImage(gin_helper::Arguments* args);
+  static void WriteImage(const gfx::Image& image, gin_helper::Arguments* args);
 
   static base::string16 ReadFindText();
   static void WriteFindText(const base::string16& text);
 
   static v8::Local<v8::Value> ReadBuffer(const std::string& format_string,
-                                         mate::Arguments* args);
+                                         gin_helper::Arguments* args);
   static void WriteBuffer(const std::string& format_string,
                           const v8::Local<v8::Value> buffer,
-                          mate::Arguments* args);
+                          gin_helper::Arguments* args);
 
  private:
   DISALLOW_COPY_AND_ASSIGN(Clipboard);

+ 5 - 6
shell/common/api/atom_api_command_line.cc

@@ -5,11 +5,9 @@
 #include "base/command_line.h"
 #include "base/files/file_path.h"
 #include "base/strings/string_util.h"
-#include "native_mate/converter.h"
-#include "native_mate/dictionary.h"
 #include "services/network/public/cpp/network_switches.h"
-#include "shell/common/native_mate_converters/file_path_converter.h"
-#include "shell/common/native_mate_converters/string16_converter.h"
+#include "shell/common/gin_converters/file_path_converter.h"
+#include "shell/common/gin_helper/dictionary.h"
 #include "shell/common/node_includes.h"
 
 namespace {
@@ -23,7 +21,8 @@ base::CommandLine::StringType GetSwitchValue(const std::string& name) {
       name.c_str());
 }
 
-void AppendSwitch(const std::string& switch_string, mate::Arguments* args) {
+void AppendSwitch(const std::string& switch_string,
+                  gin_helper::Arguments* args) {
   auto* command_line = base::CommandLine::ForCurrentProcess();
 
   if (base::EndsWith(switch_string, "-path",
@@ -47,7 +46,7 @@ void Initialize(v8::Local<v8::Object> exports,
                 v8::Local<v8::Context> context,
                 void* priv) {
   auto* command_line = base::CommandLine::ForCurrentProcess();
-  mate::Dictionary dict(context->GetIsolate(), exports);
+  gin_helper::Dictionary dict(context->GetIsolate(), exports);
   dict.SetMethod("hasSwitch", &HasSwitch);
   dict.SetMethod("getSwitchValue", &GetSwitchValue);
   dict.SetMethod("appendSwitch", &AppendSwitch);

+ 1 - 1
shell/common/api/atom_api_native_image.cc

@@ -18,7 +18,7 @@
 #include "shell/common/gin_converters/file_path_converter.h"
 #include "shell/common/gin_converters/gfx_converter.h"
 #include "shell/common/gin_converters/gurl_converter.h"
-#include "shell/common/gin_converters/value_converter_gin_adapter.h"
+#include "shell/common/gin_converters/value_converter.h"
 #include "shell/common/gin_helper/dictionary.h"
 #include "shell/common/gin_helper/object_template_builder.h"
 #include "shell/common/node_includes.h"

+ 1 - 2
shell/common/api/atom_api_shell.cc

@@ -6,10 +6,9 @@
 
 #include "shell/common/gin_converters/callback_converter.h"
 #include "shell/common/gin_converters/file_path_converter.h"
+#include "shell/common/gin_converters/gurl_converter.h"
 #include "shell/common/gin_helper/dictionary.h"
 #include "shell/common/gin_helper/error_thrower.h"
-#include "shell/common/native_mate_converters/gurl_converter.h"
-#include "shell/common/native_mate_converters/string16_converter.h"
 #include "shell/common/node_includes.h"
 #include "shell/common/platform_util.h"
 #include "shell/common/promise_util.h"

+ 13 - 15
shell/common/api/electron_bindings.cc

@@ -18,16 +18,14 @@
 #include "base/threading/thread_restrictions.h"
 #include "chrome/common/chrome_version.h"
 #include "electron/electron_version.h"
-#include "native_mate/dictionary.h"
 #include "services/resource_coordinator/public/cpp/memory_instrumentation/global_memory_dump.h"
 #include "services/resource_coordinator/public/cpp/memory_instrumentation/memory_instrumentation.h"
 #include "shell/browser/browser.h"
-#include "shell/common/api/locker.h"
 #include "shell/common/application_info.h"
+#include "shell/common/gin_converters/file_path_converter.h"
 #include "shell/common/gin_helper/dictionary.h"
+#include "shell/common/gin_helper/locker.h"
 #include "shell/common/heap_snapshot.h"
-#include "shell/common/native_mate_converters/file_path_converter.h"
-#include "shell/common/native_mate_converters/string16_converter.h"
 #include "shell/common/node_includes.h"
 #include "shell/common/promise_util.h"
 #include "third_party/blink/renderer/platform/heap/process_heap.h"  // nogncheck
@@ -57,7 +55,7 @@ ElectronBindings::~ElectronBindings() {
 
 // static
 void ElectronBindings::BindProcess(v8::Isolate* isolate,
-                                   mate::Dictionary* process,
+                                   gin_helper::Dictionary* process,
                                    base::ProcessMetrics* metrics) {
   // These bindings are shared between sandboxed & unsandboxed renderers
   process->SetMethod("crash", &Crash);
@@ -89,7 +87,7 @@ void ElectronBindings::BindTo(v8::Isolate* isolate,
                               v8::Local<v8::Object> process) {
   isolate->SetFatalErrorHandler(FatalErrorCallback);
 
-  mate::Dictionary dict(isolate, process);
+  gin_helper::Dictionary dict(isolate, process);
   BindProcess(isolate, &dict, metrics_.get());
 
   dict.SetMethod("takeHeapSnapshot", &TakeHeapSnapshot);
@@ -100,7 +98,7 @@ void ElectronBindings::BindTo(v8::Isolate* isolate,
                  base::BindRepeating(&ElectronBindings::ActivateUVLoop,
                                      base::Unretained(this)));
 
-  mate::Dictionary versions;
+  gin_helper::Dictionary versions;
   if (dict.Get("versions", &versions)) {
     versions.SetReadOnly(ELECTRON_PROJECT_NAME, ELECTRON_VERSION_STRING);
     versions.SetReadOnly("chrome", CHROME_VERSION_STRING);
@@ -131,7 +129,7 @@ void ElectronBindings::OnCallNextTick(uv_async_t* handle) {
            self->pending_next_ticks_.begin();
        it != self->pending_next_ticks_.end(); ++it) {
     node::Environment* env = *it;
-    mate::Locker locker(env->isolate());
+    gin_helper::Locker locker(env->isolate());
     v8::Context::Scope context_scope(env->context());
     node::InternalCallbackScope scope(
         env, v8::Local<v8::Object>(), {0, 0},
@@ -201,7 +199,7 @@ v8::Local<v8::Value> ElectronBindings::GetCreationTime(v8::Isolate* isolate) {
 // static
 v8::Local<v8::Value> ElectronBindings::GetSystemMemoryInfo(
     v8::Isolate* isolate,
-    mate::Arguments* args) {
+    gin_helper::Arguments* args) {
   base::SystemMemoryInfoKB mem_info;
   if (!base::GetSystemMemoryInfo(&mem_info)) {
     args->ThrowError("Unable to retrieve system memory information");
@@ -233,10 +231,10 @@ v8::Local<v8::Value> ElectronBindings::GetSystemMemoryInfo(
 // static
 v8::Local<v8::Promise> ElectronBindings::GetProcessMemoryInfo(
     v8::Isolate* isolate) {
-  util::Promise<mate::Dictionary> promise(isolate);
+  util::Promise<gin_helper::Dictionary> promise(isolate);
   v8::Local<v8::Promise> handle = promise.GetHandle();
 
-  if (mate::Locker::IsBrowserProcess() && !Browser::Get()->is_ready()) {
+  if (gin_helper::Locker::IsBrowserProcess() && !Browser::Get()->is_ready()) {
     promise.RejectWithErrorMessage(
         "Memory Info is available only after app ready");
     return handle;
@@ -267,11 +265,11 @@ v8::Local<v8::Value> ElectronBindings::GetBlinkMemoryInfo(
 // static
 void ElectronBindings::DidReceiveMemoryDump(
     v8::Global<v8::Context> context,
-    util::Promise<mate::Dictionary> promise,
+    util::Promise<gin_helper::Dictionary> promise,
     bool success,
     std::unique_ptr<memory_instrumentation::GlobalMemoryDump> global_dump) {
   v8::Isolate* isolate = promise.isolate();
-  mate::Locker locker(isolate);
+  gin_helper::Locker locker(isolate);
   v8::HandleScope handle_scope(isolate);
   v8::MicrotasksScope script_scope(isolate,
                                    v8::MicrotasksScope::kRunMicrotasks);
@@ -287,14 +285,14 @@ void ElectronBindings::DidReceiveMemoryDump(
   for (const memory_instrumentation::GlobalMemoryDump::ProcessDump& dump :
        global_dump->process_dumps()) {
     if (base::GetCurrentProcId() == dump.pid()) {
-      mate::Dictionary dict = mate::Dictionary::CreateEmpty(isolate);
+      gin_helper::Dictionary dict = gin::Dictionary::CreateEmpty(isolate);
       const auto& osdump = dump.os_dump();
 #if defined(OS_LINUX) || defined(OS_WIN)
       dict.Set("residentSet", osdump.resident_set_kb);
 #endif
       dict.Set("private", osdump.private_footprint_kb);
       dict.Set("shared", osdump.shared_footprint_kb);
-      promise.Resolve(dict);
+      promise.ResolveWithGin(dict);
       resolved = true;
       break;
     }

+ 6 - 7
shell/common/api/electron_bindings.h

@@ -13,14 +13,13 @@
 #include "base/memory/scoped_refptr.h"
 #include "base/process/process_metrics.h"
 #include "base/strings/string16.h"
-#include "native_mate/arguments.h"
 #include "shell/common/promise_util.h"
 #include "uv.h"  // NOLINT(build/include)
-#include "v8/include/v8.h"
 
-namespace mate {
+namespace gin_helper {
+class Arguments;
 class Dictionary;
-}
+}  // namespace gin_helper
 
 namespace memory_instrumentation {
 class GlobalMemoryDump;
@@ -45,7 +44,7 @@ class ElectronBindings {
   void EnvironmentDestroyed(node::Environment* env);
 
   static void BindProcess(v8::Isolate* isolate,
-                          mate::Dictionary* process,
+                          gin_helper::Dictionary* process,
                           base::ProcessMetrics* metrics);
 
   static void Log(const base::string16& message);
@@ -56,7 +55,7 @@ class ElectronBindings {
   static v8::Local<v8::Value> GetHeapStatistics(v8::Isolate* isolate);
   static v8::Local<v8::Value> GetCreationTime(v8::Isolate* isolate);
   static v8::Local<v8::Value> GetSystemMemoryInfo(v8::Isolate* isolate,
-                                                  mate::Arguments* args);
+                                                  gin_helper::Arguments* args);
   static v8::Local<v8::Promise> GetProcessMemoryInfo(v8::Isolate* isolate);
   static v8::Local<v8::Value> GetBlinkMemoryInfo(v8::Isolate* isolate);
   static v8::Local<v8::Value> GetCPUUsage(base::ProcessMetrics* metrics,
@@ -71,7 +70,7 @@ class ElectronBindings {
 
   static void DidReceiveMemoryDump(
       v8::Global<v8::Context> context,
-      util::Promise<mate::Dictionary> promise,
+      util::Promise<gin_helper::Dictionary> promise,
       bool success,
       std::unique_ptr<memory_instrumentation::GlobalMemoryDump> dump);
 

+ 0 - 38
shell/common/api/event_emitter_caller_deprecated.cc

@@ -1,38 +0,0 @@
-// Copyright (c) 2015 GitHub, Inc.
-// Use of this source code is governed by the MIT license that can be
-// found in the LICENSE file.
-
-#include "shell/common/api/event_emitter_caller_deprecated.h"
-
-#include "shell/common/api/locker.h"
-#include "shell/common/node_includes.h"
-
-namespace mate {
-
-namespace internal {
-
-v8::Local<v8::Value> CallMethodWithArgs(v8::Isolate* isolate,
-                                        v8::Local<v8::Object> obj,
-                                        const char* method,
-                                        ValueVector* args) {
-  // Perform microtask checkpoint after running JavaScript.
-  v8::MicrotasksScope script_scope(isolate,
-                                   v8::MicrotasksScope::kRunMicrotasks);
-  // Use node::MakeCallback to call the callback, and it will also run pending
-  // tasks in Node.js.
-  v8::MaybeLocal<v8::Value> ret = node::MakeCallback(
-      isolate, obj, method, args->size(), &args->front(), {0, 0});
-  // If the JS function throws an exception (doesn't return a value) the result
-  // of MakeCallback will be empty and therefore ToLocal will be false, in this
-  // case we need to return "false" as that indicates that the event emitter did
-  // not handle the event
-  v8::Local<v8::Value> localRet;
-  if (ret.ToLocal(&localRet)) {
-    return localRet;
-  }
-  return v8::Boolean::New(isolate, false);
-}
-
-}  // namespace internal
-
-}  // namespace mate

+ 0 - 73
shell/common/api/event_emitter_caller_deprecated.h

@@ -1,73 +0,0 @@
-// Copyright (c) 2015 GitHub, Inc.
-// Use of this source code is governed by the MIT license that can be
-// found in the LICENSE file.
-
-#ifndef SHELL_COMMON_API_EVENT_EMITTER_CALLER_DEPRECATED_H_
-#define SHELL_COMMON_API_EVENT_EMITTER_CALLER_DEPRECATED_H_
-
-// =============================== NOTICE ===============================
-// Do not add code here, native_mate is being removed. Any new code
-// should use gin_helper version instead.
-
-#include <utility>
-#include <vector>
-
-#include "native_mate/converter.h"
-#include "shell/common/native_mate_converters/string16_converter.h"
-
-namespace mate {
-
-namespace internal {
-
-using ValueVector = std::vector<v8::Local<v8::Value>>;
-
-v8::Local<v8::Value> CallMethodWithArgs(v8::Isolate* isolate,
-                                        v8::Local<v8::Object> obj,
-                                        const char* method,
-                                        ValueVector* args);
-
-}  // namespace internal
-
-// obj.emit.apply(obj, name, args...);
-// The caller is responsible of allocating a HandleScope.
-template <typename StringType>
-v8::Local<v8::Value> EmitEvent(v8::Isolate* isolate,
-                               v8::Local<v8::Object> obj,
-                               const StringType& name,
-                               const internal::ValueVector& args) {
-  internal::ValueVector concatenated_args = {StringToV8(isolate, name)};
-  concatenated_args.reserve(1 + args.size());
-  concatenated_args.insert(concatenated_args.end(), args.begin(), args.end());
-  return internal::CallMethodWithArgs(isolate, obj, "emit", &concatenated_args);
-}
-
-// obj.emit(name, args...);
-// The caller is responsible of allocating a HandleScope.
-template <typename StringType, typename... Args>
-v8::Local<v8::Value> EmitEvent(v8::Isolate* isolate,
-                               v8::Local<v8::Object> obj,
-                               const StringType& name,
-                               Args&&... args) {
-  internal::ValueVector converted_args = {
-      StringToV8(isolate, name),
-      ConvertToV8(isolate, std::forward<Args>(args))...,
-  };
-  return internal::CallMethodWithArgs(isolate, obj, "emit", &converted_args);
-}
-
-// obj.custom_emit(args...)
-template <typename... Args>
-v8::Local<v8::Value> CustomEmit(v8::Isolate* isolate,
-                                v8::Local<v8::Object> object,
-                                const char* custom_emit,
-                                Args&&... args) {
-  internal::ValueVector converted_args = {
-      ConvertToV8(isolate, std::forward<Args>(args))...,
-  };
-  return internal::CallMethodWithArgs(isolate, object, custom_emit,
-                                      &converted_args);
-}
-
-}  // namespace mate
-
-#endif  // SHELL_COMMON_API_EVENT_EMITTER_CALLER_DEPRECATED_H_

+ 1 - 3
shell/common/api/remote/remote_object_freer.cc

@@ -7,10 +7,8 @@
 #include "base/strings/utf_string_conversions.h"
 #include "base/values.h"
 #include "content/public/renderer/render_frame.h"
-#include "electron/shell/common/api/api.mojom.h"
-#include "electron/shell/common/native_mate_converters/blink_converter.h"
-#include "electron/shell/common/native_mate_converters/value_converter.h"
 #include "services/service_manager/public/cpp/interface_provider.h"
+#include "shell/common/api/api.mojom.h"
 #include "third_party/blink/public/web/web_local_frame.h"
 
 using blink::WebLocalFrame;

+ 41 - 41
shell/common/native_mate_converters/blink_converter.cc → shell/common/gin_converters/blink_converter.cc

@@ -2,7 +2,7 @@
 // Use of this source code is governed by the MIT license that can be
 // found in the LICENSE file.
 
-#include "shell/common/native_mate_converters/blink_converter.h"
+#include "shell/common/gin_converters/blink_converter.h"
 
 #include <algorithm>
 #include <string>
@@ -14,10 +14,10 @@
 #include "gin/converter.h"
 #include "mojo/public/cpp/base/values_mojom_traits.h"
 #include "mojo/public/mojom/base/values.mojom.h"
-#include "native_mate/dictionary.h"
 #include "shell/common/deprecate_util.h"
+#include "shell/common/gin_converters/value_converter.h"
+#include "shell/common/gin_helper/dictionary.h"
 #include "shell/common/keyboard_util.h"
-#include "shell/common/native_mate_converters/value_converter.h"
 #include "third_party/blink/public/platform/web_input_event.h"
 #include "third_party/blink/public/platform/web_keyboard_event.h"
 #include "third_party/blink/public/platform/web_mouse_event.h"
@@ -39,7 +39,7 @@ int VectorToBitArray(const std::vector<T>& vec) {
 
 }  // namespace
 
-namespace mate {
+namespace gin {
 
 template <>
 struct Converter<base::char16> {
@@ -149,7 +149,7 @@ struct Converter<blink::WebInputEvent::Modifiers> {
 blink::WebInputEvent::Type GetWebInputEventType(v8::Isolate* isolate,
                                                 v8::Local<v8::Value> val) {
   blink::WebInputEvent::Type type = blink::WebInputEvent::kUndefined;
-  mate::Dictionary dict;
+  gin_helper::Dictionary dict;
   ConvertFromV8(isolate, val, &dict) && dict.Get("type", &type);
   return type;
 }
@@ -157,7 +157,7 @@ blink::WebInputEvent::Type GetWebInputEventType(v8::Isolate* isolate,
 bool Converter<blink::WebInputEvent>::FromV8(v8::Isolate* isolate,
                                              v8::Local<v8::Value> val,
                                              blink::WebInputEvent* out) {
-  mate::Dictionary dict;
+  gin_helper::Dictionary dict;
   if (!ConvertFromV8(isolate, val, &dict))
     return false;
   blink::WebInputEvent::Type type;
@@ -174,7 +174,7 @@ bool Converter<blink::WebInputEvent>::FromV8(v8::Isolate* isolate,
 bool Converter<blink::WebKeyboardEvent>::FromV8(v8::Isolate* isolate,
                                                 v8::Local<v8::Value> val,
                                                 blink::WebKeyboardEvent* out) {
-  mate::Dictionary dict;
+  gin_helper::Dictionary dict;
   if (!ConvertFromV8(isolate, val, &dict))
     return false;
   if (!ConvertFromV8(isolate, val, static_cast<blink::WebInputEvent*>(out)))
@@ -219,7 +219,7 @@ bool Converter<blink::WebKeyboardEvent>::FromV8(v8::Isolate* isolate,
 bool Converter<blink::WebMouseEvent>::FromV8(v8::Isolate* isolate,
                                              v8::Local<v8::Value> val,
                                              blink::WebMouseEvent* out) {
-  mate::Dictionary dict;
+  gin_helper::Dictionary dict;
   if (!ConvertFromV8(isolate, val, &dict))
     return false;
   if (!ConvertFromV8(isolate, val, static_cast<blink::WebInputEvent*>(out)))
@@ -250,7 +250,7 @@ bool Converter<blink::WebMouseWheelEvent>::FromV8(
     v8::Isolate* isolate,
     v8::Local<v8::Value> val,
     blink::WebMouseWheelEvent* out) {
-  mate::Dictionary dict;
+  gin_helper::Dictionary dict;
   if (!ConvertFromV8(isolate, val, &dict))
     return false;
   if (!ConvertFromV8(isolate, val, static_cast<blink::WebMouseEvent*>(out)))
@@ -285,7 +285,7 @@ bool Converter<blink::WebMouseWheelEvent>::FromV8(
 bool Converter<blink::WebFloatPoint>::FromV8(v8::Isolate* isolate,
                                              v8::Local<v8::Value> val,
                                              blink::WebFloatPoint* out) {
-  mate::Dictionary dict;
+  gin_helper::Dictionary dict;
   if (!ConvertFromV8(isolate, val, &dict))
     return false;
   return dict.Get("x", &out->x) && dict.Get("y", &out->y);
@@ -296,7 +296,7 @@ struct Converter<base::Optional<blink::WebPoint>> {
   static bool FromV8(v8::Isolate* isolate,
                      v8::Local<v8::Value> val,
                      base::Optional<blink::WebPoint>* out) {
-    mate::Dictionary dict;
+    gin_helper::Dictionary dict;
     if (!ConvertFromV8(isolate, val, &dict))
       return false;
     blink::WebPoint point;
@@ -311,7 +311,7 @@ struct Converter<base::Optional<blink::WebPoint>> {
 bool Converter<blink::WebSize>::FromV8(v8::Isolate* isolate,
                                        v8::Local<v8::Value> val,
                                        blink::WebSize* out) {
-  mate::Dictionary dict;
+  gin_helper::Dictionary dict;
   if (!ConvertFromV8(isolate, val, &dict))
     return false;
   return dict.Get("width", &out->width) && dict.Get("height", &out->height);
@@ -321,7 +321,7 @@ bool Converter<blink::WebDeviceEmulationParams>::FromV8(
     v8::Isolate* isolate,
     v8::Local<v8::Value> val,
     blink::WebDeviceEmulationParams* out) {
-  mate::Dictionary dict;
+  gin_helper::Dictionary dict;
   if (!ConvertFromV8(isolate, val, &dict))
     return false;
 
@@ -350,19 +350,19 @@ v8::Local<v8::Value> Converter<blink::WebContextMenuData::MediaType>::ToV8(
     const blink::WebContextMenuData::MediaType& in) {
   switch (in) {
     case blink::WebContextMenuData::kMediaTypeImage:
-      return mate::StringToV8(isolate, "image");
+      return StringToV8(isolate, "image");
     case blink::WebContextMenuData::kMediaTypeVideo:
-      return mate::StringToV8(isolate, "video");
+      return StringToV8(isolate, "video");
     case blink::WebContextMenuData::kMediaTypeAudio:
-      return mate::StringToV8(isolate, "audio");
+      return StringToV8(isolate, "audio");
     case blink::WebContextMenuData::kMediaTypeCanvas:
-      return mate::StringToV8(isolate, "canvas");
+      return StringToV8(isolate, "canvas");
     case blink::WebContextMenuData::kMediaTypeFile:
-      return mate::StringToV8(isolate, "file");
+      return StringToV8(isolate, "file");
     case blink::WebContextMenuData::kMediaTypePlugin:
-      return mate::StringToV8(isolate, "plugin");
+      return StringToV8(isolate, "plugin");
     default:
-      return mate::StringToV8(isolate, "none");
+      return StringToV8(isolate, "none");
   }
 }
 
@@ -372,18 +372,18 @@ v8::Local<v8::Value> Converter<blink::WebContextMenuData::InputFieldType>::ToV8(
     const blink::WebContextMenuData::InputFieldType& in) {
   switch (in) {
     case blink::WebContextMenuData::kInputFieldTypePlainText:
-      return mate::StringToV8(isolate, "plainText");
+      return StringToV8(isolate, "plainText");
     case blink::WebContextMenuData::kInputFieldTypePassword:
-      return mate::StringToV8(isolate, "password");
+      return StringToV8(isolate, "password");
     case blink::WebContextMenuData::kInputFieldTypeOther:
-      return mate::StringToV8(isolate, "other");
+      return StringToV8(isolate, "other");
     default:
-      return mate::StringToV8(isolate, "none");
+      return StringToV8(isolate, "none");
   }
 }
 
 v8::Local<v8::Value> EditFlagsToV8(v8::Isolate* isolate, int editFlags) {
-  mate::Dictionary dict = mate::Dictionary::CreateEmpty(isolate);
+  gin_helper::Dictionary dict = gin::Dictionary::CreateEmpty(isolate);
   dict.Set("canUndo", !!(editFlags & blink::WebContextMenuData::kCanUndo));
   dict.Set("canRedo", !!(editFlags & blink::WebContextMenuData::kCanRedo));
   dict.Set("canCut", !!(editFlags & blink::WebContextMenuData::kCanCut));
@@ -403,11 +403,11 @@ v8::Local<v8::Value> EditFlagsToV8(v8::Isolate* isolate, int editFlags) {
   dict.Set("canSelectAll",
            !!(editFlags & blink::WebContextMenuData::kCanSelectAll));
 
-  return mate::ConvertToV8(isolate, dict);
+  return ConvertToV8(isolate, dict);
 }
 
 v8::Local<v8::Value> MediaFlagsToV8(v8::Isolate* isolate, int mediaFlags) {
-  mate::Dictionary dict = mate::Dictionary::CreateEmpty(isolate);
+  gin_helper::Dictionary dict = gin::Dictionary::CreateEmpty(isolate);
   dict.Set("inError",
            !!(mediaFlags & blink::WebContextMenuData::kMediaInError));
   dict.Set("isPaused",
@@ -423,13 +423,13 @@ v8::Local<v8::Value> MediaFlagsToV8(v8::Isolate* isolate, int mediaFlags) {
            !!(mediaFlags & blink::WebContextMenuData::kMediaCanToggleControls));
   dict.Set("canRotate",
            !!(mediaFlags & blink::WebContextMenuData::kMediaCanRotate));
-  return mate::ConvertToV8(isolate, dict);
+  return ConvertToV8(isolate, dict);
 }
 
 v8::Local<v8::Value> Converter<blink::WebCacheResourceTypeStat>::ToV8(
     v8::Isolate* isolate,
     const blink::WebCacheResourceTypeStat& stat) {
-  mate::Dictionary dict = mate::Dictionary::CreateEmpty(isolate);
+  gin_helper::Dictionary dict = gin::Dictionary::CreateEmpty(isolate);
   dict.Set("count", static_cast<uint32_t>(stat.count));
   dict.Set("size", static_cast<double>(stat.size));
   dict.Set("liveSize", static_cast<double>(stat.decoded_size));
@@ -439,7 +439,7 @@ v8::Local<v8::Value> Converter<blink::WebCacheResourceTypeStat>::ToV8(
 v8::Local<v8::Value> Converter<blink::WebCacheResourceTypeStats>::ToV8(
     v8::Isolate* isolate,
     const blink::WebCacheResourceTypeStats& stats) {
-  mate::Dictionary dict = mate::Dictionary::CreateEmpty(isolate);
+  gin_helper::Dictionary dict = gin::Dictionary::CreateEmpty(isolate);
   dict.Set("images", stats.images);
   dict.Set("scripts", stats.scripts);
   dict.Set("cssStyleSheets", stats.css_style_sheets);
@@ -455,24 +455,24 @@ v8::Local<v8::Value> Converter<network::mojom::ReferrerPolicy>::ToV8(
     const network::mojom::ReferrerPolicy& in) {
   switch (in) {
     case network::mojom::ReferrerPolicy::kDefault:
-      return mate::StringToV8(isolate, "default");
+      return StringToV8(isolate, "default");
     case network::mojom::ReferrerPolicy::kAlways:
-      return mate::StringToV8(isolate, "unsafe-url");
+      return StringToV8(isolate, "unsafe-url");
     case network::mojom::ReferrerPolicy::kNoReferrerWhenDowngrade:
-      return mate::StringToV8(isolate, "no-referrer-when-downgrade");
+      return StringToV8(isolate, "no-referrer-when-downgrade");
     case network::mojom::ReferrerPolicy::kNever:
-      return mate::StringToV8(isolate, "no-referrer");
+      return StringToV8(isolate, "no-referrer");
     case network::mojom::ReferrerPolicy::kOrigin:
-      return mate::StringToV8(isolate, "origin");
+      return StringToV8(isolate, "origin");
     case network::mojom::ReferrerPolicy::
         kNoReferrerWhenDowngradeOriginWhenCrossOrigin:
-      return mate::StringToV8(isolate, "strict-origin-when-cross-origin");
+      return StringToV8(isolate, "strict-origin-when-cross-origin");
     case network::mojom::ReferrerPolicy::kSameOrigin:
-      return mate::StringToV8(isolate, "same-origin");
+      return StringToV8(isolate, "same-origin");
     case network::mojom::ReferrerPolicy::kStrictOrigin:
-      return mate::StringToV8(isolate, "strict-origin");
+      return StringToV8(isolate, "strict-origin");
     default:
-      return mate::StringToV8(isolate, "no-referrer");
+      return StringToV8(isolate, "no-referrer");
   }
 }
 
@@ -523,7 +523,7 @@ class V8Serializer : public v8::ValueSerializer::Delegate {
       WriteTag(kOldSerializationTag);
       if (!WriteBaseValue(value)) {
         isolate_->ThrowException(
-            mate::StringToV8(isolate_, "An object could not be cloned."));
+            StringToV8(isolate_, "An object could not be cloned."));
         return false;
       }
     } else {
@@ -684,4 +684,4 @@ bool Converter<blink::CloneableMessage>::FromV8(v8::Isolate* isolate,
   return V8Serializer(isolate).Serialize(val, out);
 }
 
-}  // namespace mate
+}  // namespace gin

+ 6 - 6
shell/common/native_mate_converters/blink_converter.h → shell/common/gin_converters/blink_converter.h

@@ -2,10 +2,10 @@
 // Use of this source code is governed by the MIT license that can be
 // found in the LICENSE file.
 
-#ifndef SHELL_COMMON_NATIVE_MATE_CONVERTERS_BLINK_CONVERTER_H_
-#define SHELL_COMMON_NATIVE_MATE_CONVERTERS_BLINK_CONVERTER_H_
+#ifndef SHELL_COMMON_GIN_CONVERTERS_BLINK_CONVERTER_H_
+#define SHELL_COMMON_GIN_CONVERTERS_BLINK_CONVERTER_H_
 
-#include "native_mate/converter.h"
+#include "gin/converter.h"
 #include "third_party/blink/public/common/messaging/cloneable_message.h"
 #include "third_party/blink/public/common/web_cache/web_cache_resource_type_stats.h"
 #include "third_party/blink/public/platform/web_input_event.h"
@@ -21,7 +21,7 @@ struct WebPoint;
 struct WebSize;
 }  // namespace blink
 
-namespace mate {
+namespace gin {
 
 blink::WebInputEvent::Type GetWebInputEventType(v8::Isolate* isolate,
                                                 v8::Local<v8::Value> val);
@@ -130,6 +130,6 @@ struct Converter<blink::CloneableMessage> {
 v8::Local<v8::Value> EditFlagsToV8(v8::Isolate* isolate, int editFlags);
 v8::Local<v8::Value> MediaFlagsToV8(v8::Isolate* isolate, int mediaFlags);
 
-}  // namespace mate
+}  // namespace gin
 
-#endif  // SHELL_COMMON_NATIVE_MATE_CONVERTERS_BLINK_CONVERTER_H_
+#endif  // SHELL_COMMON_GIN_CONVERTERS_BLINK_CONVERTER_H_

+ 0 - 79
shell/common/gin_converters/blink_converter_gin_adapter.h

@@ -1,79 +0,0 @@
-// Copyright (c) 2019 GitHub, Inc.
-// Use of this source code is governed by the MIT license that can be
-// found in the LICENSE file.
-
-#ifndef SHELL_COMMON_GIN_CONVERTERS_BLINK_CONVERTER_GIN_ADAPTER_H_
-#define SHELL_COMMON_GIN_CONVERTERS_BLINK_CONVERTER_GIN_ADAPTER_H_
-
-#include "gin/converter.h"
-#include "shell/common/native_mate_converters/blink_converter.h"
-
-// TODO(zcbenz): Move the implementations from native_mate_converters to here.
-
-namespace gin {
-
-template <>
-struct Converter<blink::WebKeyboardEvent> {
-  static bool FromV8(v8::Isolate* isolate,
-                     v8::Local<v8::Value> val,
-                     blink::WebKeyboardEvent* out) {
-    return mate::ConvertFromV8(isolate, val, out);
-  }
-};
-
-template <>
-struct Converter<blink::CloneableMessage> {
-  static bool FromV8(v8::Isolate* isolate,
-                     v8::Local<v8::Value> val,
-                     blink::CloneableMessage* out) {
-    return mate::ConvertFromV8(isolate, val, out);
-  }
-  static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
-                                   const blink::CloneableMessage& val) {
-    return mate::ConvertToV8(isolate, val);
-  }
-};
-
-template <>
-struct Converter<blink::WebDeviceEmulationParams> {
-  static bool FromV8(v8::Isolate* isolate,
-                     v8::Local<v8::Value> val,
-                     blink::WebDeviceEmulationParams* out) {
-    return mate::ConvertFromV8(isolate, val, out);
-  }
-};
-
-template <>
-struct Converter<blink::WebContextMenuData::MediaType> {
-  static v8::Local<v8::Value> ToV8(
-      v8::Isolate* isolate,
-      const blink::WebContextMenuData::MediaType& in) {
-    return mate::ConvertToV8(isolate, in);
-  }
-};
-
-template <>
-struct Converter<blink::WebContextMenuData::InputFieldType> {
-  static v8::Local<v8::Value> ToV8(
-      v8::Isolate* isolate,
-      const blink::WebContextMenuData::InputFieldType& in) {
-    return mate::ConvertToV8(isolate, in);
-  }
-};
-
-template <>
-struct Converter<network::mojom::ReferrerPolicy> {
-  static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
-                                   const network::mojom::ReferrerPolicy& in) {
-    return mate::ConvertToV8(isolate, in);
-  }
-  static bool FromV8(v8::Isolate* isolate,
-                     v8::Local<v8::Value> val,
-                     network::mojom::ReferrerPolicy* out) {
-    return mate::ConvertFromV8(isolate, val, out);
-  }
-};
-
-}  // namespace gin
-
-#endif  // SHELL_COMMON_GIN_CONVERTERS_BLINK_CONVERTER_GIN_ADAPTER_H_

+ 3 - 3
shell/common/gin_converters/content_converter.cc

@@ -12,7 +12,7 @@
 #include "content/public/common/context_menu_params.h"
 #include "shell/browser/api/atom_api_web_contents.h"
 #include "shell/browser/web_contents_permission_helper.h"
-#include "shell/common/gin_converters/blink_converter_gin_adapter.h"
+#include "shell/common/gin_converters/blink_converter.h"
 #include "shell/common/gin_converters/callback_converter.h"
 #include "shell/common/gin_converters/gurl_converter.h"
 #include "shell/common/gin_helper/dictionary.h"
@@ -128,13 +128,13 @@ v8::Local<v8::Value> Converter<ContextMenuParamsWithWebContents>::ToV8(
   dict.Set("frameURL", params.frame_url);
   dict.Set("srcURL", params.src_url);
   dict.Set("mediaType", params.media_type);
-  dict.Set("mediaFlags", mate::MediaFlagsToV8(isolate, params.media_flags));
+  dict.Set("mediaFlags", MediaFlagsToV8(isolate, params.media_flags));
   bool has_image_contents =
       (params.media_type == blink::WebContextMenuData::kMediaTypeImage) &&
       params.has_image_contents;
   dict.Set("hasImageContents", has_image_contents);
   dict.Set("isEditable", params.is_editable);
-  dict.Set("editFlags", mate::EditFlagsToV8(isolate, params.edit_flags));
+  dict.Set("editFlags", EditFlagsToV8(isolate, params.edit_flags));
   dict.Set("selectionText", params.selection_text);
   dict.Set("titleText", params.title_text);
   dict.Set("misspelledWord", params.misspelled_word);

+ 1 - 0
shell/common/gin_converters/file_path_converter.h

@@ -9,6 +9,7 @@
 #include "gin/converter.h"
 
 namespace gin {
+
 template <>
 struct Converter<base::FilePath> {
   static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,

+ 1 - 59
shell/common/gin_converters/net_converter.cc

@@ -14,10 +14,6 @@
 #include "base/values.h"
 #include "gin/converter.h"
 #include "gin/dictionary.h"
-#include "net/base/upload_bytes_element_reader.h"
-#include "net/base/upload_data_stream.h"
-#include "net/base/upload_element_reader.h"
-#include "net/base/upload_file_element_reader.h"
 #include "net/cert/x509_certificate.h"
 #include "net/cert/x509_util.h"
 #include "net/http/http_response_headers.h"
@@ -25,7 +21,7 @@
 #include "shell/browser/api/atom_api_data_pipe_holder.h"
 #include "shell/common/gin_converters/gurl_converter.h"
 #include "shell/common/gin_converters/std_converter.h"
-#include "shell/common/gin_converters/value_converter_gin_adapter.h"
+#include "shell/common/gin_converters/value_converter.h"
 #include "shell/common/node_includes.h"
 
 namespace gin {
@@ -364,57 +360,3 @@ v8::Local<v8::Value> Converter<electron::VerifyRequestParams>::ToV8(
 }
 
 }  // namespace gin
-
-namespace electron {
-
-void FillRequestDetails(base::DictionaryValue* details,
-                        const net::URLRequest* request) {
-  details->SetString("method", request->method());
-  std::string url;
-  if (!request->url_chain().empty())
-    url = request->url().spec();
-  details->SetKey("url", base::Value(url));
-  details->SetString("referrer", request->referrer());
-  auto list = std::make_unique<base::ListValue>();
-  GetUploadData(list.get(), request);
-  if (!list->empty())
-    details->Set("uploadData", std::move(list));
-  auto headers_value = std::make_unique<base::DictionaryValue>();
-  for (net::HttpRequestHeaders::Iterator it(request->extra_request_headers());
-       it.GetNext();) {
-    headers_value->SetString(it.name(), it.value());
-  }
-  details->Set("headers", std::move(headers_value));
-}
-
-void GetUploadData(base::ListValue* upload_data_list,
-                   const net::URLRequest* request) {
-  const net::UploadDataStream* upload_data = request->get_upload_for_testing();
-  if (!upload_data)
-    return;
-  const std::vector<std::unique_ptr<net::UploadElementReader>>* readers =
-      upload_data->GetElementReaders();
-  for (const auto& reader : *readers) {
-    auto upload_data_dict = std::make_unique<base::DictionaryValue>();
-    if (reader->AsBytesReader()) {
-      const net::UploadBytesElementReader* bytes_reader =
-          reader->AsBytesReader();
-      auto bytes = std::make_unique<base::Value>(
-          std::vector<char>(bytes_reader->bytes(),
-                            bytes_reader->bytes() + bytes_reader->length()));
-      upload_data_dict->Set("bytes", std::move(bytes));
-    } else if (reader->AsFileReader()) {
-      const net::UploadFileElementReader* file_reader = reader->AsFileReader();
-      auto file_path = file_reader->path().AsUTF8Unsafe();
-      upload_data_dict->SetKey("file", base::Value(file_path));
-    }
-    // else {
-    //   const storage::UploadBlobElementReader* blob_reader =
-    //       static_cast<storage::UploadBlobElementReader*>(reader.get());
-    //   upload_data_dict->SetString("blobUUID", blob_reader->uuid());
-    // }
-    upload_data_list->Append(std::move(upload_data_dict));
-  }
-}
-
-}  // namespace electron

+ 0 - 11
shell/common/gin_converters/net_converter.h

@@ -5,7 +5,6 @@
 #ifndef SHELL_COMMON_GIN_CONVERTERS_NET_CONVERTER_H_
 #define SHELL_COMMON_GIN_CONVERTERS_NET_CONVERTER_H_
 
-#include "base/memory/ref_counted.h"
 #include "gin/converter.h"
 #include "shell/browser/net/cert_verifier_client.h"
 
@@ -99,14 +98,4 @@ struct Converter<electron::VerifyRequestParams> {
 
 }  // namespace gin
 
-namespace electron {
-
-void FillRequestDetails(base::DictionaryValue* details,
-                        const net::URLRequest* request);
-
-void GetUploadData(base::ListValue* upload_data_list,
-                   const net::URLRequest* request);
-
-}  // namespace electron
-
 #endif  // SHELL_COMMON_GIN_CONVERTERS_NET_CONVERTER_H_

+ 4 - 4
shell/common/native_mate_converters/value_converter.cc → shell/common/gin_converters/value_converter.cc

@@ -2,15 +2,15 @@
 // Use of this source code is governed by the MIT license that can be
 // found in the LICENSE file.
 
-#include "shell/common/native_mate_converters/value_converter.h"
+#include "shell/common/gin_converters/value_converter.h"
 
 #include <memory>
 #include <utility>
 
 #include "base/values.h"
-#include "shell/common/native_mate_converters/v8_value_converter.h"
+#include "shell/common/v8_value_converter.h"
 
-namespace mate {
+namespace gin {
 
 bool Converter<base::DictionaryValue>::FromV8(v8::Isolate* isolate,
                                               v8::Local<v8::Value> val,
@@ -74,4 +74,4 @@ v8::Local<v8::Value> Converter<base::ListValue>::ToV8(
   return converter.ToV8Value(&val, isolate->GetCurrentContext());
 }
 
-}  // namespace mate
+}  // namespace gin

+ 6 - 31
shell/common/native_mate_converters/value_converter.h → shell/common/gin_converters/value_converter.h

@@ -2,12 +2,10 @@
 // Use of this source code is governed by the MIT license that can be
 // found in the LICENSE file.
 
-#ifndef SHELL_COMMON_NATIVE_MATE_CONVERTERS_VALUE_CONVERTER_H_
-#define SHELL_COMMON_NATIVE_MATE_CONVERTERS_VALUE_CONVERTER_H_
+#ifndef SHELL_COMMON_GIN_CONVERTERS_VALUE_CONVERTER_H_
+#define SHELL_COMMON_GIN_CONVERTERS_VALUE_CONVERTER_H_
 
-#include "native_mate/converter.h"
-
-#include "base/optional.h"
+#include "gin/converter.h"
 
 namespace base {
 class DictionaryValue;
@@ -15,7 +13,7 @@ class ListValue;
 class Value;
 }  // namespace base
 
-namespace mate {
+namespace gin {
 
 template <>
 struct Converter<base::DictionaryValue> {
@@ -35,29 +33,6 @@ struct Converter<base::Value> {
                                    const base::Value& val);
 };
 
-template <typename T>
-struct Converter<base::Optional<T>> {
-  static bool FromV8(v8::Isolate* isolate,
-                     v8::Local<v8::Value> val,
-                     base::Optional<T>* out) {
-    if (val->IsNull() || val->IsUndefined()) {
-      return true;
-    }
-    T converted;
-    if (Converter<T>::FromV8(isolate, val, &converted)) {
-      return true;
-    }
-    out->emplace(converted);
-    return true;
-  }
-  static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
-                                   const base::Optional<T>& val) {
-    if (val.has_value())
-      return Converter<T>::ToV8(val.value());
-    return v8::Undefined(isolate);
-  }
-};
-
 template <>
 struct Converter<base::ListValue> {
   static bool FromV8(v8::Isolate* isolate,
@@ -67,6 +42,6 @@ struct Converter<base::ListValue> {
                                    const base::ListValue& val);
 };
 
-}  // namespace mate
+}  // namespace gin
 
-#endif  // SHELL_COMMON_NATIVE_MATE_CONVERTERS_VALUE_CONVERTER_H_
+#endif  // SHELL_COMMON_GIN_CONVERTERS_VALUE_CONVERTER_H_

+ 0 - 56
shell/common/gin_converters/value_converter_gin_adapter.h

@@ -1,56 +0,0 @@
-// Copyright (c) 2019 GitHub, Inc.
-// Use of this source code is governed by the MIT license that can be
-// found in the LICENSE file.
-
-#ifndef SHELL_COMMON_GIN_CONVERTERS_VALUE_CONVERTER_GIN_ADAPTER_H_
-#define SHELL_COMMON_GIN_CONVERTERS_VALUE_CONVERTER_GIN_ADAPTER_H_
-
-#include "gin/converter.h"
-#include "shell/common/native_mate_converters/value_converter.h"
-
-// TODO(zcbenz): Move the implementations from native_mate_converters to here.
-
-namespace gin {
-
-template <>
-struct Converter<base::DictionaryValue> {
-  static bool FromV8(v8::Isolate* isolate,
-                     v8::Local<v8::Value> val,
-                     base::DictionaryValue* out) {
-    return mate::ConvertFromV8(isolate, val, out);
-  }
-  static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
-                                   const base::DictionaryValue& val) {
-    return mate::ConvertToV8(isolate, val);
-  }
-};
-
-template <>
-struct Converter<base::ListValue> {
-  static bool FromV8(v8::Isolate* isolate,
-                     v8::Local<v8::Value> val,
-                     base::ListValue* out) {
-    return mate::ConvertFromV8(isolate, val, out);
-  }
-  static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
-                                   const base::ListValue& val) {
-    return mate::ConvertToV8(isolate, val);
-  }
-};
-
-template <>
-struct Converter<base::Value> {
-  static bool FromV8(v8::Isolate* isolate,
-                     v8::Local<v8::Value> val,
-                     base::Value* out) {
-    return mate::ConvertFromV8(isolate, val, out);
-  }
-  static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
-                                   const base::Value& in) {
-    return mate::ConvertToV8(isolate, in);
-  }
-};
-
-}  // namespace gin
-
-#endif  // SHELL_COMMON_GIN_CONVERTERS_VALUE_CONVERTER_GIN_ADAPTER_H_

+ 1 - 1
shell/common/gin_helper/callback.cc

@@ -69,7 +69,7 @@ void CallTranslater(v8::Local<v8::External> external,
 struct DeleteOnUIThread {
   template <typename T>
   static void Destruct(const T* x) {
-    if (mate::Locker::IsBrowserProcess() &&
+    if (gin_helper::Locker::IsBrowserProcess() &&
         !content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)) {
       content::BrowserThread::DeleteSoon(content::BrowserThread::UI, FROM_HERE,
                                          x);

+ 4 - 4
shell/common/gin_helper/callback.h

@@ -9,9 +9,9 @@
 #include <vector>
 
 #include "base/bind.h"
-#include "shell/common/api/locker.h"
 #include "shell/common/gin_converters/std_converter.h"
 #include "shell/common/gin_helper/function_template.h"
+#include "shell/common/gin_helper/locker.h"
 
 // Implements safe convertions between JS functions and base::Callback.
 
@@ -43,7 +43,7 @@ struct V8FunctionInvoker<v8::Local<v8::Value>(ArgTypes...)> {
   static v8::Local<v8::Value> Go(v8::Isolate* isolate,
                                  const SafeV8Function& function,
                                  ArgTypes... raw) {
-    mate::Locker locker(isolate);
+    gin_helper::Locker locker(isolate);
     v8::EscapableHandleScope handle_scope(isolate);
     if (!function.IsAlive())
       return v8::Null(isolate);
@@ -68,7 +68,7 @@ struct V8FunctionInvoker<void(ArgTypes...)> {
   static void Go(v8::Isolate* isolate,
                  const SafeV8Function& function,
                  ArgTypes... raw) {
-    mate::Locker locker(isolate);
+    gin_helper::Locker locker(isolate);
     v8::HandleScope handle_scope(isolate);
     if (!function.IsAlive())
       return;
@@ -91,7 +91,7 @@ struct V8FunctionInvoker<ReturnType(ArgTypes...)> {
   static ReturnType Go(v8::Isolate* isolate,
                        const SafeV8Function& function,
                        ArgTypes... raw) {
-    mate::Locker locker(isolate);
+    gin_helper::Locker locker(isolate);
     v8::HandleScope handle_scope(isolate);
     ReturnType ret = ReturnType();
     if (!function.IsAlive())

+ 20 - 0
shell/common/gin_helper/dictionary.h

@@ -108,6 +108,26 @@ class Dictionary : public gin::Dictionary {
     return !result.IsNothing() && result.FromJust();
   }
 
+  // Note: If we plan to add more Set methods, consider adding an option instead
+  // of copying code.
+  template <typename T>
+  bool SetReadOnlyNonConfigurable(base::StringPiece key, T val) {
+    v8::Local<v8::Value> v8_value;
+    if (!gin::TryConvertToV8(isolate(), val, &v8_value))
+      return false;
+    v8::Maybe<bool> result = GetHandle()->DefineOwnProperty(
+        isolate()->GetCurrentContext(), gin::StringToV8(isolate(), key),
+        v8_value,
+        static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontDelete));
+    return !result.IsNothing() && result.FromJust();
+  }
+
+  bool Has(base::StringPiece key) const {
+    v8::Maybe<bool> result = GetHandle()->Has(isolate()->GetCurrentContext(),
+                                              gin::StringToV8(isolate(), key));
+    return !result.IsNothing() && result.FromJust();
+  }
+
   bool Delete(base::StringPiece key) {
     v8::Maybe<bool> result = GetHandle()->Delete(
         isolate()->GetCurrentContext(), gin::StringToV8(isolate(), key));

+ 2 - 3
shell/common/gin_helper/event_emitter.cc

@@ -68,11 +68,10 @@ v8::Local<v8::Object> CreateNativeEvent(
     v8::Isolate* isolate,
     v8::Local<v8::Object> sender,
     content::RenderFrameHost* frame,
-    base::Optional<electron::mojom::ElectronBrowser::MessageSyncCallback>
-        callback) {
+    electron::mojom::ElectronBrowser::MessageSyncCallback callback) {
   v8::Local<v8::Object> event;
   if (frame && callback) {
-    mate::Handle<mate::Event> native_event = mate::Event::Create(isolate);
+    gin::Handle<Event> native_event = Event::Create(isolate);
     native_event->SetCallback(std::move(callback));
     event = v8::Local<v8::Object>::Cast(native_event.ToV8());
   } else {

+ 5 - 8
shell/common/gin_helper/event_emitter.h

@@ -8,7 +8,6 @@
 #include <utility>
 #include <vector>
 
-#include "base/optional.h"
 #include "content/public/browser/browser_thread.h"
 #include "electron/shell/common/api/api.mojom.h"
 #include "native_mate/wrappable.h"
@@ -31,8 +30,7 @@ v8::Local<v8::Object> CreateNativeEvent(
     v8::Isolate* isolate,
     v8::Local<v8::Object> sender,
     content::RenderFrameHost* frame,
-    base::Optional<electron::mojom::ElectronBrowser::MessageSyncCallback>
-        callback);
+    electron::mojom::ElectronBrowser::MessageSyncCallback callback);
 
 }  // namespace internal
 
@@ -83,11 +81,10 @@ class EventEmitter : public mate::Wrappable<T> {
 
   // this.emit(name, new Event(sender, message), args...);
   template <typename... Args>
-  bool EmitWithSender(
-      base::StringPiece name,
-      content::RenderFrameHost* sender,
-      base::Optional<electron::mojom::ElectronBrowser::InvokeCallback> callback,
-      Args&&... args) {
+  bool EmitWithSender(base::StringPiece name,
+                      content::RenderFrameHost* sender,
+                      electron::mojom::ElectronBrowser::InvokeCallback callback,
+                      Args&&... args) {
     DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
     v8::Locker locker(isolate());
     v8::HandleScope handle_scope(isolate());

+ 1 - 1
shell/common/gin_helper/event_emitter_caller.cc

@@ -4,7 +4,7 @@
 
 #include "shell/common/gin_helper/event_emitter_caller.h"
 
-#include "shell/common/api/locker.h"
+#include "shell/common/gin_helper/locker.h"
 #include "shell/common/node_includes.h"
 
 namespace gin_helper {

+ 3 - 5
shell/common/api/locker.cc → shell/common/gin_helper/locker.cc

@@ -2,11 +2,9 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE.chromium file.
 
-#include "shell/common/api/locker.h"
+#include "shell/common/gin_helper/locker.h"
 
-#include <memory>
-
-namespace mate {
+namespace gin_helper {
 
 Locker::Locker(v8::Isolate* isolate) {
   if (IsBrowserProcess())
@@ -15,4 +13,4 @@ Locker::Locker(v8::Isolate* isolate) {
 
 Locker::~Locker() = default;
 
-}  // namespace mate
+}  // namespace gin_helper

+ 5 - 5
shell/common/api/locker.h → shell/common/gin_helper/locker.h

@@ -2,15 +2,15 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE.chromium file.
 
-#ifndef SHELL_COMMON_API_LOCKER_H_
-#define SHELL_COMMON_API_LOCKER_H_
+#ifndef SHELL_COMMON_GIN_HELPER_LOCKER_H_
+#define SHELL_COMMON_GIN_HELPER_LOCKER_H_
 
 #include <memory>
 
 #include "base/macros.h"
 #include "v8/include/v8.h"
 
-namespace mate {
+namespace gin_helper {
 
 // Only lock when lockers are used in current thread.
 class Locker {
@@ -31,6 +31,6 @@ class Locker {
   DISALLOW_COPY_AND_ASSIGN(Locker);
 };
 
-}  // namespace mate
+}  // namespace gin_helper
 
-#endif  // SHELL_COMMON_API_LOCKER_H_
+#endif  // SHELL_COMMON_GIN_HELPER_LOCKER_H_

+ 32 - 0
shell/common/gin_helper/persistent_dictionary.cc

@@ -0,0 +1,32 @@
+// Copyright 2014 Cheng Zhao. All rights reserved.
+// Use of this source code is governed by MIT license that can be found in the
+// LICENSE file.
+
+#include "shell/common/gin_helper/persistent_dictionary.h"
+
+namespace gin_helper {
+
+PersistentDictionary::PersistentDictionary() = default;
+
+PersistentDictionary::PersistentDictionary(v8::Isolate* isolate,
+                                           v8::Local<v8::Object> object)
+    : isolate_(isolate), handle_(isolate, object) {}
+
+PersistentDictionary::PersistentDictionary(const PersistentDictionary& other)
+    : isolate_(other.isolate_),
+      handle_(isolate_, v8::Local<v8::Object>::New(isolate_, other.handle_)) {}
+
+PersistentDictionary::~PersistentDictionary() = default;
+
+PersistentDictionary& PersistentDictionary::operator=(
+    const PersistentDictionary& other) {
+  isolate_ = other.isolate_;
+  handle_.Reset(isolate_, v8::Local<v8::Object>::New(isolate_, other.handle_));
+  return *this;
+}
+
+v8::Local<v8::Object> PersistentDictionary::GetHandle() const {
+  return v8::Local<v8::Object>::New(isolate_, handle_);
+}
+
+}  // namespace gin_helper

+ 64 - 0
shell/common/gin_helper/persistent_dictionary.h

@@ -0,0 +1,64 @@
+// Copyright 2014 Cheng Zhao. All rights reserved.
+// Use of this source code is governed by MIT license that can be found in the
+// LICENSE file.
+
+#ifndef SHELL_COMMON_GIN_HELPER_PERSISTENT_DICTIONARY_H_
+#define SHELL_COMMON_GIN_HELPER_PERSISTENT_DICTIONARY_H_
+
+#include "shell/common/gin_helper/dictionary.h"
+
+namespace gin_helper {
+
+// Like Dictionary, but stores object in persistent handle so you can keep it
+// safely on heap.
+//
+// TODO(zcbenz): The only user of this class is AtomTouchBar, we should migrate
+// away from this class.
+class PersistentDictionary {
+ public:
+  PersistentDictionary();
+  PersistentDictionary(v8::Isolate* isolate, v8::Local<v8::Object> object);
+  PersistentDictionary(const PersistentDictionary& other);
+  ~PersistentDictionary();
+
+  PersistentDictionary& operator=(const PersistentDictionary& other);
+
+  v8::Local<v8::Object> GetHandle() const;
+
+  template <typename K, typename V>
+  bool Get(const K& key, V* out) const {
+    v8::Local<v8::Context> context = isolate_->GetCurrentContext();
+    v8::Local<v8::Value> v8_key = gin::ConvertToV8(isolate_, key);
+    v8::Local<v8::Value> value;
+    v8::Maybe<bool> result = GetHandle()->Has(context, v8_key);
+    if (result.IsJust() && result.FromJust() &&
+        GetHandle()->Get(context, v8_key).ToLocal(&value))
+      return gin::ConvertFromV8(isolate_, value, out);
+    return false;
+  }
+
+ private:
+  v8::Isolate* isolate_ = nullptr;
+  v8::Global<v8::Object> handle_;
+};
+
+}  // namespace gin_helper
+
+namespace gin {
+
+template <>
+struct Converter<gin_helper::PersistentDictionary> {
+  static bool FromV8(v8::Isolate* isolate,
+                     v8::Local<v8::Value> val,
+                     gin_helper::PersistentDictionary* out) {
+    if (!val->IsObject())
+      return false;
+    *out = gin_helper::PersistentDictionary(isolate,
+                                            v8::Local<v8::Object>::Cast(val));
+    return true;
+  }
+};
+
+}  // namespace gin
+
+#endif  // SHELL_COMMON_GIN_HELPER_PERSISTENT_DICTIONARY_H_

+ 2 - 2
shell/common/gin_helper/trackable_object.cc

@@ -9,7 +9,7 @@
 #include "base/bind.h"
 #include "base/supports_user_data.h"
 #include "shell/browser/atom_browser_main_parts.h"
-#include "shell/common/api/locker.h"
+#include "shell/common/gin_helper/locker.h"
 
 namespace gin_helper {
 
@@ -33,7 +33,7 @@ class IDUserData : public base::SupportsUserData::Data {
 
 TrackableObjectBase::TrackableObjectBase() : weak_factory_(this) {
   // TODO(zcbenz): Make TrackedObject work in renderer process.
-  DCHECK(mate::Locker::IsBrowserProcess())
+  DCHECK(gin_helper::Locker::IsBrowserProcess())
       << "This class only works for browser process";
 
   electron::AtomBrowserMainParts::Get()->RegisterDestructionCallback(

+ 0 - 162
shell/common/native_mate_converters/callback_converter_deprecated.cc

@@ -1,162 +0,0 @@
-// Copyright (c) 2015 GitHub, Inc. All rights reserved.
-// Use of this source code is governed by the MIT license that can be
-// found in the LICENSE file.
-
-#include "shell/common/native_mate_converters/callback_converter_deprecated.h"
-#include "base/stl_util.h"
-#include "content/public/browser/browser_thread.h"
-
-#include "native_mate/dictionary.h"
-
-using content::BrowserThread;
-
-namespace mate {
-
-namespace internal {
-
-namespace {
-
-struct TranslaterHolder {
-  explicit TranslaterHolder(v8::Isolate* isolate)
-      : handle(isolate, v8::External::New(isolate, this)) {
-    handle.SetWeak(this, &GC, v8::WeakCallbackType::kFinalizer);
-  }
-  ~TranslaterHolder() {
-    if (!handle.IsEmpty()) {
-      handle.ClearWeak();
-      handle.Reset();
-    }
-  }
-
-  static void GC(const v8::WeakCallbackInfo<TranslaterHolder>& data) {
-    delete data.GetParameter();
-  }
-
-  v8::Global<v8::External> handle;
-  Translater translater;
-};
-
-// Cached JavaScript version of |CallTranslater|.
-v8::Persistent<v8::FunctionTemplate> g_call_translater;
-
-void CallTranslater(v8::Local<v8::External> external,
-                    v8::Local<v8::Object> state,
-                    mate::Arguments* args) {
-  // Whether the callback should only be called for once.
-  v8::Isolate* isolate = args->isolate();
-  auto context = isolate->GetCurrentContext();
-  bool one_time =
-      state->Has(context, mate::StringToSymbol(isolate, "oneTime")).ToChecked();
-
-  // Check if the callback has already been called.
-  if (one_time) {
-    auto called_symbol = mate::StringToSymbol(isolate, "called");
-    if (state->Has(context, called_symbol).ToChecked()) {
-      args->ThrowError("callback can only be called for once");
-      return;
-    } else {
-      state->Set(context, called_symbol, v8::Boolean::New(isolate, true))
-          .ToChecked();
-    }
-  }
-
-  TranslaterHolder* holder = static_cast<TranslaterHolder*>(external->Value());
-  holder->translater.Run(args);
-
-  // Free immediately for one-time callback.
-  if (one_time)
-    delete holder;
-}
-
-}  // namespace
-
-// Destroy the class on UI thread when possible.
-struct DeleteOnUIThread {
-  template <typename T>
-  static void Destruct(const T* x) {
-    if (Locker::IsBrowserProcess() &&
-        !BrowserThread::CurrentlyOn(BrowserThread::UI)) {
-      BrowserThread::DeleteSoon(BrowserThread::UI, FROM_HERE, x);
-    } else {
-      delete x;
-    }
-  }
-};
-
-// Like v8::Global, but ref-counted.
-template <typename T>
-class RefCountedGlobal
-    : public base::RefCountedThreadSafe<RefCountedGlobal<T>, DeleteOnUIThread> {
- public:
-  RefCountedGlobal(v8::Isolate* isolate, v8::Local<v8::Value> value)
-      : handle_(isolate, v8::Local<T>::Cast(value)) {}
-
-  bool IsAlive() const { return !handle_.IsEmpty(); }
-
-  v8::Local<T> NewHandle(v8::Isolate* isolate) const {
-    return v8::Local<T>::New(isolate, handle_);
-  }
-
- private:
-  v8::Global<T> handle_;
-
-  DISALLOW_COPY_AND_ASSIGN(RefCountedGlobal);
-};
-
-SafeV8Function::SafeV8Function(v8::Isolate* isolate, v8::Local<v8::Value> value)
-    : v8_function_(new RefCountedGlobal<v8::Function>(isolate, value)) {}
-
-SafeV8Function::SafeV8Function(const SafeV8Function& other) = default;
-
-SafeV8Function::~SafeV8Function() = default;
-
-bool SafeV8Function::IsAlive() const {
-  return v8_function_.get() && v8_function_->IsAlive();
-}
-
-v8::Local<v8::Function> SafeV8Function::NewHandle(v8::Isolate* isolate) const {
-  return v8_function_->NewHandle(isolate);
-}
-
-v8::Local<v8::Value> CreateFunctionFromTranslater(v8::Isolate* isolate,
-                                                  const Translater& translater,
-                                                  bool one_time) {
-  // The FunctionTemplate is cached.
-  if (g_call_translater.IsEmpty())
-    g_call_translater.Reset(isolate,
-                            mate::CreateFunctionTemplate(
-                                isolate, base::BindRepeating(&CallTranslater)));
-
-  v8::Local<v8::FunctionTemplate> call_translater =
-      v8::Local<v8::FunctionTemplate>::New(isolate, g_call_translater);
-  auto* holder = new TranslaterHolder(isolate);
-  holder->translater = translater;
-  Dictionary state = mate::Dictionary::CreateEmpty(isolate);
-  if (one_time)
-    state.Set("oneTime", true);
-  auto context = isolate->GetCurrentContext();
-  return BindFunctionWith(
-      isolate, context, call_translater->GetFunction(context).ToLocalChecked(),
-      holder->handle.Get(isolate), state.GetHandle());
-}
-
-// func.bind(func, arg1).
-// NB(zcbenz): Using C++11 version crashes VS.
-v8::Local<v8::Value> BindFunctionWith(v8::Isolate* isolate,
-                                      v8::Local<v8::Context> context,
-                                      v8::Local<v8::Function> func,
-                                      v8::Local<v8::Value> arg1,
-                                      v8::Local<v8::Value> arg2) {
-  v8::MaybeLocal<v8::Value> bind =
-      func->Get(context, mate::StringToV8(isolate, "bind"));
-  CHECK(!bind.IsEmpty());
-  v8::Local<v8::Function> bind_func =
-      v8::Local<v8::Function>::Cast(bind.ToLocalChecked());
-  v8::Local<v8::Value> converted[] = {func, arg1, arg2};
-  return bind_func->Call(context, func, base::size(converted), converted)
-      .ToLocalChecked();
-}
-
-}  // namespace internal
-
-}  // namespace mate

+ 0 - 185
shell/common/native_mate_converters/callback_converter_deprecated.h

@@ -1,185 +0,0 @@
-// Copyright (c) 2015 GitHub, Inc. All rights reserved.
-// Use of this source code is governed by the MIT license that can be
-// found in the LICENSE file.
-
-#ifndef SHELL_COMMON_NATIVE_MATE_CONVERTERS_CALLBACK_CONVERTER_DEPRECATED_H_
-#define SHELL_COMMON_NATIVE_MATE_CONVERTERS_CALLBACK_CONVERTER_DEPRECATED_H_
-
-#include <utility>
-#include <vector>
-
-#include "base/bind.h"
-#include "base/callback.h"
-#include "base/memory/weak_ptr.h"
-#include "base/message_loop/message_loop.h"
-#include "native_mate/function_template.h"
-#include "native_mate/scoped_persistent.h"
-#include "shell/common/api/locker.h"
-
-// =============================== NOTICE ===============================
-// Do not add code here, native_mate is being removed. Any new code
-// should use gin instead.
-
-namespace mate {
-
-namespace internal {
-
-template <typename T>
-class RefCountedGlobal;
-
-// Manages the V8 function with RAII.
-class SafeV8Function {
- public:
-  SafeV8Function(v8::Isolate* isolate, v8::Local<v8::Value> value);
-  SafeV8Function(const SafeV8Function& other);
-  ~SafeV8Function();
-
-  bool IsAlive() const;
-  v8::Local<v8::Function> NewHandle(v8::Isolate* isolate) const;
-
- private:
-  scoped_refptr<RefCountedGlobal<v8::Function>> v8_function_;
-};
-
-// Helper to invoke a V8 function with C++ parameters.
-template <typename Sig>
-struct V8FunctionInvoker {};
-
-template <typename... ArgTypes>
-struct V8FunctionInvoker<v8::Local<v8::Value>(ArgTypes...)> {
-  static v8::Local<v8::Value> Go(v8::Isolate* isolate,
-                                 const SafeV8Function& function,
-                                 ArgTypes... raw) {
-    Locker locker(isolate);
-    v8::EscapableHandleScope handle_scope(isolate);
-    if (!function.IsAlive())
-      return v8::Null(isolate);
-    v8::MicrotasksScope script_scope(isolate,
-                                     v8::MicrotasksScope::kRunMicrotasks);
-    v8::Local<v8::Function> holder = function.NewHandle(isolate);
-    v8::Local<v8::Context> context = holder->CreationContext();
-    v8::Context::Scope context_scope(context);
-    std::vector<v8::Local<v8::Value>> args{
-        ConvertToV8(isolate, std::forward<ArgTypes>(raw))...};
-    v8::MaybeLocal<v8::Value> ret = holder->Call(
-        context, holder, args.size(), args.empty() ? nullptr : &args.front());
-    if (ret.IsEmpty())
-      return v8::Undefined(isolate);
-    else
-      return handle_scope.Escape(ret.ToLocalChecked());
-  }
-};
-
-template <typename... ArgTypes>
-struct V8FunctionInvoker<void(ArgTypes...)> {
-  static void Go(v8::Isolate* isolate,
-                 const SafeV8Function& function,
-                 ArgTypes... raw) {
-    Locker locker(isolate);
-    v8::HandleScope handle_scope(isolate);
-    if (!function.IsAlive())
-      return;
-    v8::MicrotasksScope script_scope(isolate,
-                                     v8::MicrotasksScope::kRunMicrotasks);
-    v8::Local<v8::Function> holder = function.NewHandle(isolate);
-    v8::Local<v8::Context> context = holder->CreationContext();
-    v8::Context::Scope context_scope(context);
-    std::vector<v8::Local<v8::Value>> args{
-        ConvertToV8(isolate, std::forward<ArgTypes>(raw))...};
-    holder
-        ->Call(context, holder, args.size(),
-               args.empty() ? nullptr : &args.front())
-        .IsEmpty();
-  }
-};
-
-template <typename ReturnType, typename... ArgTypes>
-struct V8FunctionInvoker<ReturnType(ArgTypes...)> {
-  static ReturnType Go(v8::Isolate* isolate,
-                       const SafeV8Function& function,
-                       ArgTypes... raw) {
-    Locker locker(isolate);
-    v8::HandleScope handle_scope(isolate);
-    ReturnType ret = ReturnType();
-    if (!function.IsAlive())
-      return ret;
-    v8::MicrotasksScope script_scope(isolate,
-                                     v8::MicrotasksScope::kRunMicrotasks);
-    v8::Local<v8::Function> holder = function.NewHandle(isolate);
-    v8::Local<v8::Context> context = holder->CreationContext();
-    v8::Context::Scope context_scope(context);
-    std::vector<v8::Local<v8::Value>> args{
-        ConvertToV8(isolate, std::forward<ArgTypes>(raw))...};
-    v8::Local<v8::Value> result;
-    auto maybe_result = holder->Call(context, holder, args.size(),
-                                     args.empty() ? nullptr : &args.front());
-    if (maybe_result.ToLocal(&result))
-      Converter<ReturnType>::FromV8(isolate, result, &ret);
-    return ret;
-  }
-};
-
-// Helper to pass a C++ funtion to JavaScript.
-using Translater = base::Callback<void(Arguments* args)>;
-v8::Local<v8::Value> CreateFunctionFromTranslater(v8::Isolate* isolate,
-                                                  const Translater& translater,
-                                                  bool one_time);
-v8::Local<v8::Value> BindFunctionWith(v8::Isolate* isolate,
-                                      v8::Local<v8::Context> context,
-                                      v8::Local<v8::Function> func,
-                                      v8::Local<v8::Value> arg1,
-                                      v8::Local<v8::Value> arg2);
-
-// Calls callback with Arguments.
-template <typename Sig>
-struct NativeFunctionInvoker {};
-
-template <typename ReturnType, typename... ArgTypes>
-struct NativeFunctionInvoker<ReturnType(ArgTypes...)> {
-  static void Go(base::Callback<ReturnType(ArgTypes...)> val, Arguments* args) {
-    using Indices = typename IndicesGenerator<sizeof...(ArgTypes)>::type;
-    Invoker<Indices, ArgTypes...> invoker(args, 0);
-    if (invoker.IsOK())
-      invoker.DispatchToCallback(val);
-  }
-};
-
-}  // namespace internal
-
-template <typename Sig>
-struct Converter<base::RepeatingCallback<Sig>> {
-  static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
-                                   const base::RepeatingCallback<Sig>& val) {
-    // We don't use CreateFunctionTemplate here because it creates a new
-    // FunctionTemplate everytime, which is cached by V8 and causes leaks.
-    internal::Translater translater =
-        base::Bind(&internal::NativeFunctionInvoker<Sig>::Go, val);
-    // To avoid memory leak, we ensure that the callback can only be called
-    // for once.
-    return internal::CreateFunctionFromTranslater(isolate, translater, true);
-  }
-  static bool FromV8(v8::Isolate* isolate,
-                     v8::Local<v8::Value> val,
-                     base::RepeatingCallback<Sig>* out) {
-    if (!val->IsFunction())
-      return false;
-
-    *out = base::BindRepeating(&internal::V8FunctionInvoker<Sig>::Go, isolate,
-                               internal::SafeV8Function(isolate, val));
-    return true;
-  }
-};
-
-// Convert a callback to V8 without the call number limitation, this can easily
-// cause memory leaks so use it with caution.
-template <typename Sig>
-v8::Local<v8::Value> CallbackToV8(v8::Isolate* isolate,
-                                  const base::Callback<Sig>& val) {
-  internal::Translater translater =
-      base::Bind(&internal::NativeFunctionInvoker<Sig>::Go, val);
-  return internal::CreateFunctionFromTranslater(isolate, translater, false);
-}
-
-}  // namespace mate
-
-#endif  // SHELL_COMMON_NATIVE_MATE_CONVERTERS_CALLBACK_CONVERTER_DEPRECATED_H_

+ 0 - 41
shell/common/native_mate_converters/file_dialog_converter.h

@@ -1,41 +0,0 @@
-// Copyright (c) 2014 GitHub, Inc.
-// Use of this source code is governed by the MIT license that can be
-// found in the LICENSE file.
-
-#ifndef SHELL_COMMON_NATIVE_MATE_CONVERTERS_FILE_DIALOG_CONVERTER_H_
-#define SHELL_COMMON_NATIVE_MATE_CONVERTERS_FILE_DIALOG_CONVERTER_H_
-
-#include "native_mate/converter.h"
-#include "shell/common/gin_converters/file_dialog_converter.h"
-
-namespace mate {
-
-template <>
-struct Converter<file_dialog::Filter> {
-  static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
-                                   const file_dialog::Filter& in) {
-    return gin::ConvertToV8(isolate, in);
-  }
-  static bool FromV8(v8::Isolate* isolate,
-                     v8::Local<v8::Value> val,
-                     file_dialog::Filter* out) {
-    return gin::ConvertFromV8(isolate, val, out);
-  }
-};
-
-template <>
-struct Converter<file_dialog::DialogSettings> {
-  static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
-                                   const file_dialog::DialogSettings& in) {
-    return gin::ConvertToV8(isolate, in);
-  }
-  static bool FromV8(v8::Isolate* isolate,
-                     v8::Local<v8::Value> val,
-                     file_dialog::DialogSettings* out) {
-    return gin::ConvertFromV8(isolate, val, out);
-  }
-};
-
-}  // namespace mate
-
-#endif  // SHELL_COMMON_NATIVE_MATE_CONVERTERS_FILE_DIALOG_CONVERTER_H_

+ 0 - 28
shell/common/native_mate_converters/file_path_converter.h

@@ -1,28 +0,0 @@
-// Copyright (c) 2014 GitHub, Inc.
-// Use of this source code is governed by the MIT license that can be
-// found in the LICENSE file.
-
-#ifndef SHELL_COMMON_NATIVE_MATE_CONVERTERS_FILE_PATH_CONVERTER_H_
-#define SHELL_COMMON_NATIVE_MATE_CONVERTERS_FILE_PATH_CONVERTER_H_
-
-#include "shell/common/gin_converters/file_path_converter.h"
-
-namespace mate {
-
-template <>
-struct Converter<base::FilePath> {
-  static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
-                                   const base::FilePath& val) {
-    return gin::Converter<base::FilePath::StringType>::ToV8(isolate,
-                                                            val.value());
-  }
-  static bool FromV8(v8::Isolate* isolate,
-                     v8::Local<v8::Value> val,
-                     base::FilePath* out) {
-    return gin::Converter<base::FilePath>::FromV8(isolate, val, out);
-  }
-};
-
-}  // namespace mate
-
-#endif  // SHELL_COMMON_NATIVE_MATE_CONVERTERS_FILE_PATH_CONVERTER_H_

+ 0 - 27
shell/common/native_mate_converters/gurl_converter.h

@@ -1,27 +0,0 @@
-// Copyright (c) 2014 GitHub, Inc.
-// Use of this source code is governed by the MIT license that can be
-// found in the LICENSE file.
-
-#ifndef SHELL_COMMON_NATIVE_MATE_CONVERTERS_GURL_CONVERTER_H_
-#define SHELL_COMMON_NATIVE_MATE_CONVERTERS_GURL_CONVERTER_H_
-
-#include "native_mate/converter.h"
-#include "shell/common/gin_converters/gurl_converter.h"
-
-namespace mate {
-
-template <>
-struct Converter<GURL> {
-  static v8::Local<v8::Value> ToV8(v8::Isolate* isolate, const GURL& val) {
-    return gin::ConvertToV8(isolate, val);
-  }
-  static bool FromV8(v8::Isolate* isolate,
-                     v8::Local<v8::Value> val,
-                     GURL* out) {
-    return gin::ConvertFromV8(isolate, val, out);
-  }
-};
-
-}  // namespace mate
-
-#endif  // SHELL_COMMON_NATIVE_MATE_CONVERTERS_GURL_CONVERTER_H_

+ 0 - 37
shell/common/native_mate_converters/image_converter.h

@@ -1,37 +0,0 @@
-// Copyright (c) 2014 GitHub, Inc.
-// Use of this source code is governed by the MIT license that can be
-// found in the LICENSE file.
-
-#ifndef SHELL_COMMON_NATIVE_MATE_CONVERTERS_IMAGE_CONVERTER_H_
-#define SHELL_COMMON_NATIVE_MATE_CONVERTERS_IMAGE_CONVERTER_H_
-
-#include "native_mate/converter.h"
-#include "shell/common/gin_converters/image_converter.h"
-
-namespace mate {
-
-template <>
-struct Converter<gfx::ImageSkia> {
-  static bool FromV8(v8::Isolate* isolate,
-                     v8::Local<v8::Value> val,
-                     gfx::ImageSkia* out) {
-    return gin::ConvertFromV8(isolate, val, out);
-  }
-};
-
-template <>
-struct Converter<gfx::Image> {
-  static bool FromV8(v8::Isolate* isolate,
-                     v8::Local<v8::Value> val,
-                     gfx::Image* out) {
-    return gin::ConvertFromV8(isolate, val, out);
-  }
-  static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
-                                   const gfx::Image& val) {
-    return gin::ConvertToV8(isolate, val);
-  }
-};
-
-}  // namespace mate
-
-#endif  // SHELL_COMMON_NATIVE_MATE_CONVERTERS_IMAGE_CONVERTER_H_

+ 0 - 24
shell/common/native_mate_converters/native_window_converter.h

@@ -1,24 +0,0 @@
-// Copyright (c) 2019 GitHub, Inc.
-// Use of this source code is governed by the MIT license that can be
-// found in the LICENSE file.
-
-#ifndef SHELL_COMMON_NATIVE_MATE_CONVERTERS_NATIVE_WINDOW_CONVERTER_H_
-#define SHELL_COMMON_NATIVE_MATE_CONVERTERS_NATIVE_WINDOW_CONVERTER_H_
-
-#include "native_mate/converter.h"
-#include "shell/common/gin_converters/native_window_converter.h"
-
-namespace mate {
-
-template <>
-struct Converter<electron::NativeWindow*> {
-  static bool FromV8(v8::Isolate* isolate,
-                     v8::Local<v8::Value> val,
-                     electron::NativeWindow** out) {
-    return gin::ConvertFromV8(isolate, val, out);
-  }
-};
-
-}  // namespace mate
-
-#endif  // SHELL_COMMON_NATIVE_MATE_CONVERTERS_NATIVE_WINDOW_CONVERTER_H_

+ 0 - 75
shell/common/native_mate_converters/net_converter.h

@@ -1,75 +0,0 @@
-// Copyright (c) 2015 GitHub, Inc.
-// Use of this source code is governed by the MIT license that can be
-// found in the LICENSE file.
-
-#ifndef SHELL_COMMON_NATIVE_MATE_CONVERTERS_NET_CONVERTER_H_
-#define SHELL_COMMON_NATIVE_MATE_CONVERTERS_NET_CONVERTER_H_
-
-#include "native_mate/converter.h"
-#include "shell/common/gin_converters/net_converter.h"
-
-namespace mate {
-
-template <>
-struct Converter<net::AuthChallengeInfo> {
-  static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
-                                   const net::AuthChallengeInfo& val) {
-    return gin::ConvertToV8(isolate, val);
-  }
-};
-
-template <>
-struct Converter<scoped_refptr<net::X509Certificate>> {
-  static v8::Local<v8::Value> ToV8(
-      v8::Isolate* isolate,
-      const scoped_refptr<net::X509Certificate>& val) {
-    return gin::ConvertToV8(isolate, val);
-  }
-
-  static bool FromV8(v8::Isolate* isolate,
-                     v8::Local<v8::Value> val,
-                     scoped_refptr<net::X509Certificate>* out) {
-    return gin::ConvertFromV8(isolate, val, out);
-  }
-};
-
-template <>
-struct Converter<net::CertPrincipal> {
-  static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
-                                   const net::CertPrincipal& val) {
-    return gin::ConvertToV8(isolate, val);
-  }
-};
-
-template <>
-struct Converter<net::HttpResponseHeaders*> {
-  static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
-                                   net::HttpResponseHeaders* headers) {
-    return gin::ConvertToV8(isolate, headers);
-  }
-  static bool FromV8(v8::Isolate* isolate,
-                     v8::Local<v8::Value> val,
-                     net::HttpResponseHeaders* out) {
-    return gin::Converter<net::HttpResponseHeaders*>::FromV8(isolate, val, out);
-  }
-};
-
-template <>
-struct Converter<network::ResourceRequest> {
-  static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
-                                   const network::ResourceRequest& val) {
-    return gin::ConvertToV8(isolate, val);
-  }
-};
-
-template <>
-struct Converter<electron::VerifyRequestParams> {
-  static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
-                                   electron::VerifyRequestParams val) {
-    return gin::ConvertToV8(isolate, val);
-  }
-};
-
-}  // namespace mate
-
-#endif  // SHELL_COMMON_NATIVE_MATE_CONVERTERS_NET_CONVERTER_H_

+ 0 - 87
shell/common/native_mate_converters/once_callback.h

@@ -1,87 +0,0 @@
-// Copyright (c) 2019 GitHub, Inc. All rights reserved.
-// Use of this source code is governed by the MIT license that can be
-// found in the LICENSE file.
-
-#ifndef SHELL_COMMON_NATIVE_MATE_CONVERTERS_ONCE_CALLBACK_H_
-#define SHELL_COMMON_NATIVE_MATE_CONVERTERS_ONCE_CALLBACK_H_
-
-#include <utility>
-
-#include "shell/common/native_mate_converters/callback_converter_deprecated.h"
-
-namespace mate {
-
-namespace internal {
-
-// Manages the OnceCallback with ref-couting.
-template <typename Sig>
-class RefCountedOnceCallback
-    : public base::RefCounted<RefCountedOnceCallback<Sig>> {
- public:
-  explicit RefCountedOnceCallback(base::OnceCallback<Sig> callback)
-      : callback_(std::move(callback)) {}
-
-  base::OnceCallback<Sig> GetCallback() { return std::move(callback_); }
-
- private:
-  friend class base::RefCounted<RefCountedOnceCallback<Sig>>;
-  ~RefCountedOnceCallback() = default;
-
-  base::OnceCallback<Sig> callback_;
-};
-
-// Invokes the OnceCallback.
-template <typename Sig>
-struct InvokeOnceCallback {};
-
-template <typename... ArgTypes>
-struct InvokeOnceCallback<void(ArgTypes...)> {
-  static void Go(
-      scoped_refptr<RefCountedOnceCallback<void(ArgTypes...)>> holder,
-      ArgTypes... args) {
-    base::OnceCallback<void(ArgTypes...)> callback = holder->GetCallback();
-    DCHECK(!callback.is_null());
-    std::move(callback).Run(std::move(args)...);
-  }
-};
-
-template <typename ReturnType, typename... ArgTypes>
-struct InvokeOnceCallback<ReturnType(ArgTypes...)> {
-  static ReturnType Go(
-      scoped_refptr<RefCountedOnceCallback<ReturnType(ArgTypes...)>> holder,
-      ArgTypes... args) {
-    base::OnceCallback<void(ArgTypes...)> callback = holder->GetCallback();
-    DCHECK(!callback.is_null());
-    return std::move(callback).Run(std::move(args)...);
-  }
-};
-
-}  // namespace internal
-
-template <typename Sig>
-struct Converter<base::OnceCallback<Sig>> {
-  static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
-                                   base::OnceCallback<Sig> val) {
-    // Reuse the converter of base::RepeatingCallback by storing the callback
-    // with a RefCounted.
-    auto holder = base::MakeRefCounted<internal::RefCountedOnceCallback<Sig>>(
-        std::move(val));
-    return Converter<base::RepeatingCallback<Sig>>::ToV8(
-        isolate,
-        base::BindRepeating(&internal::InvokeOnceCallback<Sig>::Go, holder));
-  }
-
-  static bool FromV8(v8::Isolate* isolate,
-                     v8::Local<v8::Value> val,
-                     base::OnceCallback<Sig>* out) {
-    if (!val->IsFunction())
-      return false;
-    *out = base::BindOnce(&internal::V8FunctionInvoker<Sig>::Go, isolate,
-                          internal::SafeV8Function(isolate, val));
-    return true;
-  }
-};
-
-}  // namespace mate
-
-#endif  // SHELL_COMMON_NATIVE_MATE_CONVERTERS_ONCE_CALLBACK_H_

+ 0 - 33
shell/common/native_mate_converters/string16_converter.h

@@ -1,33 +0,0 @@
-// Copyright (c) 2014 GitHub, Inc.
-// Use of this source code is governed by the MIT license that can be
-// found in the LICENSE file.
-
-#ifndef SHELL_COMMON_NATIVE_MATE_CONVERTERS_STRING16_CONVERTER_H_
-#define SHELL_COMMON_NATIVE_MATE_CONVERTERS_STRING16_CONVERTER_H_
-
-#include "gin/converter.h"
-#include "native_mate/converter.h"
-
-namespace mate {
-
-template <>
-struct Converter<base::string16> {
-  static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
-                                   const base::string16& val) {
-    return gin::Converter<base::string16>::ToV8(isolate, val);
-  }
-  static bool FromV8(v8::Isolate* isolate,
-                     v8::Local<v8::Value> val,
-                     base::string16* out) {
-    return gin::Converter<base::string16>::FromV8(isolate, val, out);
-  }
-};
-
-inline v8::Local<v8::String> StringToV8(v8::Isolate* isolate,
-                                        const base::string16& input) {
-  return ConvertToV8(isolate, input).As<v8::String>();
-}
-
-}  // namespace mate
-
-#endif  // SHELL_COMMON_NATIVE_MATE_CONVERTERS_STRING16_CONVERTER_H_

+ 2 - 2
shell/common/node_bindings.cc

@@ -22,11 +22,11 @@
 #include "content/public/browser/browser_thread.h"
 #include "content/public/common/content_paths.h"
 #include "electron/buildflags/buildflags.h"
-#include "shell/common/api/locker.h"
 #include "shell/common/atom_command_line.h"
 #include "shell/common/gin_converters/file_path_converter.h"
 #include "shell/common/gin_helper/dictionary.h"
 #include "shell/common/gin_helper/event_emitter_caller.h"
+#include "shell/common/gin_helper/locker.h"
 #include "shell/common/mac/main_application_bundle.h"
 #include "shell/common/node_includes.h"
 
@@ -396,7 +396,7 @@ void NodeBindings::UvRunOnce() {
     return;
 
   // Use Locker in browser process.
-  mate::Locker locker(env->isolate());
+  gin_helper::Locker locker(env->isolate());
   v8::HandleScope handle_scope(env->isolate());
 
   // Enter node context while dealing with uv events.

+ 1 - 1
shell/common/native_mate_converters/v8_value_converter.cc → shell/common/v8_value_converter.cc

@@ -2,7 +2,7 @@
 // Use of this source code is governed by the MIT license that can be
 // found in the LICENSE file.
 
-#include "shell/common/native_mate_converters/v8_value_converter.h"
+#include "shell/common/v8_value_converter.h"
 
 #include <map>
 #include <memory>

+ 3 - 3
shell/common/native_mate_converters/v8_value_converter.h → shell/common/v8_value_converter.h

@@ -2,8 +2,8 @@
 // Use of this source code is governed by the MIT license that can be
 // found in the LICENSE file.
 
-#ifndef SHELL_COMMON_NATIVE_MATE_CONVERTERS_V8_VALUE_CONVERTER_H_
-#define SHELL_COMMON_NATIVE_MATE_CONVERTERS_V8_VALUE_CONVERTER_H_
+#ifndef SHELL_COMMON_V8_VALUE_CONVERTER_H_
+#define SHELL_COMMON_V8_VALUE_CONVERTER_H_
 
 #include <memory>
 
@@ -74,4 +74,4 @@ class V8ValueConverter {
 
 }  // namespace electron
 
-#endif  // SHELL_COMMON_NATIVE_MATE_CONVERTERS_V8_VALUE_CONVERTER_H_
+#endif  // SHELL_COMMON_V8_VALUE_CONVERTER_H_

+ 37 - 34
shell/renderer/api/atom_api_context_bridge.cc

@@ -4,17 +4,25 @@
 
 #include "shell/renderer/api/atom_api_context_bridge.h"
 
+#include <map>
 #include <set>
+#include <string>
 #include <utility>
 #include <vector>
 
 #include "base/no_destructor.h"
 #include "base/strings/string_number_conversions.h"
+#include "content/public/renderer/render_frame.h"
+#include "content/public/renderer/render_frame_observer.h"
 #include "shell/common/api/remote/object_life_monitor.h"
-#include "shell/common/native_mate_converters/blink_converter.h"
-#include "shell/common/native_mate_converters/callback_converter_deprecated.h"
-#include "shell/common/native_mate_converters/once_callback.h"
+#include "shell/common/gin_converters/blink_converter.h"
+#include "shell/common/gin_converters/callback_converter.h"
+#include "shell/common/gin_helper/dictionary.h"
+#include "shell/common/node_includes.h"
 #include "shell/common/promise_util.h"
+#include "shell/renderer/api/context_bridge/render_frame_context_bridge_store.h"
+#include "shell/renderer/atom_render_frame_observer.h"
+#include "third_party/blink/public/web/web_local_frame.h"
 
 namespace electron {
 
@@ -24,6 +32,11 @@ namespace {
 
 static int kMaxRecursion = 1000;
 
+// Returns true if |maybe| is both a value, and that value is true.
+inline bool IsTrue(v8::Maybe<bool> maybe) {
+  return maybe.IsJust() && maybe.FromJust();
+}
+
 content::RenderFrame* GetRenderFrame(const v8::Local<v8::Object>& value) {
   v8::Local<v8::Context> context = value->CreationContext();
   if (context.IsEmpty())
@@ -74,7 +87,7 @@ bool DeepFreeze(const v8::Local<v8::Object>& object,
         return false;
     }
   }
-  return mate::internal::IsTrue(
+  return IsTrue(
       object->SetIntegrityLevel(context, v8::IntegrityLevel::kFrozen));
 }
 
@@ -130,16 +143,6 @@ class FunctionLifeMonitor final : public ObjectLifeMonitor {
 
 }  // namespace
 
-template <typename Sig>
-v8::Local<v8::Value> BindRepeatingFunctionToV8(
-    v8::Isolate* isolate,
-    const base::RepeatingCallback<Sig>& val) {
-  auto translater =
-      base::BindRepeating(&mate::internal::NativeFunctionInvoker<Sig>::Go, val);
-  return mate::internal::CreateFunctionFromTranslater(isolate, translater,
-                                                      false);
-}
-
 v8::MaybeLocal<v8::Value> PassValueToOtherContext(
     v8::Local<v8::Context> source_context,
     v8::Local<v8::Context> destination_context,
@@ -176,7 +179,7 @@ v8::MaybeLocal<v8::Value> PassValueToOtherContext(
         std::make_tuple(std::move(global_func), std::move(global_source));
     v8::Context::Scope destination_scope(destination_context);
     {
-      v8::Local<v8::Value> proxy_func = BindRepeatingFunctionToV8(
+      v8::Local<v8::Value> proxy_func = gin_helper::CallbackToV8Leaked(
           destination_context->GetIsolate(),
           base::BindRepeating(&ProxyFunctionWrapper, store, func_id));
       FunctionLifeMonitor::BindTo(destination_context->GetIsolate(),
@@ -239,9 +242,9 @@ v8::MaybeLocal<v8::Value> PassValueToOtherContext(
       ignore_result(source_promise->Then(
           source_context,
           v8::Local<v8::Function>::Cast(
-              mate::ConvertToV8(destination_context->GetIsolate(), then_cb)),
+              gin::ConvertToV8(destination_context->GetIsolate(), then_cb)),
           v8::Local<v8::Function>::Cast(
-              mate::ConvertToV8(destination_context->GetIsolate(), catch_cb))));
+              gin::ConvertToV8(destination_context->GetIsolate(), catch_cb))));
 
       store->CacheProxiedObject(value, proxied_promise_handle);
       return v8::MaybeLocal<v8::Value>(proxied_promise_handle);
@@ -275,9 +278,8 @@ v8::MaybeLocal<v8::Value> PassValueToOtherContext(
         if (value_for_array.IsEmpty())
           return v8::MaybeLocal<v8::Value>();
 
-        if (!mate::internal::IsTrue(
-                cloned_arr->Set(destination_context, static_cast<int>(i),
-                                value_for_array.ToLocalChecked()))) {
+        if (!IsTrue(cloned_arr->Set(destination_context, static_cast<int>(i),
+                                    value_for_array.ToLocalChecked()))) {
           return v8::MaybeLocal<v8::Value>();
         }
       }
@@ -303,7 +305,7 @@ v8::MaybeLocal<v8::Value> PassValueToOtherContext(
     v8::Context::Scope source_context_scope(source_context);
     {
       // V8 serializer will throw an error if required
-      if (!mate::ConvertFromV8(source_context->GetIsolate(), value, &ret))
+      if (!gin::ConvertFromV8(source_context->GetIsolate(), value, &ret))
         return v8::MaybeLocal<v8::Value>();
     }
   }
@@ -311,7 +313,7 @@ v8::MaybeLocal<v8::Value> PassValueToOtherContext(
   v8::Context::Scope destination_context_scope(destination_context);
   {
     v8::Local<v8::Value> cloned_value =
-        mate::ConvertToV8(destination_context->GetIsolate(), ret);
+        gin::ConvertToV8(destination_context->GetIsolate(), ret);
     store->CacheProxiedObject(value, cloned_value);
     return v8::MaybeLocal<v8::Value>(cloned_value);
   }
@@ -320,7 +322,7 @@ v8::MaybeLocal<v8::Value> PassValueToOtherContext(
 v8::Local<v8::Value> ProxyFunctionWrapper(
     context_bridge::RenderFramePersistenceStore* store,
     size_t func_id,
-    mate::Arguments* args) {
+    gin_helper::Arguments* args) {
   // Context the proxy function was called from
   v8::Local<v8::Context> calling_context = args->isolate()->GetCurrentContext();
   // Context the function was created in
@@ -356,8 +358,8 @@ v8::Local<v8::Value> ProxyFunctionWrapper(
         auto message = try_catch.Message();
 
         if (message.IsEmpty() ||
-            !mate::ConvertFromV8(args->isolate(), message->Get(),
-                                 &error_message)) {
+            !gin::ConvertFromV8(args->isolate(), message->Get(),
+                                &error_message)) {
           error_message =
               "An unknown exception occurred in the isolated context, an error "
               "occurred but a valid exception was not thrown.";
@@ -391,9 +393,9 @@ v8::MaybeLocal<v8::Object> CreateProxyForAPI(
     const v8::Local<v8::Context>& destination_context,
     context_bridge::RenderFramePersistenceStore* store,
     int recursion_depth) {
-  mate::Dictionary api(source_context->GetIsolate(), api_object);
-  mate::Dictionary proxy =
-      mate::Dictionary::CreateEmpty(destination_context->GetIsolate());
+  gin_helper::Dictionary api(source_context->GetIsolate(), api_object);
+  gin_helper::Dictionary proxy =
+      gin::Dictionary::CreateEmpty(destination_context->GetIsolate());
   store->CacheProxiedObject(api.GetHandle(), proxy.GetHandle());
   auto maybe_keys = api.GetHandle()->GetOwnPropertyNames(
       source_context,
@@ -411,7 +413,7 @@ v8::MaybeLocal<v8::Object> CreateProxyForAPI(
       v8::Local<v8::Value> key =
           keys->Get(destination_context, i).ToLocalChecked();
       // Try get the key as a string
-      if (!mate::ConvertFromV8(api.isolate(), key, &key_str)) {
+      if (!gin::ConvertFromV8(api.isolate(), key, &key_str)) {
         continue;
       }
       v8::Local<v8::Value> value;
@@ -431,10 +433,10 @@ v8::MaybeLocal<v8::Object> CreateProxyForAPI(
 }
 
 #ifdef DCHECK_IS_ON
-mate::Dictionary DebugGC(mate::Dictionary empty) {
+gin_helper::Dictionary DebugGC(gin_helper::Dictionary empty) {
   auto* render_frame = GetRenderFrame(empty.GetHandle());
   auto* store = GetOrCreateStore(render_frame);
-  mate::Dictionary ret = mate::Dictionary::CreateEmpty(empty.isolate());
+  gin_helper::Dictionary ret = gin::Dictionary::CreateEmpty(empty.isolate());
   ret.Set("functionCount", store->functions().size());
   auto* proxy_map = store->proxy_map();
   ret.Set("objectCount", proxy_map->size() * 2);
@@ -458,7 +460,7 @@ mate::Dictionary DebugGC(mate::Dictionary empty) {
 
 void ExposeAPIInMainWorld(const std::string& key,
                           v8::Local<v8::Object> api_object,
-                          mate::Arguments* args) {
+                          gin_helper::Arguments* args) {
   auto* render_frame = GetRenderFrame(api_object);
   CHECK(render_frame);
   context_bridge::RenderFramePersistenceStore* store =
@@ -466,7 +468,8 @@ void ExposeAPIInMainWorld(const std::string& key,
   auto* frame = render_frame->GetWebFrame();
   CHECK(frame);
   v8::Local<v8::Context> main_context = frame->MainWorldScriptContext();
-  mate::Dictionary global(main_context->GetIsolate(), main_context->Global());
+  gin_helper::Dictionary global(main_context->GetIsolate(),
+                                main_context->Global());
 
   if (global.Has(key)) {
     args->ThrowError(
@@ -503,7 +506,7 @@ void Initialize(v8::Local<v8::Object> exports,
                 v8::Local<v8::Context> context,
                 void* priv) {
   v8::Isolate* isolate = context->GetIsolate();
-  mate::Dictionary dict(isolate, exports);
+  gin_helper::Dictionary dict(isolate, exports);
   dict.SetMethod("exposeAPIInMainWorld", &electron::api::ExposeAPIInMainWorld);
 #ifdef DCHECK_IS_ON
   dict.SetMethod("_debugGCMaps", &electron::api::DebugGC);

+ 10 - 13
shell/renderer/api/atom_api_context_bridge.h

@@ -5,27 +5,24 @@
 #ifndef SHELL_RENDERER_API_ATOM_API_CONTEXT_BRIDGE_H_
 #define SHELL_RENDERER_API_ATOM_API_CONTEXT_BRIDGE_H_
 
-#include <map>
-#include <string>
-#include <tuple>
-
-#include "content/public/renderer/render_frame.h"
-#include "content/public/renderer/render_frame_observer.h"
-#include "native_mate/converter.h"
-#include "native_mate/dictionary.h"
-#include "shell/common/node_includes.h"
-#include "shell/renderer/api/context_bridge/render_frame_context_bridge_store.h"
-#include "shell/renderer/atom_render_frame_observer.h"
-#include "third_party/blink/public/web/web_local_frame.h"
+#include "v8/include/v8.h"
+
+namespace gin_helper {
+class Arguments;
+}
 
 namespace electron {
 
 namespace api {
 
+namespace context_bridge {
+class RenderFramePersistenceStore;
+}
+
 v8::Local<v8::Value> ProxyFunctionWrapper(
     context_bridge::RenderFramePersistenceStore* store,
     size_t func_id,
-    mate::Arguments* args);
+    gin_helper::Arguments* args);
 
 v8::MaybeLocal<v8::Object> CreateProxyForAPI(
     const v8::Local<v8::Object>& api_object,

+ 7 - 7
shell/renderer/api/atom_api_renderer_ipc.cc

@@ -13,8 +13,8 @@
 #include "gin/wrappable.h"
 #include "services/service_manager/public/cpp/interface_provider.h"
 #include "shell/common/api/api.mojom.h"
-#include "shell/common/gin_converters/blink_converter_gin_adapter.h"
-#include "shell/common/gin_converters/value_converter_gin_adapter.h"
+#include "shell/common/gin_converters/blink_converter.h"
+#include "shell/common/gin_converters/value_converter.h"
 #include "shell/common/node_bindings.h"
 #include "shell/common/node_includes.h"
 #include "shell/common/promise_util.h"
@@ -75,7 +75,7 @@ class IPCRenderer : public gin::Wrappable<IPCRenderer> {
             const std::string& channel,
             v8::Local<v8::Value> arguments) {
     blink::CloneableMessage message;
-    if (!mate::ConvertFromV8(isolate, arguments, &message)) {
+    if (!gin::ConvertFromV8(isolate, arguments, &message)) {
       return;
     }
     electron_browser_ptr_->get()->Message(internal, channel,
@@ -87,7 +87,7 @@ class IPCRenderer : public gin::Wrappable<IPCRenderer> {
                                 const std::string& channel,
                                 v8::Local<v8::Value> arguments) {
     blink::CloneableMessage message;
-    if (!mate::ConvertFromV8(isolate, arguments, &message)) {
+    if (!gin::ConvertFromV8(isolate, arguments, &message)) {
       return v8::Local<v8::Promise>();
     }
     electron::util::Promise<blink::CloneableMessage> p(isolate);
@@ -110,7 +110,7 @@ class IPCRenderer : public gin::Wrappable<IPCRenderer> {
               const std::string& channel,
               v8::Local<v8::Value> arguments) {
     blink::CloneableMessage message;
-    if (!mate::ConvertFromV8(isolate, arguments, &message)) {
+    if (!gin::ConvertFromV8(isolate, arguments, &message)) {
       return;
     }
     electron_browser_ptr_->get()->MessageTo(
@@ -121,7 +121,7 @@ class IPCRenderer : public gin::Wrappable<IPCRenderer> {
                   const std::string& channel,
                   v8::Local<v8::Value> arguments) {
     blink::CloneableMessage message;
-    if (!mate::ConvertFromV8(isolate, arguments, &message)) {
+    if (!gin::ConvertFromV8(isolate, arguments, &message)) {
       return;
     }
     electron_browser_ptr_->get()->MessageHost(channel, std::move(message));
@@ -132,7 +132,7 @@ class IPCRenderer : public gin::Wrappable<IPCRenderer> {
                                    const std::string& channel,
                                    v8::Local<v8::Value> arguments) {
     blink::CloneableMessage message;
-    if (!mate::ConvertFromV8(isolate, arguments, &message)) {
+    if (!gin::ConvertFromV8(isolate, arguments, &message)) {
       return blink::CloneableMessage();
     }
     // We aren't using a true synchronous mojo call here. We're calling an

+ 10 - 10
shell/renderer/api/atom_api_spell_check_client.cc

@@ -16,10 +16,8 @@
 #include "base/numerics/safe_conversions.h"
 #include "base/threading/thread_task_runner_handle.h"
 #include "components/spellcheck/renderer/spellcheck_worditerator.h"
-#include "native_mate/converter.h"
-#include "native_mate/dictionary.h"
-#include "native_mate/function_template.h"
-#include "shell/common/native_mate_converters/string16_converter.h"
+#include "shell/common/gin_helper/dictionary.h"
+#include "shell/common/gin_helper/function_template.h"
 #include "third_party/blink/public/web/web_text_checking_completion.h"
 #include "third_party/blink/public/web/web_text_checking_result.h"
 #include "third_party/icu/source/common/unicode/uscript.h"
@@ -84,8 +82,9 @@ SpellCheckClient::SpellCheckClient(const std::string& language,
   character_attributes_.SetDefaultLanguage(language);
 
   // Persistent the method.
-  mate::Dictionary dict(isolate, provider);
-  dict.Get("spellCheck", &spell_check_);
+  v8::Local<v8::Function> spell_check;
+  gin_helper::Dictionary(isolate, provider).Get("spellCheck", &spell_check);
+  spell_check_.Reset(isolate, spell_check);
 }
 
 SpellCheckClient::~SpellCheckClient() {
@@ -221,12 +220,12 @@ void SpellCheckClient::SpellCheckWords(const SpellCheckScope& scope,
                                        const std::set<base::string16>& words) {
   DCHECK(!scope.spell_check_.IsEmpty());
 
-  v8::Local<v8::FunctionTemplate> templ = mate::CreateFunctionTemplate(
+  v8::Local<v8::FunctionTemplate> templ = gin_helper::CreateFunctionTemplate(
       isolate_,
       base::BindRepeating(&SpellCheckClient::OnSpellCheckDone, AsWeakPtr()));
 
   auto context = isolate_->GetCurrentContext();
-  v8::Local<v8::Value> args[] = {mate::ConvertToV8(isolate_, words),
+  v8::Local<v8::Value> args[] = {gin::ConvertToV8(isolate_, words),
                                  templ->GetFunction(context).ToLocalChecked()};
   // Call javascript with the words and the callback function
   scope.spell_check_->Call(context, scope.provider_, 2, args).IsEmpty();
@@ -267,8 +266,9 @@ SpellCheckClient::SpellCheckScope::SpellCheckScope(
     : handle_scope_(client.isolate_),
       context_scope_(
           v8::Local<v8::Context>::New(client.isolate_, client.context_)),
-      provider_(client.provider_.NewHandle()),
-      spell_check_(client.spell_check_.NewHandle()) {}
+      provider_(v8::Local<v8::Object>::New(client.isolate_, client.provider_)),
+      spell_check_(
+          v8::Local<v8::Function>::New(client.isolate_, client.spell_check_)) {}
 
 SpellCheckClient::SpellCheckScope::~SpellCheckScope() = default;
 

+ 4 - 4
shell/renderer/api/atom_api_spell_check_client.h

@@ -13,10 +13,10 @@
 #include "base/callback.h"
 #include "base/memory/weak_ptr.h"
 #include "components/spellcheck/renderer/spellcheck_worditerator.h"
-#include "native_mate/scoped_persistent.h"
 #include "third_party/blink/public/platform/web_spell_check_panel_host_client.h"
 #include "third_party/blink/public/platform/web_vector.h"
 #include "third_party/blink/public/web/web_text_check_client.h"
+#include "v8/include/v8.h"
 
 namespace blink {
 struct WebTextCheckingResult;
@@ -100,9 +100,9 @@ class SpellCheckClient : public blink::WebSpellCheckPanelHostClient,
   std::unique_ptr<SpellcheckRequest> pending_request_param_;
 
   v8::Isolate* isolate_;
-  v8::Persistent<v8::Context> context_;
-  mate::ScopedPersistent<v8::Object> provider_;
-  mate::ScopedPersistent<v8::Function> spell_check_;
+  v8::Global<v8::Context> context_;
+  v8::Global<v8::Object> provider_;
+  v8::Global<v8::Function> spell_check_;
 
   DISALLOW_COPY_AND_ASSIGN(SpellCheckClient);
 };

+ 14 - 15
shell/renderer/api/atom_api_web_frame.cc

@@ -12,11 +12,10 @@
 #include "content/public/renderer/render_frame_observer.h"
 #include "content/public/renderer/render_frame_visitor.h"
 #include "content/public/renderer/render_view.h"
-#include "native_mate/dictionary.h"
 #include "services/service_manager/public/cpp/interface_provider.h"
 #include "shell/common/api/api.mojom.h"
-#include "shell/common/native_mate_converters/blink_converter.h"
-#include "shell/common/native_mate_converters/string16_converter.h"
+#include "shell/common/gin_converters/blink_converter.h"
+#include "shell/common/gin_helper/dictionary.h"
 #include "shell/common/node_includes.h"
 #include "shell/common/promise_util.h"
 #include "shell/renderer/api/atom_api_spell_check_client.h"
@@ -36,7 +35,7 @@
 #include "third_party/blink/public/web/web_view.h"
 #include "url/url_util.h"
 
-namespace mate {
+namespace gin {
 
 template <>
 struct Converter<blink::WebLocalFrame::ScriptExecutionType> {
@@ -78,7 +77,7 @@ struct Converter<blink::WebDocument::CSSOrigin> {
   }
 };
 
-}  // namespace mate
+}  // namespace gin
 
 namespace electron {
 
@@ -308,12 +307,12 @@ int GetWebFrameId(v8::Local<v8::Value> window,
   return render_frame->GetRoutingID();
 }
 
-void SetSpellCheckProvider(mate::Arguments* args,
+void SetSpellCheckProvider(gin_helper::Arguments* args,
                            v8::Local<v8::Value> window,
                            const std::string& language,
                            v8::Local<v8::Object> provider) {
   auto context = args->isolate()->GetCurrentContext();
-  if (!provider->Has(context, mate::StringToV8(args->isolate(), "spellCheck"))
+  if (!provider->Has(context, gin::StringToV8(args->isolate(), "spellCheck"))
            .ToChecked()) {
     args->ThrowError("\"spellCheck\" has to be defined");
     return;
@@ -349,11 +348,11 @@ void InsertText(v8::Local<v8::Value> window, const std::string& text) {
 
 base::string16 InsertCSS(v8::Local<v8::Value> window,
                          const std::string& css,
-                         mate::Arguments* args) {
+                         gin_helper::Arguments* args) {
   blink::WebDocument::CSSOrigin css_origin =
       blink::WebDocument::CSSOrigin::kAuthorOrigin;
 
-  mate::Dictionary options;
+  gin_helper::Dictionary options;
   if (args->GetNext(&options))
     options.Get("cssOrigin", &css_origin);
 
@@ -375,7 +374,7 @@ void RemoveInsertedCSS(v8::Local<v8::Value> window, const base::string16& key) {
   }
 }
 
-v8::Local<v8::Promise> ExecuteJavaScript(mate::Arguments* args,
+v8::Local<v8::Promise> ExecuteJavaScript(gin_helper::Arguments* args,
                                          v8::Local<v8::Value> window,
                                          const base::string16& code) {
   v8::Isolate* isolate = args->isolate();
@@ -393,10 +392,10 @@ v8::Local<v8::Promise> ExecuteJavaScript(mate::Arguments* args,
 }
 
 v8::Local<v8::Promise> ExecuteJavaScriptInIsolatedWorld(
-    mate::Arguments* args,
+    gin_helper::Arguments* args,
     v8::Local<v8::Value> window,
     int world_id,
-    const std::vector<mate::Dictionary>& scripts) {
+    const std::vector<gin_helper::Dictionary>& scripts) {
   v8::Isolate* isolate = args->isolate();
   util::Promise<v8::Local<v8::Value>> promise(isolate);
   v8::Local<v8::Promise> handle = promise.GetHandle();
@@ -439,8 +438,8 @@ v8::Local<v8::Promise> ExecuteJavaScriptInIsolatedWorld(
 
 void SetIsolatedWorldInfo(v8::Local<v8::Value> window,
                           int world_id,
-                          const mate::Dictionary& options,
-                          mate::Arguments* args) {
+                          const gin_helper::Dictionary& options,
+                          gin_helper::Arguments* args) {
   std::string origin_url, security_policy, name;
   options.Get("securityOrigin", &origin_url);
   options.Get("csp", &security_policy);
@@ -574,7 +573,7 @@ void Initialize(v8::Local<v8::Object> exports,
   using namespace electron::api;  // NOLINT(build/namespaces)
 
   v8::Isolate* isolate = context->GetIsolate();
-  mate::Dictionary dict(isolate, exports);
+  gin_helper::Dictionary dict(isolate, exports);
   dict.SetMethod("setName", &SetName);
   dict.SetMethod("setZoomLevel", &SetZoomLevel);
   dict.SetMethod("getZoomLevel", &GetZoomLevel);

+ 9 - 14
shell/renderer/atom_sandboxed_renderer_client.cc

@@ -11,13 +11,9 @@
 #include "base/process/process_handle.h"
 #include "content/public/renderer/render_frame.h"
 #include "electron/buildflags/buildflags.h"
-#include "gin/converter.h"
-#include "native_mate/dictionary.h"
 #include "shell/common/api/electron_bindings.h"
 #include "shell/common/application_info.h"
 #include "shell/common/gin_helper/dictionary.h"
-#include "shell/common/native_mate_converters/string16_converter.h"
-#include "shell/common/native_mate_converters/value_converter.h"
 #include "shell/common/node_bindings.h"
 #include "shell/common/node_includes.h"
 #include "shell/common/node_util.h"
@@ -60,10 +56,10 @@ v8::Local<v8::Object> GetModuleCache(v8::Isolate* isolate) {
 // adapted from node.cc
 v8::Local<v8::Value> GetBinding(v8::Isolate* isolate,
                                 v8::Local<v8::String> key,
-                                mate::Arguments* margs) {
+                                gin_helper::Arguments* margs) {
   v8::Local<v8::Object> exports;
   std::string module_key = gin::V8ToString(isolate, key);
-  mate::Dictionary cache(isolate, GetModuleCache(isolate));
+  gin_helper::Dictionary cache(isolate, GetModuleCache(isolate));
 
   if (cache.Get(module_key.c_str(), &exports)) {
     return exports;
@@ -97,9 +93,8 @@ void InvokeHiddenCallback(v8::Handle<v8::Context> context,
                           const std::string& hidden_key,
                           const std::string& callback_name) {
   auto* isolate = context->GetIsolate();
-  auto binding_key = mate::ConvertToV8(isolate, hidden_key)
-                         ->ToString(context)
-                         .ToLocalChecked();
+  auto binding_key =
+      gin::ConvertToV8(isolate, hidden_key)->ToString(context).ToLocalChecked();
   auto private_binding_key = v8::Private::ForApi(isolate, binding_key);
   auto global_object = context->Global();
   v8::Local<v8::Value> value;
@@ -108,7 +103,7 @@ void InvokeHiddenCallback(v8::Handle<v8::Context> context,
   if (value.IsEmpty() || !value->IsObject())
     return;
   auto binding = value->ToObject(context).ToLocalChecked();
-  auto callback_key = mate::ConvertToV8(isolate, callback_name)
+  auto callback_key = gin::ConvertToV8(isolate, callback_name)
                           ->ToString(context)
                           .ToLocalChecked();
   auto callback_value = binding->Get(context, callback_key).ToLocalChecked();
@@ -132,11 +127,11 @@ void AtomSandboxedRendererClient::InitializeBindings(
     v8::Local<v8::Context> context,
     bool is_main_frame) {
   auto* isolate = context->GetIsolate();
-  mate::Dictionary b(isolate, binding);
+  gin_helper::Dictionary b(isolate, binding);
   b.SetMethod("get", GetBinding);
   b.SetMethod("createPreloadScript", CreatePreloadScript);
 
-  mate::Dictionary process = mate::Dictionary::CreateEmpty(isolate);
+  gin_helper::Dictionary process = gin::Dictionary::CreateEmpty(isolate);
   b.Set("process", process);
 
   ElectronBindings::BindProcess(isolate, &process, metrics_.get());
@@ -248,7 +243,7 @@ void AtomSandboxedRendererClient::SetupMainWorldOverrides(
   // an argument.
   auto* isolate = context->GetIsolate();
 
-  mate::Dictionary process = mate::Dictionary::CreateEmpty(isolate);
+  gin_helper::Dictionary process = gin::Dictionary::CreateEmpty(isolate);
   process.SetMethod("_linkedBinding", GetBinding);
 
   std::vector<v8::Local<v8::String>> isolated_bundle_params = {
@@ -272,7 +267,7 @@ void AtomSandboxedRendererClient::SetupExtensionWorldOverrides(
 #else
   auto* isolate = context->GetIsolate();
 
-  mate::Dictionary process = mate::Dictionary::CreateEmpty(isolate);
+  gin_helper::Dictionary process = gin::Dictionary::CreateEmpty(isolate);
   process.SetMethod("_linkedBinding", GetBinding);
 
   std::vector<v8::Local<v8::String>> isolated_bundle_params = {

+ 2 - 2
shell/renderer/electron_api_service_impl.cc

@@ -13,8 +13,8 @@
 #include "base/threading/thread_restrictions.h"
 #include "mojo/public/cpp/system/platform_handle.h"
 #include "shell/common/atom_constants.h"
-#include "shell/common/gin_converters/blink_converter_gin_adapter.h"
-#include "shell/common/gin_converters/value_converter_gin_adapter.h"
+#include "shell/common/gin_converters/blink_converter.h"
+#include "shell/common/gin_converters/value_converter.h"
 #include "shell/common/heap_snapshot.h"
 #include "shell/common/node_includes.h"
 #include "shell/common/options_switches.h"

+ 0 - 1
shell/renderer/renderer_client_base.cc

@@ -22,7 +22,6 @@
 #include "printing/buildflags/buildflags.h"
 #include "shell/common/color_util.h"
 #include "shell/common/gin_helper/dictionary.h"
-#include "shell/common/native_mate_converters/value_converter.h"
 #include "shell/common/options_switches.h"
 #include "shell/renderer/atom_autofill_agent.h"
 #include "shell/renderer/atom_render_frame_observer.h"