refactor: move native window gin converter (#19577)

* move native window gin converter

* extract to new file
This commit is contained in:
Micha Hanselmann 2019-08-09 13:43:18 -07:00 committed by Shelley Vohr
parent 7861e9f728
commit 57507ca37c
10 changed files with 67 additions and 36 deletions

View file

@ -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",

View file

@ -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"

View file

@ -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"

View file

@ -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"

View file

@ -261,28 +261,4 @@ class TopLevelWindow : public mate::TrackableObject<TopLevelWindow>,
} // namespace electron
namespace mate {
template <>
struct Converter<electron::NativeWindow*> {
static bool FromV8(v8::Isolate* isolate,
v8::Local<v8::Value> val,
electron::NativeWindow** out) {
// null would be tranfered to NULL.
if (val->IsNull()) {
*out = NULL;
return true;
}
electron::api::TopLevelWindow* window;
if (!Converter<electron::api::TopLevelWindow*>::FromV8(isolate, val,
&window))
return false;
*out = window->window();
return true;
}
};
} // namespace mate
#endif // SHELL_BROWSER_API_ATOM_API_TOP_LEVEL_WINDOW_H_

View file

@ -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 {

View file

@ -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<electron::NativeWindow*> {
static bool FromV8(v8::Isolate* isolate,
v8::Local<v8::Value> val,
electron::NativeWindow** out) {
return mate::ConvertFromV8(isolate, val, out);
}
};
template <>
struct Converter<electron::MessageBoxSettings> {
static bool FromV8(v8::Isolate* isolate,

View file

@ -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<electron::NativeWindow*> {
static bool FromV8(v8::Isolate* isolate,
v8::Local<v8::Value> 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<electron::api::TopLevelWindow*>::FromV8(isolate, val,
&window))
return false;
*out = window->window();
return true;
}
};
} // namespace gin
#endif // SHELL_COMMON_GIN_CONVERTERS_NATIVE_WINDOW_CONVERTER_H_

View file

@ -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 {

View file

@ -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<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_