diff --git a/filenames.gni b/filenames.gni index 5410f092faa..36b85eebb05 100644 --- a/filenames.gni +++ b/filenames.gni @@ -471,6 +471,7 @@ filenames = { "shell/common/gin_converters/image_converter_gin_adapter.h", "shell/common/gin_converters/message_box_converter.cc", "shell/common/gin_converters/message_box_converter.h", + "shell/common/gin_converters/native_window_converter.h", "shell/common/gin_converters/net_converter_gin_adapter.h", "shell/common/gin_converters/string16_converter.h", "shell/common/gin_util.h", @@ -502,6 +503,7 @@ filenames = { "shell/common/native_mate_converters/image_converter.cc", "shell/common/native_mate_converters/image_converter.h", "shell/common/native_mate_converters/map_converter.h", + "shell/common/native_mate_converters/native_window_converter.h", "shell/common/native_mate_converters/net_converter.cc", "shell/common/native_mate_converters/net_converter.h", "shell/common/native_mate_converters/network_converter.cc", diff --git a/shell/browser/api/atom_api_dialog.cc b/shell/browser/api/atom_api_dialog.cc index 48328976e6a..abdc4bb896c 100644 --- a/shell/browser/api/atom_api_dialog.cc +++ b/shell/browser/api/atom_api_dialog.cc @@ -13,6 +13,7 @@ #include "shell/common/api/gin_utils.h" #include "shell/common/gin_converters/file_dialog_converter_gin_adapter.h" #include "shell/common/gin_converters/message_box_converter.h" +#include "shell/common/gin_converters/native_window_converter.h" #include "shell/common/gin_converters/net_converter_gin_adapter.h" #include "shell/common/node_includes.h" #include "shell/common/promise_util.h" diff --git a/shell/browser/api/atom_api_screen.cc b/shell/browser/api/atom_api_screen.cc index 4ce35048806..5131b06fa01 100644 --- a/shell/browser/api/atom_api_screen.cc +++ b/shell/browser/api/atom_api_screen.cc @@ -10,9 +10,9 @@ #include "base/bind.h" #include "native_mate/dictionary.h" #include "native_mate/object_template_builder.h" -#include "shell/browser/api/atom_api_browser_window.h" #include "shell/browser/browser.h" #include "shell/common/native_mate_converters/gfx_converter.h" +#include "shell/common/native_mate_converters/native_window_converter.h" #include "shell/common/node_includes.h" #include "ui/display/display.h" #include "ui/display/screen.h" diff --git a/shell/browser/api/atom_api_top_level_window.cc b/shell/browser/api/atom_api_top_level_window.cc index f8101f92a15..372d9f2e0e2 100644 --- a/shell/browser/api/atom_api_top_level_window.cc +++ b/shell/browser/api/atom_api_top_level_window.cc @@ -20,6 +20,7 @@ #include "shell/common/native_mate_converters/file_path_converter.h" #include "shell/common/native_mate_converters/gfx_converter.h" #include "shell/common/native_mate_converters/image_converter.h" +#include "shell/common/native_mate_converters/native_window_converter.h" #include "shell/common/native_mate_converters/string16_converter.h" #include "shell/common/native_mate_converters/value_converter.h" #include "shell/common/node_includes.h" diff --git a/shell/browser/api/atom_api_top_level_window.h b/shell/browser/api/atom_api_top_level_window.h index 84b1f10c934..02c79a95fd5 100644 --- a/shell/browser/api/atom_api_top_level_window.h +++ b/shell/browser/api/atom_api_top_level_window.h @@ -261,28 +261,4 @@ class TopLevelWindow : public mate::TrackableObject, } // namespace electron -namespace mate { - -template <> -struct Converter { - static bool FromV8(v8::Isolate* isolate, - v8::Local val, - electron::NativeWindow** out) { - // null would be tranfered to NULL. - if (val->IsNull()) { - *out = NULL; - return true; - } - - electron::api::TopLevelWindow* window; - if (!Converter::FromV8(isolate, val, - &window)) - return false; - *out = window->window(); - return true; - } -}; - -} // namespace mate - #endif // SHELL_BROWSER_API_ATOM_API_TOP_LEVEL_WINDOW_H_ diff --git a/shell/common/gin_converters/message_box_converter.cc b/shell/common/gin_converters/message_box_converter.cc index 7653b1bdac7..ac357634c25 100644 --- a/shell/common/gin_converters/message_box_converter.cc +++ b/shell/common/gin_converters/message_box_converter.cc @@ -6,6 +6,7 @@ #include "gin/dictionary.h" #include "shell/common/gin_converters/image_converter_gin_adapter.h" +#include "shell/common/gin_converters/native_window_converter.h" namespace gin { diff --git a/shell/common/gin_converters/message_box_converter.h b/shell/common/gin_converters/message_box_converter.h index c301728d45a..15ed2516d44 100644 --- a/shell/common/gin_converters/message_box_converter.h +++ b/shell/common/gin_converters/message_box_converter.h @@ -6,21 +6,10 @@ #define SHELL_COMMON_GIN_CONVERTERS_MESSAGE_BOX_CONVERTER_H_ #include "gin/converter.h" -#include "shell/browser/api/atom_api_browser_window.h" #include "shell/browser/ui/message_box.h" namespace gin { -// TODO(deermichel): remove adapter after removing mate -template <> -struct Converter { - static bool FromV8(v8::Isolate* isolate, - v8::Local val, - electron::NativeWindow** out) { - return mate::ConvertFromV8(isolate, val, out); - } -}; - template <> struct Converter { static bool FromV8(v8::Isolate* isolate, diff --git a/shell/common/gin_converters/native_window_converter.h b/shell/common/gin_converters/native_window_converter.h new file mode 100644 index 00000000000..cb1d3b12860 --- /dev/null +++ b/shell/common/gin_converters/native_window_converter.h @@ -0,0 +1,36 @@ +// 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_NATIVE_WINDOW_CONVERTER_H_ +#define SHELL_COMMON_GIN_CONVERTERS_NATIVE_WINDOW_CONVERTER_H_ + +#include "gin/converter.h" +#include "shell/browser/api/atom_api_top_level_window.h" + +namespace gin { + +template <> +struct Converter { + static bool FromV8(v8::Isolate* isolate, + v8::Local val, + electron::NativeWindow** out) { + // null would be tranfered to NULL. + if (val->IsNull()) { + *out = NULL; + return true; + } + + electron::api::TopLevelWindow* window; + // TODO(deermichel): remove mate:: after dropping mate + if (!mate::Converter::FromV8(isolate, val, + &window)) + return false; + *out = window->window(); + return true; + } +}; + +} // namespace gin + +#endif // SHELL_COMMON_GIN_CONVERTERS_NATIVE_WINDOW_CONVERTER_H_ diff --git a/shell/common/native_mate_converters/file_dialog_converter.cc b/shell/common/native_mate_converters/file_dialog_converter.cc index fc809623d92..f43c96e545d 100644 --- a/shell/common/native_mate_converters/file_dialog_converter.cc +++ b/shell/common/native_mate_converters/file_dialog_converter.cc @@ -8,6 +8,7 @@ #include "shell/browser/api/atom_api_browser_window.h" #include "shell/browser/ui/file_dialog.h" #include "shell/common/native_mate_converters/file_path_converter.h" +#include "shell/common/native_mate_converters/native_window_converter.h" namespace mate { diff --git a/shell/common/native_mate_converters/native_window_converter.h b/shell/common/native_mate_converters/native_window_converter.h new file mode 100644 index 00000000000..454fd68aefe --- /dev/null +++ b/shell/common/native_mate_converters/native_window_converter.h @@ -0,0 +1,24 @@ +// 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 { + static bool FromV8(v8::Isolate* isolate, + v8::Local val, + electron::NativeWindow** out) { + return gin::ConvertFromV8(isolate, val, out); + } +}; + +} // namespace mate + +#endif // SHELL_COMMON_NATIVE_MATE_CONVERTERS_NATIVE_WINDOW_CONVERTER_H_