chore: move gin::Handle to gin_helper (#47959)

* chore: move gin::Handle to gin_helper

* chore: fix lint
This commit is contained in:
Robo 2025-08-05 02:03:06 +09:00 committed by GitHub
commit 4ca10a1056
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
95 changed files with 555 additions and 419 deletions

View file

@ -653,6 +653,7 @@ filenames = {
"shell/common/gin_helper/function_template.cc", "shell/common/gin_helper/function_template.cc",
"shell/common/gin_helper/function_template.h", "shell/common/gin_helper/function_template.h",
"shell/common/gin_helper/function_template_extensions.h", "shell/common/gin_helper/function_template_extensions.h",
"shell/common/gin_helper/handle.h",
"shell/common/gin_helper/locker.cc", "shell/common/gin_helper/locker.cc",
"shell/common/gin_helper/locker.h", "shell/common/gin_helper/locker.h",
"shell/common/gin_helper/object_template_builder.cc", "shell/common/gin_helper/object_template_builder.cc",

View file

@ -41,7 +41,6 @@
#include "content/public/browser/render_frame_host.h" #include "content/public/browser/render_frame_host.h"
#include "crypto/crypto_buildflags.h" #include "crypto/crypto_buildflags.h"
#include "electron/mas.h" #include "electron/mas.h"
#include "gin/handle.h"
#include "media/audio/audio_manager.h" #include "media/audio/audio_manager.h"
#include "net/dns/public/dns_over_https_config.h" #include "net/dns/public/dns_over_https_config.h"
#include "net/dns/public/dns_over_https_server_config.h" #include "net/dns/public/dns_over_https_server_config.h"
@ -76,6 +75,7 @@
#include "shell/common/gin_converters/value_converter.h" #include "shell/common/gin_converters/value_converter.h"
#include "shell/common/gin_helper/dictionary.h" #include "shell/common/gin_helper/dictionary.h"
#include "shell/common/gin_helper/error_thrower.h" #include "shell/common/gin_helper/error_thrower.h"
#include "shell/common/gin_helper/handle.h"
#include "shell/common/gin_helper/object_template_builder.h" #include "shell/common/gin_helper/object_template_builder.h"
#include "shell/common/language_util.h" #include "shell/common/language_util.h"
#include "shell/common/node_includes.h" #include "shell/common/node_includes.h"
@ -1701,8 +1701,8 @@ App* App::Get() {
} }
// static // static
gin::Handle<App> App::Create(v8::Isolate* isolate) { gin_helper::Handle<App> App::Create(v8::Isolate* isolate) {
return gin::CreateHandle(isolate, Get()); return gin_helper::CreateHandle(isolate, Get());
} }
gin::ObjectTemplateBuilder App::GetObjectTemplateBuilder(v8::Isolate* isolate) { gin::ObjectTemplateBuilder App::GetObjectTemplateBuilder(v8::Isolate* isolate) {

View file

@ -37,14 +37,11 @@ namespace base {
class FilePath; class FilePath;
} }
namespace gin {
template <typename T>
class Handle;
} // namespace gin
namespace gin_helper { namespace gin_helper {
class Dictionary; class Dictionary;
class ErrorThrower; class ErrorThrower;
template <typename T>
class Handle;
} // namespace gin_helper } // namespace gin_helper
namespace electron { namespace electron {
@ -64,7 +61,7 @@ class App final : public ElectronBrowserClient::Delegate,
private content::GpuDataManagerObserver, private content::GpuDataManagerObserver,
private content::BrowserChildProcessObserver { private content::BrowserChildProcessObserver {
public: public:
static gin::Handle<App> Create(v8::Isolate* isolate); static gin_helper::Handle<App> Create(v8::Isolate* isolate);
static App* Get(); static App* Get();
// gin_helper::Wrappable // gin_helper::Wrappable

View file

@ -5,7 +5,6 @@
#include "shell/browser/api/electron_api_auto_updater.h" #include "shell/browser/api/electron_api_auto_updater.h"
#include "base/time/time.h" #include "base/time/time.h"
#include "gin/handle.h"
#include "shell/browser/javascript_environment.h" #include "shell/browser/javascript_environment.h"
#include "shell/browser/native_window.h" #include "shell/browser/native_window.h"
#include "shell/browser/window_list.h" #include "shell/browser/window_list.h"
@ -13,6 +12,7 @@
#include "shell/common/gin_converters/time_converter.h" #include "shell/common/gin_converters/time_converter.h"
#include "shell/common/gin_helper/dictionary.h" #include "shell/common/gin_helper/dictionary.h"
#include "shell/common/gin_helper/event_emitter_caller.h" #include "shell/common/gin_helper/event_emitter_caller.h"
#include "shell/common/gin_helper/handle.h"
#include "shell/common/gin_helper/object_template_builder.h" #include "shell/common/gin_helper/object_template_builder.h"
#include "shell/common/node_includes.h" #include "shell/common/node_includes.h"
@ -120,8 +120,8 @@ void AutoUpdater::QuitAndInstall() {
} }
// static // static
gin::Handle<AutoUpdater> AutoUpdater::Create(v8::Isolate* isolate) { gin_helper::Handle<AutoUpdater> AutoUpdater::Create(v8::Isolate* isolate) {
return gin::CreateHandle(isolate, new AutoUpdater()); return gin_helper::CreateHandle(isolate, new AutoUpdater());
} }
gin::ObjectTemplateBuilder AutoUpdater::GetObjectTemplateBuilder( gin::ObjectTemplateBuilder AutoUpdater::GetObjectTemplateBuilder(

View file

@ -12,10 +12,10 @@
#include "shell/browser/window_list_observer.h" #include "shell/browser/window_list_observer.h"
#include "shell/common/gin_helper/wrappable.h" #include "shell/common/gin_helper/wrappable.h"
namespace gin { namespace gin_helper {
template <typename T> template <typename T>
class Handle; class Handle;
} // namespace gin } // namespace gin_helper
namespace electron::api { namespace electron::api {
@ -24,7 +24,7 @@ class AutoUpdater final : public gin_helper::DeprecatedWrappable<AutoUpdater>,
public auto_updater::Delegate, public auto_updater::Delegate,
private WindowListObserver { private WindowListObserver {
public: public:
static gin::Handle<AutoUpdater> Create(v8::Isolate* isolate); static gin_helper::Handle<AutoUpdater> Create(v8::Isolate* isolate);
// gin_helper::Wrappable // gin_helper::Wrappable
static gin::DeprecatedWrapperInfo kWrapperInfo; static gin::DeprecatedWrapperInfo kWrapperInfo;

View file

@ -13,7 +13,6 @@
#include "content/public/common/color_parser.h" #include "content/public/common/color_parser.h"
#include "electron/buildflags/buildflags.h" #include "electron/buildflags/buildflags.h"
#include "gin/dictionary.h" #include "gin/dictionary.h"
#include "gin/handle.h"
#include "shell/browser/api/electron_api_menu.h" #include "shell/browser/api/electron_api_menu.h"
#include "shell/browser/api/electron_api_view.h" #include "shell/browser/api/electron_api_view.h"
#include "shell/browser/api/electron_api_web_contents.h" #include "shell/browser/api/electron_api_web_contents.h"
@ -28,6 +27,7 @@
#include "shell/common/gin_converters/optional_converter.h" #include "shell/common/gin_converters/optional_converter.h"
#include "shell/common/gin_converters/value_converter.h" #include "shell/common/gin_converters/value_converter.h"
#include "shell/common/gin_helper/dictionary.h" #include "shell/common/gin_helper/dictionary.h"
#include "shell/common/gin_helper/handle.h"
#include "shell/common/gin_helper/object_template_builder.h" #include "shell/common/gin_helper/object_template_builder.h"
#include "shell/common/gin_helper/persistent_dictionary.h" #include "shell/common/gin_helper/persistent_dictionary.h"
#include "shell/common/node_includes.h" #include "shell/common/node_includes.h"
@ -96,7 +96,7 @@ v8::Local<v8::Value> ToBuffer(v8::Isolate* isolate,
BaseWindow::BaseWindow(v8::Isolate* isolate, BaseWindow::BaseWindow(v8::Isolate* isolate,
const gin_helper::Dictionary& options) { const gin_helper::Dictionary& options) {
// The parent window. // The parent window.
gin::Handle<BaseWindow> parent; gin_helper::Handle<BaseWindow> parent;
if (options.Get("parent", &parent) && !parent.IsEmpty()) if (options.Get("parent", &parent) && !parent.IsEmpty())
parent_window_.Reset(isolate, parent.ToV8()); parent_window_.Reset(isolate, parent.ToV8());
@ -150,7 +150,7 @@ void BaseWindow::InitWith(v8::Isolate* isolate, v8::Local<v8::Object> wrapper) {
// We can only append this window to parent window's child windows after this // We can only append this window to parent window's child windows after this
// window's JS wrapper gets initialized. // window's JS wrapper gets initialized.
if (!parent_window_.IsEmpty()) { if (!parent_window_.IsEmpty()) {
gin::Handle<BaseWindow> parent; gin_helper::Handle<BaseWindow> parent;
gin::ConvertFromV8(isolate, GetParentWindow(), &parent); gin::ConvertFromV8(isolate, GetParentWindow(), &parent);
DCHECK(!parent.IsEmpty()); DCHECK(!parent.IsEmpty());
parent->child_windows_.Set(isolate, weak_map_id(), wrapper); parent->child_windows_.Set(isolate, weak_map_id(), wrapper);
@ -194,7 +194,7 @@ void BaseWindow::OnWindowQueryEndSession(
v8::Isolate* isolate = JavascriptEnvironment::GetIsolate(); v8::Isolate* isolate = JavascriptEnvironment::GetIsolate();
v8::HandleScope handle_scope(isolate); v8::HandleScope handle_scope(isolate);
gin::Handle<gin_helper::internal::Event> event = gin_helper::Handle<gin_helper::internal::Event> event =
gin_helper::internal::Event::New(isolate); gin_helper::internal::Event::New(isolate);
v8::Local<v8::Object> event_object = event.ToV8().As<v8::Object>(); v8::Local<v8::Object> event_object = event.ToV8().As<v8::Object>();
@ -211,7 +211,7 @@ void BaseWindow::OnWindowEndSession(const std::vector<std::string>& reasons) {
v8::Isolate* isolate = JavascriptEnvironment::GetIsolate(); v8::Isolate* isolate = JavascriptEnvironment::GetIsolate();
v8::HandleScope handle_scope(isolate); v8::HandleScope handle_scope(isolate);
gin::Handle<gin_helper::internal::Event> event = gin_helper::Handle<gin_helper::internal::Event> event =
gin_helper::internal::Event::New(isolate); gin_helper::internal::Event::New(isolate);
v8::Local<v8::Object> event_object = event.ToV8().As<v8::Object>(); v8::Local<v8::Object> event_object = event.ToV8().As<v8::Object>();
@ -356,7 +356,7 @@ void BaseWindow::OnWindowMessage(UINT message, WPARAM w_param, LPARAM l_param) {
} }
#endif #endif
void BaseWindow::SetContentView(gin::Handle<View> view) { void BaseWindow::SetContentView(gin_helper::Handle<View> view) {
content_view_.Reset(JavascriptEnvironment::GetIsolate(), view.ToV8()); content_view_.Reset(JavascriptEnvironment::GetIsolate(), view.ToV8());
window_->SetContentView(view->view()); window_->SetContentView(view->view());
} }
@ -730,7 +730,7 @@ bool BaseWindow::IsFocusable() const {
void BaseWindow::SetMenu(v8::Isolate* isolate, v8::Local<v8::Value> value) { void BaseWindow::SetMenu(v8::Isolate* isolate, v8::Local<v8::Value> value) {
auto context = isolate->GetCurrentContext(); auto context = isolate->GetCurrentContext();
gin::Handle<Menu> menu; gin_helper::Handle<Menu> menu;
v8::Local<v8::Object> object; v8::Local<v8::Object> object;
if (value->IsObject() && value->ToObject(context).ToLocal(&object) && if (value->IsObject() && value->ToObject(context).ToLocal(&object) &&
gin::ConvertFromV8(isolate, value, &menu) && !menu.IsEmpty()) { gin::ConvertFromV8(isolate, value, &menu) && !menu.IsEmpty()) {
@ -763,7 +763,7 @@ void BaseWindow::SetParentWindow(v8::Local<v8::Value> value,
return; return;
} }
gin::Handle<BaseWindow> parent; gin_helper::Handle<BaseWindow> parent;
if (value->IsNull() || value->IsUndefined()) { if (value->IsNull() || value->IsUndefined()) {
RemoveFromParentChildWindows(); RemoveFromParentChildWindows();
parent_window_.Reset(); parent_window_.Reset();
@ -1132,7 +1132,7 @@ void BaseWindow::RemoveFromParentChildWindows() {
v8::Isolate* isolate = JavascriptEnvironment::GetIsolate(); v8::Isolate* isolate = JavascriptEnvironment::GetIsolate();
v8::HandleScope handle_scope(isolate); v8::HandleScope handle_scope(isolate);
gin::Handle<BaseWindow> parent; gin_helper::Handle<BaseWindow> parent;
if (!gin::ConvertFromV8(isolate, GetParentWindow(), &parent) || if (!gin::ConvertFromV8(isolate, GetParentWindow(), &parent) ||
parent.IsEmpty()) { parent.IsEmpty()) {
return; return;

View file

@ -98,7 +98,7 @@ class BaseWindow : public gin_helper::TrackableObject<BaseWindow>,
#endif #endif
// Public APIs of NativeWindow. // Public APIs of NativeWindow.
void SetContentView(gin::Handle<View> view); void SetContentView(gin_helper::Handle<View> view);
void Close(); void Close();
virtual void CloseImmediately(); virtual void CloseImmediately();
virtual void Focus(); virtual void Focus();

View file

@ -65,14 +65,14 @@ BrowserWindow::BrowserWindow(gin::Arguments* args,
web_preferences.Set(options::kShow, true); web_preferences.Set(options::kShow, true);
// Creates the WebContentsView. // Creates the WebContentsView.
gin::Handle<WebContentsView> web_contents_view = gin_helper::Handle<WebContentsView> web_contents_view =
WebContentsView::Create(isolate, web_preferences); WebContentsView::Create(isolate, web_preferences);
DCHECK(web_contents_view.get()); DCHECK(web_contents_view.get());
window()->AddDraggableRegionProvider(web_contents_view.get()); window()->AddDraggableRegionProvider(web_contents_view.get());
web_contents_view_.Reset(isolate, web_contents_view.ToV8()); web_contents_view_.Reset(isolate, web_contents_view.ToV8());
// Save a reference of the WebContents. // Save a reference of the WebContents.
gin::Handle<WebContents> web_contents = gin_helper::Handle<WebContents> web_contents =
web_contents_view->GetWebContents(isolate); web_contents_view->GetWebContents(isolate);
web_contents_.Reset(isolate, web_contents.ToV8()); web_contents_.Reset(isolate, web_contents.ToV8());
api_web_contents_ = web_contents->GetWeakPtr(); api_web_contents_ = web_contents->GetWeakPtr();
@ -211,7 +211,7 @@ void BrowserWindow::CloseImmediately() {
// Close all child windows before closing current window. // Close all child windows before closing current window.
v8::HandleScope handle_scope(isolate()); v8::HandleScope handle_scope(isolate());
for (v8::Local<v8::Value> value : GetChildWindows()) { for (v8::Local<v8::Value> value : GetChildWindows()) {
gin::Handle<BrowserWindow> child; gin_helper::Handle<BrowserWindow> child;
if (gin::ConvertFromV8(isolate(), value, &child) && !child.IsEmpty()) if (gin::ConvertFromV8(isolate(), value, &child) && !child.IsEmpty())
child->window()->CloseImmediately(); child->window()->CloseImmediately();
} }

View file

@ -17,7 +17,6 @@
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#include "content/public/browser/storage_partition.h" #include "content/public/browser/storage_partition.h"
#include "gin/dictionary.h" #include "gin/dictionary.h"
#include "gin/handle.h"
#include "gin/object_template_builder.h" #include "gin/object_template_builder.h"
#include "net/cookies/canonical_cookie.h" #include "net/cookies/canonical_cookie.h"
#include "net/cookies/cookie_change_dispatcher.h" #include "net/cookies/cookie_change_dispatcher.h"
@ -30,6 +29,7 @@
#include "shell/common/gin_converters/gurl_converter.h" #include "shell/common/gin_converters/gurl_converter.h"
#include "shell/common/gin_converters/value_converter.h" #include "shell/common/gin_converters/value_converter.h"
#include "shell/common/gin_helper/dictionary.h" #include "shell/common/gin_helper/dictionary.h"
#include "shell/common/gin_helper/handle.h"
#include "shell/common/gin_helper/object_template_builder.h" #include "shell/common/gin_helper/object_template_builder.h"
#include "shell/common/gin_helper/promise.h" #include "shell/common/gin_helper/promise.h"
@ -442,9 +442,10 @@ void Cookies::OnCookieChanged(const net::CookieChangeInfo& change) {
} }
// static // static
gin::Handle<Cookies> Cookies::Create(v8::Isolate* isolate, gin_helper::Handle<Cookies> Cookies::Create(
v8::Isolate* isolate,
ElectronBrowserContext* browser_context) { ElectronBrowserContext* browser_context) {
return gin::CreateHandle(isolate, new Cookies{browser_context}); return gin_helper::CreateHandle(isolate, new Cookies{browser_context});
} }
gin::ObjectTemplateBuilder Cookies::GetObjectTemplateBuilder( gin::ObjectTemplateBuilder Cookies::GetObjectTemplateBuilder(

View file

@ -15,13 +15,10 @@
class GURL; class GURL;
namespace gin {
template <typename T>
class Handle;
} // namespace gin
namespace gin_helper { namespace gin_helper {
class Dictionary; class Dictionary;
template <typename T>
class Handle;
} // namespace gin_helper } // namespace gin_helper
namespace net { namespace net {
@ -37,7 +34,8 @@ namespace api {
class Cookies final : public gin_helper::DeprecatedWrappable<Cookies>, class Cookies final : public gin_helper::DeprecatedWrappable<Cookies>,
public gin_helper::EventEmitterMixin<Cookies> { public gin_helper::EventEmitterMixin<Cookies> {
public: public:
static gin::Handle<Cookies> Create(v8::Isolate* isolate, static gin_helper::Handle<Cookies> Create(
v8::Isolate* isolate,
ElectronBrowserContext* browser_context); ElectronBrowserContext* browser_context);
// gin_helper::Wrappable // gin_helper::Wrappable

View file

@ -11,10 +11,10 @@
#include "base/no_destructor.h" #include "base/no_destructor.h"
#include "base/strings/string_number_conversions.h" #include "base/strings/string_number_conversions.h"
#include "base/task/sequenced_task_runner.h" #include "base/task/sequenced_task_runner.h"
#include "gin/handle.h"
#include "mojo/public/cpp/system/data_pipe.h" #include "mojo/public/cpp/system/data_pipe.h"
#include "mojo/public/cpp/system/simple_watcher.h" #include "mojo/public/cpp/system/simple_watcher.h"
#include "net/base/net_errors.h" #include "net/base/net_errors.h"
#include "shell/common/gin_helper/handle.h"
#include "shell/common/gin_helper/promise.h" #include "shell/common/gin_helper/promise.h"
#include "shell/common/key_weak_map.h" #include "shell/common/key_weak_map.h"
#include "shell/common/node_util.h" #include "shell/common/node_util.h"
@ -171,21 +171,21 @@ const char* DataPipeHolder::GetTypeName() {
} }
// static // static
gin::Handle<DataPipeHolder> DataPipeHolder::Create( gin_helper::Handle<DataPipeHolder> DataPipeHolder::Create(
v8::Isolate* isolate, v8::Isolate* isolate,
const network::DataElement& element) { const network::DataElement& element) {
auto handle = gin::CreateHandle(isolate, new DataPipeHolder(element)); auto handle = gin_helper::CreateHandle(isolate, new DataPipeHolder(element));
AllDataPipeHolders().Set(isolate, handle->id(), AllDataPipeHolders().Set(isolate, handle->id(),
handle->GetWrapper(isolate).ToLocalChecked()); handle->GetWrapper(isolate).ToLocalChecked());
return handle; return handle;
} }
// static // static
gin::Handle<DataPipeHolder> DataPipeHolder::From(v8::Isolate* isolate, gin_helper::Handle<DataPipeHolder> DataPipeHolder::From(v8::Isolate* isolate,
const std::string& id) { const std::string& id) {
v8::MaybeLocal<v8::Object> object = AllDataPipeHolders().Get(isolate, id); v8::MaybeLocal<v8::Object> object = AllDataPipeHolders().Get(isolate, id);
if (!object.IsEmpty()) { if (!object.IsEmpty()) {
gin::Handle<DataPipeHolder> handle; gin_helper::Handle<DataPipeHolder> handle;
if (gin::ConvertFromV8(isolate, object.ToLocalChecked(), &handle)) if (gin::ConvertFromV8(isolate, object.ToLocalChecked(), &handle))
return handle; return handle;
} }

View file

@ -12,10 +12,10 @@
#include "services/network/public/mojom/data_pipe_getter.mojom.h" #include "services/network/public/mojom/data_pipe_getter.mojom.h"
#include "shell/common/gin_helper/wrappable.h" #include "shell/common/gin_helper/wrappable.h"
namespace gin { namespace gin_helper {
template <typename T> template <typename T>
class Handle; class Handle;
} // namespace gin } // namespace gin_helper
namespace electron::api { namespace electron::api {
@ -27,10 +27,10 @@ class DataPipeHolder final
static gin::DeprecatedWrapperInfo kWrapperInfo; static gin::DeprecatedWrapperInfo kWrapperInfo;
const char* GetTypeName() override; const char* GetTypeName() override;
static gin::Handle<DataPipeHolder> Create( static gin_helper::Handle<DataPipeHolder> Create(
v8::Isolate* isolate, v8::Isolate* isolate,
const network::DataElement& element); const network::DataElement& element);
static gin::Handle<DataPipeHolder> From(v8::Isolate* isolate, static gin_helper::Handle<DataPipeHolder> From(v8::Isolate* isolate,
const std::string& id); const std::string& id);
// Read all data at once. // Read all data at once.

View file

@ -13,11 +13,11 @@
#include "base/json/json_writer.h" #include "base/json/json_writer.h"
#include "content/public/browser/devtools_agent_host.h" #include "content/public/browser/devtools_agent_host.h"
#include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents.h"
#include "gin/handle.h"
#include "gin/object_template_builder.h" #include "gin/object_template_builder.h"
#include "gin/per_isolate_data.h" #include "gin/per_isolate_data.h"
#include "shell/browser/javascript_environment.h" #include "shell/browser/javascript_environment.h"
#include "shell/common/gin_converters/value_converter.h" #include "shell/common/gin_converters/value_converter.h"
#include "shell/common/gin_helper/handle.h"
#include "shell/common/gin_helper/promise.h" #include "shell/common/gin_helper/promise.h"
using content::DevToolsAgentHost; using content::DevToolsAgentHost;
@ -178,9 +178,10 @@ void Debugger::ClearPendingRequests() {
} }
// static // static
gin::Handle<Debugger> Debugger::Create(v8::Isolate* isolate, gin_helper::Handle<Debugger> Debugger::Create(
v8::Isolate* isolate,
content::WebContents* web_contents) { content::WebContents* web_contents) {
return gin::CreateHandle(isolate, new Debugger(isolate, web_contents)); return gin_helper::CreateHandle(isolate, new Debugger(isolate, web_contents));
} }
gin::ObjectTemplateBuilder Debugger::GetObjectTemplateBuilder( gin::ObjectTemplateBuilder Debugger::GetObjectTemplateBuilder(

View file

@ -37,7 +37,8 @@ class Debugger final : public gin_helper::DeprecatedWrappable<Debugger>,
public content::DevToolsAgentHostClient, public content::DevToolsAgentHostClient,
private content::WebContentsObserver { private content::WebContentsObserver {
public: public:
static gin::Handle<Debugger> Create(v8::Isolate* isolate, static gin_helper::Handle<Debugger> Create(
v8::Isolate* isolate,
content::WebContents* web_contents); content::WebContents* web_contents);
// gin_helper::Wrappable // gin_helper::Wrappable

View file

@ -17,13 +17,13 @@
#include "chrome/browser/media/webrtc/window_icon_util.h" #include "chrome/browser/media/webrtc/window_icon_util.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#include "content/public/browser/desktop_capture.h" #include "content/public/browser/desktop_capture.h"
#include "gin/handle.h"
#include "gin/object_template_builder.h" #include "gin/object_template_builder.h"
#include "shell/browser/javascript_environment.h" #include "shell/browser/javascript_environment.h"
#include "shell/common/api/electron_api_native_image.h" #include "shell/common/api/electron_api_native_image.h"
#include "shell/common/gin_converters/gfx_converter.h" #include "shell/common/gin_converters/gfx_converter.h"
#include "shell/common/gin_helper/dictionary.h" #include "shell/common/gin_helper/dictionary.h"
#include "shell/common/gin_helper/event_emitter_caller.h" #include "shell/common/gin_helper/event_emitter_caller.h"
#include "shell/common/gin_helper/handle.h"
#include "shell/common/node_includes.h" #include "shell/common/node_includes.h"
#include "third_party/webrtc/modules/desktop_capture/desktop_capture_options.h" #include "third_party/webrtc/modules/desktop_capture/desktop_capture_options.h"
#include "third_party/webrtc/modules/desktop_capture/desktop_capturer.h" #include "third_party/webrtc/modules/desktop_capture/desktop_capturer.h"
@ -504,8 +504,9 @@ void DesktopCapturer::HandleFailure() {
} }
// static // static
gin::Handle<DesktopCapturer> DesktopCapturer::Create(v8::Isolate* isolate) { gin_helper::Handle<DesktopCapturer> DesktopCapturer::Create(
auto handle = gin::CreateHandle(isolate, new DesktopCapturer(isolate)); v8::Isolate* isolate) {
auto handle = gin_helper::CreateHandle(isolate, new DesktopCapturer(isolate));
// Keep reference alive until capturing has finished. // Keep reference alive until capturing has finished.
handle->Pin(isolate); handle->Pin(isolate);

View file

@ -14,10 +14,10 @@
#include "shell/common/gin_helper/pinnable.h" #include "shell/common/gin_helper/pinnable.h"
#include "shell/common/gin_helper/wrappable.h" #include "shell/common/gin_helper/wrappable.h"
namespace gin { namespace gin_helper {
template <typename T> template <typename T>
class Handle; class Handle;
} // namespace gin } // namespace gin_helper
namespace electron::api { namespace electron::api {
@ -35,7 +35,7 @@ class DesktopCapturer final
bool fetch_icon = false; bool fetch_icon = false;
}; };
static gin::Handle<DesktopCapturer> Create(v8::Isolate* isolate); static gin_helper::Handle<DesktopCapturer> Create(v8::Isolate* isolate);
static bool IsDisplayMediaSystemPickerAvailable(); static bool IsDisplayMediaSystemPickerAvailable();

View file

@ -7,13 +7,13 @@
#include <memory> #include <memory>
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "gin/handle.h"
#include "net/base/filename_util.h" #include "net/base/filename_util.h"
#include "shell/browser/electron_browser_main_parts.h" #include "shell/browser/electron_browser_main_parts.h"
#include "shell/common/gin_converters/file_dialog_converter.h" #include "shell/common/gin_converters/file_dialog_converter.h"
#include "shell/common/gin_converters/file_path_converter.h" #include "shell/common/gin_converters/file_path_converter.h"
#include "shell/common/gin_converters/gurl_converter.h" #include "shell/common/gin_converters/gurl_converter.h"
#include "shell/common/gin_helper/dictionary.h" #include "shell/common/gin_helper/dictionary.h"
#include "shell/common/gin_helper/handle.h"
#include "shell/common/gin_helper/object_template_builder.h" #include "shell/common/gin_helper/object_template_builder.h"
#include "url/gurl.h" #include "url/gurl.h"
@ -307,14 +307,15 @@ const char* DownloadItem::GetTypeName() {
} }
// static // static
gin::Handle<DownloadItem> DownloadItem::FromOrCreate( gin_helper::Handle<DownloadItem> DownloadItem::FromOrCreate(
v8::Isolate* isolate, v8::Isolate* isolate,
download::DownloadItem* item) { download::DownloadItem* item) {
DownloadItem* existing = FromDownloadItem(item); DownloadItem* existing = FromDownloadItem(item);
if (existing) if (existing)
return gin::CreateHandle(isolate, existing); return gin_helper::CreateHandle(isolate, existing);
auto handle = gin::CreateHandle(isolate, new DownloadItem(isolate, item)); auto handle =
gin_helper::CreateHandle(isolate, new DownloadItem(isolate, item));
handle->Pin(isolate); handle->Pin(isolate);

View file

@ -18,10 +18,10 @@
class GURL; class GURL;
namespace gin { namespace gin_helper {
template <typename T> template <typename T>
class Handle; class Handle;
} // namespace gin } // namespace gin_helper
namespace electron::api { namespace electron::api {
@ -30,7 +30,8 @@ class DownloadItem final : public gin_helper::DeprecatedWrappable<DownloadItem>,
public gin_helper::EventEmitterMixin<DownloadItem>, public gin_helper::EventEmitterMixin<DownloadItem>,
private download::DownloadItem::Observer { private download::DownloadItem::Observer {
public: public:
static gin::Handle<DownloadItem> FromOrCreate(v8::Isolate* isolate, static gin_helper::Handle<DownloadItem> FromOrCreate(
v8::Isolate* isolate,
download::DownloadItem* item); download::DownloadItem* item);
static DownloadItem* FromDownloadItem(download::DownloadItem* item); static DownloadItem* FromDownloadItem(download::DownloadItem* item);

View file

@ -7,7 +7,6 @@
#include "chrome/browser/browser_process.h" #include "chrome/browser/browser_process.h"
#include "extensions/browser/extension_registry.h" #include "extensions/browser/extension_registry.h"
#include "gin/data_object_builder.h" #include "gin/data_object_builder.h"
#include "gin/handle.h"
#include "gin/object_template_builder.h" #include "gin/object_template_builder.h"
#include "shell/browser/api/electron_api_extensions.h" #include "shell/browser/api/electron_api_extensions.h"
#include "shell/browser/electron_browser_context.h" #include "shell/browser/electron_browser_context.h"
@ -18,6 +17,7 @@
#include "shell/common/gin_converters/gurl_converter.h" #include "shell/common/gin_converters/gurl_converter.h"
#include "shell/common/gin_converters/value_converter.h" #include "shell/common/gin_converters/value_converter.h"
#include "shell/common/gin_helper/dictionary.h" #include "shell/common/gin_helper/dictionary.h"
#include "shell/common/gin_helper/handle.h"
#include "shell/common/gin_helper/promise.h" #include "shell/common/gin_helper/promise.h"
#include "shell/common/node_util.h" #include "shell/common/node_util.h"
@ -36,10 +36,11 @@ Extensions::~Extensions() {
} }
// static // static
gin::Handle<Extensions> Extensions::Create( gin_helper::Handle<Extensions> Extensions::Create(
v8::Isolate* isolate, v8::Isolate* isolate,
ElectronBrowserContext* browser_context) { ElectronBrowserContext* browser_context) {
return gin::CreateHandle(isolate, new Extensions(isolate, browser_context)); return gin_helper::CreateHandle(isolate,
new Extensions(isolate, browser_context));
} }
v8::Local<v8::Promise> Extensions::LoadExtension( v8::Local<v8::Promise> Extensions::LoadExtension(

View file

@ -11,10 +11,10 @@
#include "shell/browser/event_emitter_mixin.h" #include "shell/browser/event_emitter_mixin.h"
#include "shell/common/gin_helper/wrappable.h" #include "shell/common/gin_helper/wrappable.h"
namespace gin { namespace gin_helper {
template <typename T> template <typename T>
class Handle; class Handle;
} // namespace gin } // namespace gin_helper
namespace electron { namespace electron {
@ -26,7 +26,7 @@ class Extensions final : public gin_helper::DeprecatedWrappable<Extensions>,
public gin_helper::EventEmitterMixin<Extensions>, public gin_helper::EventEmitterMixin<Extensions>,
private extensions::ExtensionRegistryObserver { private extensions::ExtensionRegistryObserver {
public: public:
static gin::Handle<Extensions> Create( static gin_helper::Handle<Extensions> Create(
v8::Isolate* isolate, v8::Isolate* isolate,
ElectronBrowserContext* browser_context); ElectronBrowserContext* browser_context);

View file

@ -15,12 +15,12 @@
#include "electron/shell/common/electron_constants.h" #include "electron/shell/common/electron_constants.h"
#include "extensions/common/command.h" #include "extensions/common/command.h"
#include "gin/dictionary.h" #include "gin/dictionary.h"
#include "gin/handle.h"
#include "gin/object_template_builder.h" #include "gin/object_template_builder.h"
#include "shell/browser/api/electron_api_system_preferences.h" #include "shell/browser/api/electron_api_system_preferences.h"
#include "shell/browser/browser.h" #include "shell/browser/browser.h"
#include "shell/common/gin_converters/accelerator_converter.h" #include "shell/common/gin_converters/accelerator_converter.h"
#include "shell/common/gin_converters/callback_converter.h" #include "shell/common/gin_converters/callback_converter.h"
#include "shell/common/gin_helper/handle.h"
#include "shell/common/node_includes.h" #include "shell/common/node_includes.h"
#if BUILDFLAG(IS_MAC) #if BUILDFLAG(IS_MAC)
@ -219,8 +219,9 @@ void GlobalShortcut::UnregisterAll() {
} }
// static // static
gin::Handle<GlobalShortcut> GlobalShortcut::Create(v8::Isolate* isolate) { gin_helper::Handle<GlobalShortcut> GlobalShortcut::Create(
return gin::CreateHandle(isolate, new GlobalShortcut()); v8::Isolate* isolate) {
return gin_helper::CreateHandle(isolate, new GlobalShortcut());
} }
// static // static

View file

@ -14,10 +14,10 @@
#include "ui/base/accelerators/accelerator.h" #include "ui/base/accelerators/accelerator.h"
#include "ui/base/accelerators/global_accelerator_listener/global_accelerator_listener.h" #include "ui/base/accelerators/global_accelerator_listener/global_accelerator_listener.h"
namespace gin { namespace gin_helper {
template <typename T> template <typename T>
class Handle; class Handle;
} // namespace gin } // namespace gin_helper
namespace electron::api { namespace electron::api {
@ -25,7 +25,7 @@ class GlobalShortcut final
: private ui::GlobalAcceleratorListener::Observer, : private ui::GlobalAcceleratorListener::Observer,
public gin_helper::DeprecatedWrappable<GlobalShortcut> { public gin_helper::DeprecatedWrappable<GlobalShortcut> {
public: public:
static gin::Handle<GlobalShortcut> Create(v8::Isolate* isolate); static gin_helper::Handle<GlobalShortcut> Create(v8::Isolate* isolate);
// gin_helper::Wrappable // gin_helper::Wrappable
static gin::DeprecatedWrapperInfo kWrapperInfo; static gin::DeprecatedWrapperInfo kWrapperInfo;

View file

@ -8,8 +8,8 @@
#include <utility> #include <utility>
#include <vector> #include <vector>
#include "gin/handle.h"
#include "shell/common/gin_helper/dictionary.h" #include "shell/common/gin_helper/dictionary.h"
#include "shell/common/gin_helper/handle.h"
#include "shell/common/gin_helper/object_template_builder.h" #include "shell/common/gin_helper/object_template_builder.h"
#include "shell/common/gin_helper/promise.h" #include "shell/common/gin_helper/promise.h"
#include "shell/common/node_includes.h" #include "shell/common/node_includes.h"
@ -135,8 +135,8 @@ gin::DeprecatedWrapperInfo InAppPurchase::kWrapperInfo = {
#if BUILDFLAG(IS_MAC) #if BUILDFLAG(IS_MAC)
// static // static
gin::Handle<InAppPurchase> InAppPurchase::Create(v8::Isolate* isolate) { gin_helper::Handle<InAppPurchase> InAppPurchase::Create(v8::Isolate* isolate) {
return gin::CreateHandle(isolate, new InAppPurchase()); return gin_helper::CreateHandle(isolate, new InAppPurchase());
} }
gin::ObjectTemplateBuilder InAppPurchase::GetObjectTemplateBuilder( gin::ObjectTemplateBuilder InAppPurchase::GetObjectTemplateBuilder(

View file

@ -15,10 +15,10 @@
#include "shell/common/gin_helper/wrappable.h" #include "shell/common/gin_helper/wrappable.h"
#include "v8/include/v8-forward.h" #include "v8/include/v8-forward.h"
namespace gin { namespace gin_helper {
template <typename T> template <typename T>
class Handle; class Handle;
} // namespace gin } // namespace gin_helper
namespace electron::api { namespace electron::api {
@ -27,7 +27,7 @@ class InAppPurchase final
public gin_helper::EventEmitterMixin<InAppPurchase>, public gin_helper::EventEmitterMixin<InAppPurchase>,
private in_app_purchase::TransactionObserver { private in_app_purchase::TransactionObserver {
public: public:
static gin::Handle<InAppPurchase> Create(v8::Isolate* isolate); static gin_helper::Handle<InAppPurchase> Create(v8::Isolate* isolate);
// gin_helper::Wrappable // gin_helper::Wrappable
static gin::DeprecatedWrapperInfo kWrapperInfo; static gin::DeprecatedWrapperInfo kWrapperInfo;

View file

@ -33,7 +33,7 @@ class Menu : public gin_helper::DeprecatedWrappable<Menu>,
private ElectronMenuModel::Observer { private ElectronMenuModel::Observer {
public: public:
// gin_helper::Constructible // gin_helper::Constructible
static gin::Handle<Menu> New(gin::Arguments* args); static gin_helper::Handle<Menu> New(gin::Arguments* args);
static void FillObjectTemplate(v8::Isolate*, v8::Local<v8::ObjectTemplate>); static void FillObjectTemplate(v8::Isolate*, v8::Local<v8::ObjectTemplate>);
static const char* GetClassName() { return "Menu"; } static const char* GetClassName() { return "Menu"; }

View file

@ -288,9 +288,9 @@ void Menu::SendActionToFirstResponder(const std::string& action) {
} }
// static // static
gin::Handle<Menu> Menu::New(gin::Arguments* args) { gin_helper::Handle<Menu> Menu::New(gin::Arguments* args) {
auto handle = auto handle = gin_helper::CreateHandle(args->isolate(),
gin::CreateHandle(args->isolate(), static_cast<Menu*>(new MenuMac(args))); static_cast<Menu*>(new MenuMac(args)));
gin_helper::CallMethod(args->isolate(), handle.get(), "_init"); gin_helper::CallMethod(args->isolate(), handle.get(), "_init");
return handle; return handle;
} }

View file

@ -84,9 +84,9 @@ void MenuViews::OnClosed(int32_t window_id, base::OnceClosure callback) {
} }
// static // static
gin::Handle<Menu> Menu::New(gin::Arguments* args) { gin_helper::Handle<Menu> Menu::New(gin::Arguments* args) {
auto handle = gin::CreateHandle(args->isolate(), auto handle = gin_helper::CreateHandle(
static_cast<Menu*>(new MenuViews(args))); args->isolate(), static_cast<Menu*>(new MenuViews(args)));
gin_helper::CallMethod(args->isolate(), handle.get(), "_init"); gin_helper::CallMethod(args->isolate(), handle.get(), "_init");
return handle; return handle;
} }

View file

@ -8,9 +8,9 @@
#include "content/public/browser/browser_task_traits.h" #include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#include "gin/handle.h"
#include "shell/common/gin_converters/std_converter.h" #include "shell/common/gin_converters/std_converter.h"
#include "shell/common/gin_helper/dictionary.h" #include "shell/common/gin_helper/dictionary.h"
#include "shell/common/gin_helper/handle.h"
#include "shell/common/gin_helper/object_template_builder.h" #include "shell/common/gin_helper/object_template_builder.h"
#include "shell/common/node_includes.h" #include "shell/common/node_includes.h"
#include "ui/native_theme/native_theme.h" #include "ui/native_theme/native_theme.h"
@ -98,11 +98,11 @@ bool NativeTheme::ShouldUseInvertedColorScheme() {
} }
// static // static
gin::Handle<NativeTheme> NativeTheme::Create(v8::Isolate* isolate) { gin_helper::Handle<NativeTheme> NativeTheme::Create(v8::Isolate* isolate) {
ui::NativeTheme* ui_theme = ui::NativeTheme::GetInstanceForNativeUi(); ui::NativeTheme* ui_theme = ui::NativeTheme::GetInstanceForNativeUi();
ui::NativeTheme* web_theme = ui::NativeTheme::GetInstanceForWeb(); ui::NativeTheme* web_theme = ui::NativeTheme::GetInstanceForWeb();
return gin::CreateHandle(isolate, return gin_helper::CreateHandle(
new NativeTheme(isolate, ui_theme, web_theme)); isolate, new NativeTheme(isolate, ui_theme, web_theme));
} }
gin::ObjectTemplateBuilder NativeTheme::GetObjectTemplateBuilder( gin::ObjectTemplateBuilder NativeTheme::GetObjectTemplateBuilder(

View file

@ -11,10 +11,10 @@
#include "ui/native_theme/native_theme.h" #include "ui/native_theme/native_theme.h"
#include "ui/native_theme/native_theme_observer.h" #include "ui/native_theme/native_theme_observer.h"
namespace gin { namespace gin_helper {
template <typename T> template <typename T>
class handle; class Handle;
} // namespace gin } // namespace gin_helper
namespace electron::api { namespace electron::api {
@ -22,7 +22,7 @@ class NativeTheme final : public gin_helper::DeprecatedWrappable<NativeTheme>,
public gin_helper::EventEmitterMixin<NativeTheme>, public gin_helper::EventEmitterMixin<NativeTheme>,
private ui::NativeThemeObserver { private ui::NativeThemeObserver {
public: public:
static gin::Handle<NativeTheme> Create(v8::Isolate* isolate); static gin_helper::Handle<NativeTheme> Create(v8::Isolate* isolate);
// gin_helper::Wrappable // gin_helper::Wrappable
static gin::DeprecatedWrapperInfo kWrapperInfo; static gin::DeprecatedWrapperInfo kWrapperInfo;

View file

@ -15,13 +15,13 @@
#include "components/net_log/chrome_net_log.h" #include "components/net_log/chrome_net_log.h"
#include "content/public/browser/storage_partition.h" #include "content/public/browser/storage_partition.h"
#include "electron/electron_version.h" #include "electron/electron_version.h"
#include "gin/handle.h"
#include "gin/object_template_builder.h" #include "gin/object_template_builder.h"
#include "net/log/net_log_capture_mode.h" #include "net/log/net_log_capture_mode.h"
#include "shell/browser/electron_browser_context.h" #include "shell/browser/electron_browser_context.h"
#include "shell/browser/net/system_network_context_manager.h" #include "shell/browser/net/system_network_context_manager.h"
#include "shell/common/gin_converters/file_path_converter.h" #include "shell/common/gin_converters/file_path_converter.h"
#include "shell/common/gin_helper/dictionary.h" #include "shell/common/gin_helper/dictionary.h"
#include "shell/common/gin_helper/handle.h"
namespace gin { namespace gin {
@ -231,9 +231,11 @@ const char* NetLog::GetTypeName() {
} }
// static // static
gin::Handle<NetLog> NetLog::Create(v8::Isolate* isolate, gin_helper::Handle<NetLog> NetLog::Create(
v8::Isolate* isolate,
ElectronBrowserContext* browser_context) { ElectronBrowserContext* browser_context) {
return gin::CreateHandle(isolate, new NetLog(isolate, browser_context)); return gin_helper::CreateHandle(isolate,
new NetLog(isolate, browser_context));
} }
} // namespace api } // namespace api

View file

@ -23,10 +23,12 @@ class TaskRunner;
namespace gin { namespace gin {
class Arguments; class Arguments;
} // namespace gin
namespace gin_helper {
template <typename T> template <typename T>
class Handle; class Handle;
} // namespace gin } // namespace gin_helper
namespace electron { namespace electron {
@ -37,7 +39,8 @@ namespace api {
// The code is referenced from the net_log::NetExportFileWriter class. // The code is referenced from the net_log::NetExportFileWriter class.
class NetLog final : public gin_helper::DeprecatedWrappable<NetLog> { class NetLog final : public gin_helper::DeprecatedWrappable<NetLog> {
public: public:
static gin::Handle<NetLog> Create(v8::Isolate* isolate, static gin_helper::Handle<NetLog> Create(
v8::Isolate* isolate,
ElectronBrowserContext* browser_context); ElectronBrowserContext* browser_context);
v8::Local<v8::Promise> StartLogging(base::FilePath log_path, v8::Local<v8::Promise> StartLogging(base::FilePath log_path,

View file

@ -5,13 +5,13 @@
#include "shell/browser/api/electron_api_notification.h" #include "shell/browser/api/electron_api_notification.h"
#include "base/uuid.h" #include "base/uuid.h"
#include "gin/handle.h"
#include "shell/browser/api/electron_api_menu.h" #include "shell/browser/api/electron_api_menu.h"
#include "shell/browser/browser.h" #include "shell/browser/browser.h"
#include "shell/browser/electron_browser_client.h" #include "shell/browser/electron_browser_client.h"
#include "shell/common/gin_converters/image_converter.h" #include "shell/common/gin_converters/image_converter.h"
#include "shell/common/gin_helper/dictionary.h" #include "shell/common/gin_helper/dictionary.h"
#include "shell/common/gin_helper/error_thrower.h" #include "shell/common/gin_helper/error_thrower.h"
#include "shell/common/gin_helper/handle.h"
#include "shell/common/gin_helper/object_template_builder.h" #include "shell/common/gin_helper/object_template_builder.h"
#include "shell/common/node_includes.h" #include "shell/common/node_includes.h"
#include "url/gurl.h" #include "url/gurl.h"
@ -78,13 +78,14 @@ Notification::~Notification() {
} }
// static // static
gin::Handle<Notification> Notification::New(gin_helper::ErrorThrower thrower, gin_helper::Handle<Notification> Notification::New(
gin_helper::ErrorThrower thrower,
gin::Arguments* args) { gin::Arguments* args) {
if (!Browser::Get()->is_ready()) { if (!Browser::Get()->is_ready()) {
thrower.ThrowError("Cannot create Notification before app is ready"); thrower.ThrowError("Cannot create Notification before app is ready");
return {}; return {};
} }
return gin::CreateHandle(thrower.isolate(), new Notification(args)); return gin_helper::CreateHandle(thrower.isolate(), new Notification(args));
} }
// Setters // Setters

View file

@ -20,12 +20,12 @@
namespace gin { namespace gin {
class Arguments; class Arguments;
template <typename T>
class Handle;
} // namespace gin } // namespace gin
namespace gin_helper { namespace gin_helper {
class ErrorThrower; class ErrorThrower;
template <typename T>
class Handle;
} // namespace gin_helper } // namespace gin_helper
namespace electron::api { namespace electron::api {
@ -39,7 +39,7 @@ class Notification final : public gin_helper::DeprecatedWrappable<Notification>,
static bool IsSupported(); static bool IsSupported();
// gin_helper::Constructible // gin_helper::Constructible
static gin::Handle<Notification> New(gin_helper::ErrorThrower thrower, static gin_helper::Handle<Notification> New(gin_helper::ErrorThrower thrower,
gin::Arguments* args); gin::Arguments* args);
static void FillObjectTemplate(v8::Isolate*, v8::Local<v8::ObjectTemplate>); static void FillObjectTemplate(v8::Isolate*, v8::Local<v8::ObjectTemplate>);
static const char* GetClassName() { return "Notification"; } static const char* GetClassName() { return "Notification"; }

View file

@ -8,11 +8,11 @@
#include "base/power_monitor/power_monitor_device_source.h" #include "base/power_monitor/power_monitor_device_source.h"
#include "base/power_monitor/power_observer.h" #include "base/power_monitor/power_observer.h"
#include "gin/data_object_builder.h" #include "gin/data_object_builder.h"
#include "gin/handle.h"
#include "shell/browser/browser.h" #include "shell/browser/browser.h"
#include "shell/browser/javascript_environment.h" #include "shell/browser/javascript_environment.h"
#include "shell/common/gin_converters/callback_converter.h" #include "shell/common/gin_converters/callback_converter.h"
#include "shell/common/gin_helper/dictionary.h" #include "shell/common/gin_helper/dictionary.h"
#include "shell/common/gin_helper/handle.h"
#include "shell/common/gin_helper/object_template_builder.h" #include "shell/common/gin_helper/object_template_builder.h"
#include "shell/common/node_includes.h" #include "shell/common/node_includes.h"
@ -144,7 +144,7 @@ void PowerMonitor::SetListeningForShutdown(bool is_listening) {
// static // static
v8::Local<v8::Value> PowerMonitor::Create(v8::Isolate* isolate) { v8::Local<v8::Value> PowerMonitor::Create(v8::Isolate* isolate) {
auto* pm = new PowerMonitor(isolate); auto* pm = new PowerMonitor(isolate);
auto handle = gin::CreateHandle(isolate, pm).ToV8(); auto handle = gin_helper::CreateHandle(isolate, pm).ToV8();
pm->Pin(isolate); pm->Pin(isolate);
return handle; return handle;
} }

View file

@ -10,11 +10,11 @@
#include "content/public/browser/device_service.h" #include "content/public/browser/device_service.h"
#include "gin/dictionary.h" #include "gin/dictionary.h"
#include "gin/function_template.h" #include "gin/function_template.h"
#include "gin/handle.h"
#include "gin/object_template_builder.h" #include "gin/object_template_builder.h"
#include "services/device/public/mojom/wake_lock_provider.mojom.h" #include "services/device/public/mojom/wake_lock_provider.mojom.h"
#include "services/service_manager/public/cpp/connector.h" #include "services/service_manager/public/cpp/connector.h"
#include "shell/browser/javascript_environment.h" #include "shell/browser/javascript_environment.h"
#include "shell/common/gin_helper/handle.h"
#include "shell/common/node_includes.h" #include "shell/common/node_includes.h"
namespace gin { namespace gin {
@ -115,8 +115,9 @@ bool PowerSaveBlocker::IsStarted(int id) const {
} }
// static // static
gin::Handle<PowerSaveBlocker> PowerSaveBlocker::Create(v8::Isolate* isolate) { gin_helper::Handle<PowerSaveBlocker> PowerSaveBlocker::Create(
return gin::CreateHandle(isolate, new PowerSaveBlocker(isolate)); v8::Isolate* isolate) {
return gin_helper::CreateHandle(isolate, new PowerSaveBlocker(isolate));
} }
gin::ObjectTemplateBuilder PowerSaveBlocker::GetObjectTemplateBuilder( gin::ObjectTemplateBuilder PowerSaveBlocker::GetObjectTemplateBuilder(

View file

@ -12,17 +12,19 @@
namespace gin { namespace gin {
class ObjectTemplateBuilder; class ObjectTemplateBuilder;
} // namespace gin
namespace gin_helper {
template <typename T> template <typename T>
class Handle; class Handle;
} // namespace gin } // namespace gin_helper
namespace electron::api { namespace electron::api {
class PowerSaveBlocker final class PowerSaveBlocker final
: public gin_helper::DeprecatedWrappable<PowerSaveBlocker> { : public gin_helper::DeprecatedWrappable<PowerSaveBlocker> {
public: public:
static gin::Handle<PowerSaveBlocker> Create(v8::Isolate* isolate); static gin_helper::Handle<PowerSaveBlocker> Create(v8::Isolate* isolate);
// gin_helper::Wrappable // gin_helper::Wrappable
static gin::DeprecatedWrapperInfo kWrapperInfo; static gin::DeprecatedWrapperInfo kWrapperInfo;

View file

@ -11,7 +11,6 @@
#include "base/containers/contains.h" #include "base/containers/contains.h"
#include "content/common/url_schemes.h" #include "content/common/url_schemes.h"
#include "content/public/browser/child_process_security_policy.h" #include "content/public/browser/child_process_security_policy.h"
#include "gin/handle.h"
#include "gin/object_template_builder.h" #include "gin/object_template_builder.h"
#include "shell/browser/browser.h" #include "shell/browser/browser.h"
#include "shell/browser/javascript_environment.h" #include "shell/browser/javascript_environment.h"
@ -19,6 +18,7 @@
#include "shell/common/gin_converters/callback_converter.h" #include "shell/common/gin_converters/callback_converter.h"
#include "shell/common/gin_converters/net_converter.h" #include "shell/common/gin_converters/net_converter.h"
#include "shell/common/gin_helper/dictionary.h" #include "shell/common/gin_helper/dictionary.h"
#include "shell/common/gin_helper/handle.h"
#include "shell/common/gin_helper/object_template_builder.h" #include "shell/common/gin_helper/object_template_builder.h"
#include "shell/common/gin_helper/promise.h" #include "shell/common/gin_helper/promise.h"
#include "shell/common/node_includes.h" #include "shell/common/node_includes.h"
@ -288,13 +288,14 @@ void Protocol::HandleOptionalCallback(gin::Arguments* args, Error error) {
} }
// static // static
gin::Handle<Protocol> Protocol::Create(v8::Isolate* isolate, gin_helper::Handle<Protocol> Protocol::Create(
v8::Isolate* isolate,
ProtocolRegistry* protocol_registry) { ProtocolRegistry* protocol_registry) {
return gin::CreateHandle(isolate, new Protocol{protocol_registry}); return gin_helper::CreateHandle(isolate, new Protocol{protocol_registry});
} }
// static // static
gin::Handle<Protocol> Protocol::New(gin_helper::ErrorThrower thrower) { gin_helper::Handle<Protocol> Protocol::New(gin_helper::ErrorThrower thrower) {
thrower.ThrowError("Protocol cannot be created from JS"); thrower.ThrowError("Protocol cannot be created from JS");
return {}; return {};
} }

View file

@ -16,9 +16,12 @@
namespace gin { namespace gin {
class Arguments; class Arguments;
} // namespace gin
namespace gin_helper {
template <typename T> template <typename T>
class Handle; class Handle;
} // namespace gin } // namespace gin_helper
namespace electron { namespace electron {
@ -38,11 +41,12 @@ void RegisterSchemesAsPrivileged(gin_helper::ErrorThrower thrower,
class Protocol final : public gin_helper::DeprecatedWrappable<Protocol>, class Protocol final : public gin_helper::DeprecatedWrappable<Protocol>,
public gin_helper::Constructible<Protocol> { public gin_helper::Constructible<Protocol> {
public: public:
static gin::Handle<Protocol> Create(v8::Isolate* isolate, static gin_helper::Handle<Protocol> Create(
v8::Isolate* isolate,
ProtocolRegistry* protocol_registry); ProtocolRegistry* protocol_registry);
// gin_helper::Constructible // gin_helper::Constructible
static gin::Handle<Protocol> New(gin_helper::ErrorThrower thrower); static gin_helper::Handle<Protocol> New(gin_helper::ErrorThrower thrower);
static v8::Local<v8::ObjectTemplate> FillObjectTemplate( static v8::Local<v8::ObjectTemplate> FillObjectTemplate(
v8::Isolate* isolate, v8::Isolate* isolate,
v8::Local<v8::ObjectTemplate> tmpl); v8::Local<v8::ObjectTemplate> tmpl);

View file

@ -4,9 +4,9 @@
#include "shell/browser/api/electron_api_push_notifications.h" #include "shell/browser/api/electron_api_push_notifications.h"
#include "gin/handle.h"
#include "shell/common/gin_converters/value_converter.h" #include "shell/common/gin_converters/value_converter.h"
#include "shell/common/gin_helper/dictionary.h" #include "shell/common/gin_helper/dictionary.h"
#include "shell/common/gin_helper/handle.h"
#include "shell/common/node_includes.h" #include "shell/common/node_includes.h"
namespace electron::api { namespace electron::api {
@ -30,8 +30,9 @@ PushNotifications* PushNotifications::Get() {
} }
// static // static
gin::Handle<PushNotifications> PushNotifications::Create(v8::Isolate* isolate) { gin_helper::Handle<PushNotifications> PushNotifications::Create(
return gin::CreateHandle(isolate, PushNotifications::Get()); v8::Isolate* isolate) {
return gin_helper::CreateHandle(isolate, PushNotifications::Get());
} }
// static // static

View file

@ -14,10 +14,10 @@
#include "shell/common/gin_helper/promise.h" #include "shell/common/gin_helper/promise.h"
#include "shell/common/gin_helper/wrappable.h" #include "shell/common/gin_helper/wrappable.h"
namespace gin { namespace gin_helper {
template <typename T> template <typename T>
class Handle; class Handle;
} // namespace gin } // namespace gin_helper
namespace electron::api { namespace electron::api {
@ -28,7 +28,7 @@ class PushNotifications final
private BrowserObserver { private BrowserObserver {
public: public:
static PushNotifications* Get(); static PushNotifications* Get();
static gin::Handle<PushNotifications> Create(v8::Isolate* isolate); static gin_helper::Handle<PushNotifications> Create(v8::Isolate* isolate);
// gin_helper::Wrappable // gin_helper::Wrappable
static gin::DeprecatedWrapperInfo kWrapperInfo; static gin::DeprecatedWrapperInfo kWrapperInfo;

View file

@ -8,13 +8,13 @@
#include <string_view> #include <string_view>
#include "base/functional/bind.h" #include "base/functional/bind.h"
#include "gin/handle.h"
#include "shell/browser/browser.h" #include "shell/browser/browser.h"
#include "shell/common/gin_converters/callback_converter.h" #include "shell/common/gin_converters/callback_converter.h"
#include "shell/common/gin_converters/gfx_converter.h" #include "shell/common/gin_converters/gfx_converter.h"
#include "shell/common/gin_converters/native_window_converter.h" #include "shell/common/gin_converters/native_window_converter.h"
#include "shell/common/gin_helper/dictionary.h" #include "shell/common/gin_helper/dictionary.h"
#include "shell/common/gin_helper/error_thrower.h" #include "shell/common/gin_helper/error_thrower.h"
#include "shell/common/gin_helper/handle.h"
#include "shell/common/gin_helper/object_template_builder.h" #include "shell/common/gin_helper/object_template_builder.h"
#include "shell/common/node_includes.h" #include "shell/common/node_includes.h"
#include "ui/display/display.h" #include "ui/display/display.h"
@ -185,7 +185,7 @@ v8::Local<v8::Value> Screen::Create(gin_helper::ErrorThrower error_thrower) {
return v8::Null(error_thrower.isolate()); return v8::Null(error_thrower.isolate());
} }
return gin::CreateHandle(error_thrower.isolate(), return gin_helper::CreateHandle(error_thrower.isolate(),
new Screen(error_thrower.isolate(), screen)) new Screen(error_thrower.isolate(), screen))
.ToV8(); .ToV8();
} }

View file

@ -12,7 +12,6 @@
#include "content/public/browser/console_message.h" #include "content/public/browser/console_message.h"
#include "content/public/browser/storage_partition.h" #include "content/public/browser/storage_partition.h"
#include "gin/data_object_builder.h" #include "gin/data_object_builder.h"
#include "gin/handle.h"
#include "gin/object_template_builder.h" #include "gin/object_template_builder.h"
#include "shell/browser/api/electron_api_service_worker_main.h" #include "shell/browser/api/electron_api_service_worker_main.h"
#include "shell/browser/electron_browser_context.h" #include "shell/browser/electron_browser_context.h"
@ -21,6 +20,7 @@
#include "shell/common/gin_converters/service_worker_converter.h" #include "shell/common/gin_converters/service_worker_converter.h"
#include "shell/common/gin_converters/value_converter.h" #include "shell/common/gin_converters/value_converter.h"
#include "shell/common/gin_helper/dictionary.h" #include "shell/common/gin_helper/dictionary.h"
#include "shell/common/gin_helper/handle.h"
#include "shell/common/gin_helper/promise.h" #include "shell/common/gin_helper/promise.h"
#include "shell/common/node_util.h" #include "shell/common/node_util.h"
@ -210,14 +210,14 @@ v8::Local<v8::Value> ServiceWorkerContext::GetWorkerFromVersionID(
.ToV8(); .ToV8();
} }
gin::Handle<ServiceWorkerMain> gin_helper::Handle<ServiceWorkerMain>
ServiceWorkerContext::GetWorkerFromVersionIDIfExists(v8::Isolate* isolate, ServiceWorkerContext::GetWorkerFromVersionIDIfExists(v8::Isolate* isolate,
int64_t version_id) { int64_t version_id) {
ServiceWorkerMain* worker = ServiceWorkerMain* worker =
ServiceWorkerMain::FromVersionID(version_id, storage_partition_); ServiceWorkerMain::FromVersionID(version_id, storage_partition_);
if (!worker) if (!worker)
return gin::Handle<ServiceWorkerMain>(); return gin_helper::Handle<ServiceWorkerMain>();
return gin::CreateHandle(isolate, worker); return gin_helper::CreateHandle(isolate, worker);
} }
v8::Local<v8::Promise> ServiceWorkerContext::StartWorkerForScope( v8::Local<v8::Promise> ServiceWorkerContext::StartWorkerForScope(
@ -272,11 +272,11 @@ v8::Local<v8::Promise> ServiceWorkerContext::StopAllWorkers(
} }
// static // static
gin::Handle<ServiceWorkerContext> ServiceWorkerContext::Create( gin_helper::Handle<ServiceWorkerContext> ServiceWorkerContext::Create(
v8::Isolate* isolate, v8::Isolate* isolate,
ElectronBrowserContext* browser_context) { ElectronBrowserContext* browser_context) {
return gin::CreateHandle(isolate, return gin_helper::CreateHandle(
new ServiceWorkerContext(isolate, browser_context)); isolate, new ServiceWorkerContext(isolate, browser_context));
} }
// static // static

View file

@ -16,12 +16,9 @@ namespace content {
class StoragePartition; class StoragePartition;
} }
namespace gin { namespace gin_helper {
template <typename T> template <typename T>
class Handle; class Handle;
} // namespace gin
namespace gin_helper {
template <typename T> template <typename T>
class Promise; class Promise;
} // namespace gin_helper } // namespace gin_helper
@ -39,7 +36,7 @@ class ServiceWorkerContext final
public gin_helper::EventEmitterMixin<ServiceWorkerContext>, public gin_helper::EventEmitterMixin<ServiceWorkerContext>,
private content::ServiceWorkerContextObserver { private content::ServiceWorkerContextObserver {
public: public:
static gin::Handle<ServiceWorkerContext> Create( static gin_helper::Handle<ServiceWorkerContext> Create(
v8::Isolate* isolate, v8::Isolate* isolate,
ElectronBrowserContext* browser_context); ElectronBrowserContext* browser_context);
@ -50,7 +47,7 @@ class ServiceWorkerContext final
int64_t version_id); int64_t version_id);
v8::Local<v8::Value> GetWorkerFromVersionID(v8::Isolate* isolate, v8::Local<v8::Value> GetWorkerFromVersionID(v8::Isolate* isolate,
int64_t version_id); int64_t version_id);
gin::Handle<ServiceWorkerMain> GetWorkerFromVersionIDIfExists( gin_helper::Handle<ServiceWorkerMain> GetWorkerFromVersionIDIfExists(
v8::Isolate* isolate, v8::Isolate* isolate,
int64_t version_id); int64_t version_id);
v8::Local<v8::Promise> StartWorkerForScope(v8::Isolate* isolate, GURL scope); v8::Local<v8::Promise> StartWorkerForScope(v8::Isolate* isolate, GURL scope);

View file

@ -11,7 +11,6 @@
#include "base/no_destructor.h" #include "base/no_destructor.h"
#include "content/browser/service_worker/service_worker_context_wrapper.h" // nogncheck #include "content/browser/service_worker/service_worker_context_wrapper.h" // nogncheck
#include "content/browser/service_worker/service_worker_version.h" // nogncheck #include "content/browser/service_worker/service_worker_version.h" // nogncheck
#include "gin/handle.h"
#include "gin/object_template_builder.h" #include "gin/object_template_builder.h"
#include "services/service_manager/public/cpp/interface_provider.h" #include "services/service_manager/public/cpp/interface_provider.h"
#include "shell/browser/api/message_port.h" #include "shell/browser/api/message_port.h"
@ -23,6 +22,7 @@
#include "shell/common/gin_converters/value_converter.h" #include "shell/common/gin_converters/value_converter.h"
#include "shell/common/gin_helper/dictionary.h" #include "shell/common/gin_helper/dictionary.h"
#include "shell/common/gin_helper/error_thrower.h" #include "shell/common/gin_helper/error_thrower.h"
#include "shell/common/gin_helper/handle.h"
#include "shell/common/gin_helper/object_template_builder.h" #include "shell/common/gin_helper/object_template_builder.h"
#include "shell/common/gin_helper/promise.h" #include "shell/common/gin_helper/promise.h"
#include "shell/common/node_includes.h" #include "shell/common/node_includes.h"
@ -289,12 +289,13 @@ GURL ServiceWorkerMain::ScriptURL() const {
} }
// static // static
gin::Handle<ServiceWorkerMain> ServiceWorkerMain::New(v8::Isolate* isolate) { gin_helper::Handle<ServiceWorkerMain> ServiceWorkerMain::New(
return gin::Handle<ServiceWorkerMain>(); v8::Isolate* isolate) {
return gin_helper::Handle<ServiceWorkerMain>();
} }
// static // static
gin::Handle<ServiceWorkerMain> ServiceWorkerMain::From( gin_helper::Handle<ServiceWorkerMain> ServiceWorkerMain::From(
v8::Isolate* isolate, v8::Isolate* isolate,
content::ServiceWorkerContext* sw_context, content::ServiceWorkerContext* sw_context,
const content::StoragePartition* storage_partition, const content::StoragePartition* storage_partition,
@ -303,15 +304,15 @@ gin::Handle<ServiceWorkerMain> ServiceWorkerMain::From(
auto* service_worker = FromServiceWorkerKey(service_worker_key); auto* service_worker = FromServiceWorkerKey(service_worker_key);
if (service_worker) if (service_worker)
return gin::CreateHandle(isolate, service_worker); return gin_helper::CreateHandle(isolate, service_worker);
// Ensure ServiceWorkerVersion exists and is not redundant (pending deletion) // Ensure ServiceWorkerVersion exists and is not redundant (pending deletion)
auto* live_version = GetLiveVersion(sw_context, version_id); auto* live_version = GetLiveVersion(sw_context, version_id);
if (!live_version || live_version->is_redundant()) { if (!live_version || live_version->is_redundant()) {
return gin::Handle<ServiceWorkerMain>(); return gin_helper::Handle<ServiceWorkerMain>();
} }
auto handle = gin::CreateHandle( auto handle = gin_helper::CreateHandle(
isolate, isolate,
new ServiceWorkerMain(sw_context, version_id, service_worker_key)); new ServiceWorkerMain(sw_context, version_id, service_worker_key));

View file

@ -85,9 +85,9 @@ class ServiceWorkerMain final
public gin_helper::Constructible<ServiceWorkerMain> { public gin_helper::Constructible<ServiceWorkerMain> {
public: public:
// Create a new ServiceWorkerMain and return the V8 wrapper of it. // Create a new ServiceWorkerMain and return the V8 wrapper of it.
static gin::Handle<ServiceWorkerMain> New(v8::Isolate* isolate); static gin_helper::Handle<ServiceWorkerMain> New(v8::Isolate* isolate);
static gin::Handle<ServiceWorkerMain> From( static gin_helper::Handle<ServiceWorkerMain> From(
v8::Isolate* isolate, v8::Isolate* isolate,
content::ServiceWorkerContext* sw_context, content::ServiceWorkerContext* sw_context,
const content::StoragePartition* storage_partition, const content::StoragePartition* storage_partition,

View file

@ -44,7 +44,6 @@
#include "content/public/browser/storage_partition.h" #include "content/public/browser/storage_partition.h"
#include "gin/arguments.h" #include "gin/arguments.h"
#include "gin/converter.h" #include "gin/converter.h"
#include "gin/handle.h"
#include "mojo/public/cpp/bindings/pending_remote.h" #include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/self_owned_receiver.h" #include "mojo/public/cpp/bindings/self_owned_receiver.h"
#include "net/base/completion_repeating_callback.h" #include "net/base/completion_repeating_callback.h"
@ -89,6 +88,7 @@
#include "shell/common/gin_helper/cleaned_up_at_exit.h" #include "shell/common/gin_helper/cleaned_up_at_exit.h"
#include "shell/common/gin_helper/dictionary.h" #include "shell/common/gin_helper/dictionary.h"
#include "shell/common/gin_helper/error_thrower.h" #include "shell/common/gin_helper/error_thrower.h"
#include "shell/common/gin_helper/handle.h"
#include "shell/common/gin_helper/object_template_builder.h" #include "shell/common/gin_helper/object_template_builder.h"
#include "shell/common/gin_helper/promise.h" #include "shell/common/gin_helper/promise.h"
#include "shell/common/node_includes.h" #include "shell/common/node_includes.h"
@ -1004,7 +1004,8 @@ bool Session::IsPersistent() {
v8::Local<v8::Promise> Session::GetBlobData(v8::Isolate* isolate, v8::Local<v8::Promise> Session::GetBlobData(v8::Isolate* isolate,
const std::string& uuid) { const std::string& uuid) {
gin::Handle<DataPipeHolder> holder = DataPipeHolder::From(isolate, uuid); gin_helper::Handle<DataPipeHolder> holder =
DataPipeHolder::From(isolate, uuid);
if (holder.IsEmpty()) { if (holder.IsEmpty()) {
gin_helper::Promise<v8::Local<v8::Value>> promise(isolate); gin_helper::Promise<v8::Local<v8::Value>> promise(isolate);
promise.RejectWithErrorMessage("Could not get blob data handle"); promise.RejectWithErrorMessage("Could not get blob data handle");
@ -1662,15 +1663,15 @@ Session* Session::FromBrowserContext(content::BrowserContext* context) {
} }
// static // static
gin::Handle<Session> Session::CreateFrom( gin_helper::Handle<Session> Session::CreateFrom(
v8::Isolate* isolate, v8::Isolate* isolate,
ElectronBrowserContext* browser_context) { ElectronBrowserContext* browser_context) {
Session* existing = FromBrowserContext(browser_context); Session* existing = FromBrowserContext(browser_context);
if (existing) if (existing)
return gin::CreateHandle(isolate, existing); return gin_helper::CreateHandle(isolate, existing);
auto handle = auto handle =
gin::CreateHandle(isolate, new Session(isolate, browser_context)); gin_helper::CreateHandle(isolate, new Session(isolate, browser_context));
// The Sessions should never be garbage collected, since the common pattern is // The Sessions should never be garbage collected, since the common pattern is
// to use partition strings, instead of using the Session object directly. // to use partition strings, instead of using the Session object directly.
@ -1688,7 +1689,7 @@ gin::Handle<Session> Session::CreateFrom(
} }
// static // static
gin::Handle<Session> Session::FromPartition(v8::Isolate* isolate, gin_helper::Handle<Session> Session::FromPartition(v8::Isolate* isolate,
const std::string& partition, const std::string& partition,
base::Value::Dict options) { base::Value::Dict options) {
ElectronBrowserContext* browser_context; ElectronBrowserContext* browser_context;
@ -1707,7 +1708,7 @@ gin::Handle<Session> Session::FromPartition(v8::Isolate* isolate,
} }
// static // static
std::optional<gin::Handle<Session>> Session::FromPath( std::optional<gin_helper::Handle<Session>> Session::FromPath(
v8::Isolate* isolate, v8::Isolate* isolate,
const base::FilePath& path, const base::FilePath& path,
base::Value::Dict options) { base::Value::Dict options) {
@ -1731,7 +1732,7 @@ std::optional<gin::Handle<Session>> Session::FromPath(
} }
// static // static
gin::Handle<Session> Session::New() { gin_helper::Handle<Session> Session::New() {
gin_helper::ErrorThrower(JavascriptEnvironment::GetIsolate()) gin_helper::ErrorThrower(JavascriptEnvironment::GetIsolate())
.ThrowError("Session objects cannot be created with 'new'"); .ThrowError("Session objects cannot be created with 'new'");
return {}; return {};
@ -1854,7 +1855,7 @@ v8::Local<v8::Value> FromPath(const base::FilePath& path,
} }
base::Value::Dict options; base::Value::Dict options;
args->GetNext(&options); args->GetNext(&options);
std::optional<gin::Handle<Session>> session_handle = std::optional<gin_helper::Handle<Session>> session_handle =
Session::FromPath(args->isolate(), path, std::move(options)); Session::FromPath(args->isolate(), path, std::move(options));
if (session_handle) if (session_handle)

View file

@ -37,9 +37,12 @@ class FilePath;
namespace gin { namespace gin {
class Arguments; class Arguments;
} // namespace gin
namespace gin_helper {
template <typename T> template <typename T>
class Handle; class Handle;
} // namespace gin } // namespace gin_helper
namespace gin_helper { namespace gin_helper {
class Dictionary; class Dictionary;
@ -69,20 +72,21 @@ class Session final : public gin_helper::DeprecatedWrappable<Session>,
private content::DownloadManager::Observer { private content::DownloadManager::Observer {
public: public:
// Gets or creates Session from the |browser_context|. // Gets or creates Session from the |browser_context|.
static gin::Handle<Session> CreateFrom( static gin_helper::Handle<Session> CreateFrom(
v8::Isolate* isolate, v8::Isolate* isolate,
ElectronBrowserContext* browser_context); ElectronBrowserContext* browser_context);
static gin::Handle<Session> New(); // Dummy, do not use! static gin_helper::Handle<Session> New(); // Dummy, do not use!
static Session* FromBrowserContext(content::BrowserContext* context); static Session* FromBrowserContext(content::BrowserContext* context);
// Gets the Session of |partition|. // Gets the Session of |partition|.
static gin::Handle<Session> FromPartition(v8::Isolate* isolate, static gin_helper::Handle<Session> FromPartition(
v8::Isolate* isolate,
const std::string& partition, const std::string& partition,
base::Value::Dict options = {}); base::Value::Dict options = {});
// Gets the Session based on |path|. // Gets the Session based on |path|.
static std::optional<gin::Handle<Session>> FromPath( static std::optional<gin_helper::Handle<Session>> FromPath(
v8::Isolate* isolate, v8::Isolate* isolate,
const base::FilePath& path, const base::FilePath& path,
base::Value::Dict options = {}); base::Value::Dict options = {});

View file

@ -4,11 +4,11 @@
#include "shell/browser/api/electron_api_system_preferences.h" #include "shell/browser/api/electron_api_system_preferences.h"
#include "gin/handle.h"
#include "shell/common/gin_converters/callback_converter.h" #include "shell/common/gin_converters/callback_converter.h"
#include "shell/common/gin_converters/value_converter.h" #include "shell/common/gin_converters/value_converter.h"
#include "shell/common/gin_helper/dictionary.h" #include "shell/common/gin_helper/dictionary.h"
#include "shell/common/gin_helper/error_thrower.h" #include "shell/common/gin_helper/error_thrower.h"
#include "shell/common/gin_helper/handle.h"
#include "shell/common/node_includes.h" #include "shell/common/node_includes.h"
#include "ui/gfx/animation/animation.h" #include "ui/gfx/animation/animation.h"
@ -46,8 +46,9 @@ v8::Local<v8::Value> SystemPreferences::GetAnimationSettings(
} }
// static // static
gin::Handle<SystemPreferences> SystemPreferences::Create(v8::Isolate* isolate) { gin_helper::Handle<SystemPreferences> SystemPreferences::Create(
return gin::CreateHandle(isolate, new SystemPreferences()); v8::Isolate* isolate) {
return gin_helper::CreateHandle(isolate, new SystemPreferences());
} }
gin::ObjectTemplateBuilder SystemPreferences::GetObjectTemplateBuilder( gin::ObjectTemplateBuilder SystemPreferences::GetObjectTemplateBuilder(

View file

@ -18,10 +18,10 @@
#include "ui/gfx/sys_color_change_listener.h" #include "ui/gfx/sys_color_change_listener.h"
#endif #endif
namespace gin { namespace gin_helper {
template <typename T> template <typename T>
class Handle; class Handle;
} // namespace gin } // namespace gin_helper
namespace gin_helper { namespace gin_helper {
class ErrorThrower; class ErrorThrower;
@ -47,7 +47,7 @@ class SystemPreferences final
#endif #endif
{ {
public: public:
static gin::Handle<SystemPreferences> Create(v8::Isolate* isolate); static gin_helper::Handle<SystemPreferences> Create(v8::Isolate* isolate);
// gin_helper::Wrappable // gin_helper::Wrappable
static gin::DeprecatedWrapperInfo kWrapperInfo; static gin::DeprecatedWrapperInfo kWrapperInfo;

View file

@ -9,7 +9,6 @@
#include "base/containers/fixed_flat_map.h" #include "base/containers/fixed_flat_map.h"
#include "gin/dictionary.h" #include "gin/dictionary.h"
#include "gin/handle.h"
#include "gin/object_template_builder.h" #include "gin/object_template_builder.h"
#include "shell/browser/api/electron_api_menu.h" #include "shell/browser/api/electron_api_menu.h"
#include "shell/browser/api/ui_event.h" #include "shell/browser/api/ui_event.h"
@ -22,6 +21,7 @@
#include "shell/common/gin_converters/image_converter.h" #include "shell/common/gin_converters/image_converter.h"
#include "shell/common/gin_helper/dictionary.h" #include "shell/common/gin_helper/dictionary.h"
#include "shell/common/gin_helper/error_thrower.h" #include "shell/common/gin_helper/error_thrower.h"
#include "shell/common/gin_helper/handle.h"
#include "shell/common/node_includes.h" #include "shell/common/node_includes.h"
namespace gin { namespace gin {
@ -61,7 +61,7 @@ Tray::Tray(v8::Isolate* isolate,
Tray::~Tray() = default; Tray::~Tray() = default;
// static // static
gin::Handle<Tray> Tray::New(gin_helper::ErrorThrower thrower, gin_helper::Handle<Tray> Tray::New(gin_helper::ErrorThrower thrower,
v8::Local<v8::Value> image, v8::Local<v8::Value> image,
std::optional<UUID> guid, std::optional<UUID> guid,
gin::Arguments* args) { gin::Arguments* args) {
@ -88,7 +88,7 @@ gin::Handle<Tray> Tray::New(gin_helper::ErrorThrower thrower,
return {}; return {};
} }
auto handle = gin::CreateHandle(args->isolate(), tray); auto handle = gin_helper::CreateHandle(args->isolate(), tray);
handle->Pin(args->isolate()); handle->Pin(args->isolate());
return handle; return handle;
} }
@ -342,7 +342,7 @@ void Tray::Focus() {
void Tray::PopUpContextMenu(gin::Arguments* args) { void Tray::PopUpContextMenu(gin::Arguments* args) {
if (!CheckAlive()) if (!CheckAlive())
return; return;
gin::Handle<Menu> menu; gin_helper::Handle<Menu> menu;
gfx::Point pos; gfx::Point pos;
v8::Local<v8::Value> first_arg; v8::Local<v8::Value> first_arg;
@ -374,7 +374,7 @@ void Tray::SetContextMenu(gin_helper::ErrorThrower thrower,
v8::Local<v8::Value> arg) { v8::Local<v8::Value> arg) {
if (!CheckAlive()) if (!CheckAlive())
return; return;
gin::Handle<Menu> menu; gin_helper::Handle<Menu> menu;
if (arg->IsNull()) { if (arg->IsNull()) {
menu_.Reset(); menu_.Reset();
tray_icon_->SetContextMenu(nullptr); tray_icon_->SetContextMenu(nullptr);

View file

@ -24,14 +24,11 @@ class Image;
class Image; class Image;
} // namespace gfx } // namespace gfx
namespace gin {
template <typename T>
class Handle;
} // namespace gin
namespace gin_helper { namespace gin_helper {
class Dictionary; class Dictionary;
class ErrorThrower; class ErrorThrower;
template <typename T>
class Handle;
} // namespace gin_helper } // namespace gin_helper
namespace electron::api { namespace electron::api {
@ -46,7 +43,7 @@ class Tray final : public gin_helper::DeprecatedWrappable<Tray>,
private TrayIconObserver { private TrayIconObserver {
public: public:
// gin_helper::Constructible // gin_helper::Constructible
static gin::Handle<Tray> New(gin_helper::ErrorThrower thrower, static gin_helper::Handle<Tray> New(gin_helper::ErrorThrower thrower,
v8::Local<v8::Value> image, v8::Local<v8::Value> image,
std::optional<UUID> guid, std::optional<UUID> guid,
gin::Arguments* args); gin::Arguments* args);

View file

@ -17,7 +17,6 @@
#include "content/public/browser/child_process_host.h" #include "content/public/browser/child_process_host.h"
#include "content/public/browser/service_process_host.h" #include "content/public/browser/service_process_host.h"
#include "content/public/common/result_codes.h" #include "content/public/common/result_codes.h"
#include "gin/handle.h"
#include "gin/object_template_builder.h" #include "gin/object_template_builder.h"
#include "mojo/public/cpp/bindings/pending_receiver.h" #include "mojo/public/cpp/bindings/pending_receiver.h"
#include "shell/browser/api/message_port.h" #include "shell/browser/api/message_port.h"
@ -28,6 +27,7 @@
#include "shell/common/gin_converters/file_path_converter.h" #include "shell/common/gin_converters/file_path_converter.h"
#include "shell/common/gin_helper/dictionary.h" #include "shell/common/gin_helper/dictionary.h"
#include "shell/common/gin_helper/error_thrower.h" #include "shell/common/gin_helper/error_thrower.h"
#include "shell/common/gin_helper/handle.h"
#include "shell/common/gin_helper/object_template_builder.h" #include "shell/common/gin_helper/object_template_builder.h"
#include "shell/common/node_includes.h" #include "shell/common/node_includes.h"
#include "shell/common/v8_util.h" #include "shell/common/v8_util.h"
@ -347,7 +347,7 @@ void UtilityProcessWrapper::PostMessage(gin::Arguments* args) {
} }
v8::Local<v8::Value> transferables; v8::Local<v8::Value> transferables;
std::vector<gin::Handle<MessagePort>> wrapped_ports; std::vector<gin_helper::Handle<MessagePort>> wrapped_ports;
if (args->GetNext(&transferables)) { if (args->GetNext(&transferables)) {
std::vector<v8::Local<v8::Value>> wrapped_port_values; std::vector<v8::Local<v8::Value>> wrapped_port_values;
if (!gin::ConvertFromV8(args->isolate(), transferables, if (!gin::ConvertFromV8(args->isolate(), transferables,
@ -435,7 +435,7 @@ raw_ptr<UtilityProcessWrapper> UtilityProcessWrapper::FromProcessId(
} }
// static // static
gin::Handle<UtilityProcessWrapper> UtilityProcessWrapper::Create( gin_helper::Handle<UtilityProcessWrapper> UtilityProcessWrapper::Create(
gin::Arguments* args) { gin::Arguments* args) {
if (!Browser::Get()->is_ready()) { if (!Browser::Get()->is_ready()) {
gin_helper::ErrorThrower(args->isolate()) gin_helper::ErrorThrower(args->isolate())
@ -498,7 +498,7 @@ gin::Handle<UtilityProcessWrapper> UtilityProcessWrapper::Create(
opts.Get("allowLoadingUnsignedLibraries", &use_plugin_helper); opts.Get("allowLoadingUnsignedLibraries", &use_plugin_helper);
#endif #endif
} }
auto handle = gin::CreateHandle( auto handle = gin_helper::CreateHandle(
args->isolate(), new UtilityProcessWrapper( args->isolate(), new UtilityProcessWrapper(
std::move(params), display_name, std::move(stdio), std::move(params), display_name, std::move(stdio),
env_map, current_working_directory, env_map, current_working_directory,

View file

@ -25,9 +25,12 @@
namespace gin { namespace gin {
class Arguments; class Arguments;
} // namespace gin
namespace gin_helper {
template <typename T> template <typename T>
class Handle; class Handle;
} // namespace gin } // namespace gin_helper
namespace base { namespace base {
class Process; class Process;
@ -51,7 +54,7 @@ class UtilityProcessWrapper final
enum class IOType { IO_PIPE, IO_INHERIT, IO_IGNORE }; enum class IOType { IO_PIPE, IO_INHERIT, IO_IGNORE };
~UtilityProcessWrapper() override; ~UtilityProcessWrapper() override;
static gin::Handle<UtilityProcessWrapper> Create(gin::Arguments* args); static gin_helper::Handle<UtilityProcessWrapper> Create(gin::Arguments* args);
static raw_ptr<UtilityProcessWrapper> FromProcessId(base::ProcessId pid); static raw_ptr<UtilityProcessWrapper> FromProcessId(base::ProcessId pid);
void Shutdown(uint64_t exit_code); void Shutdown(uint64_t exit_code);

View file

@ -12,12 +12,12 @@
#include "ash/style/rounded_rect_cutout_path_builder.h" #include "ash/style/rounded_rect_cutout_path_builder.h"
#include "gin/data_object_builder.h" #include "gin/data_object_builder.h"
#include "gin/handle.h"
#include "gin/wrappable.h" #include "gin/wrappable.h"
#include "shell/browser/javascript_environment.h" #include "shell/browser/javascript_environment.h"
#include "shell/common/gin_converters/callback_converter.h" #include "shell/common/gin_converters/callback_converter.h"
#include "shell/common/gin_converters/gfx_converter.h" #include "shell/common/gin_converters/gfx_converter.h"
#include "shell/common/gin_helper/dictionary.h" #include "shell/common/gin_helper/dictionary.h"
#include "shell/common/gin_helper/handle.h"
#include "shell/common/gin_helper/object_template_builder.h" #include "shell/common/gin_helper/object_template_builder.h"
#include "shell/common/node_includes.h" #include "shell/common/node_includes.h"
#include "ui/views/background.h" #include "ui/views/background.h"
@ -38,7 +38,7 @@ struct Converter<views::ChildLayout> {
gin_helper::Dictionary dict; gin_helper::Dictionary dict;
if (!gin::ConvertFromV8(isolate, val, &dict)) if (!gin::ConvertFromV8(isolate, val, &dict))
return false; return false;
gin::Handle<electron::api::View> view; gin_helper::Handle<electron::api::View> view;
if (!dict.Get("view", &view)) if (!dict.Get("view", &view))
return false; return false;
out->child_view = view->view(); out->child_view = view->view();
@ -184,7 +184,7 @@ View::~View() {
view_.ClearAndDelete(); view_.ClearAndDelete();
} }
void View::ReorderChildView(gin::Handle<View> child, size_t index) { void View::ReorderChildView(gin_helper::Handle<View> child, size_t index) {
view_->ReorderChildView(child->view(), index); view_->ReorderChildView(child->view(), index);
const auto i = const auto i =
@ -207,7 +207,7 @@ void View::ReorderChildView(gin::Handle<View> child, size_t index) {
} }
} }
void View::AddChildViewAt(gin::Handle<View> child, void View::AddChildViewAt(gin_helper::Handle<View> child,
std::optional<size_t> maybe_index) { std::optional<size_t> maybe_index) {
// TODO(nornagon): !view_ is only for supporting the weird case of // TODO(nornagon): !view_ is only for supporting the weird case of
// WebContentsView's view being deleted when the underlying WebContents is // WebContentsView's view being deleted when the underlying WebContents is
@ -258,7 +258,7 @@ void View::AddChildViewAt(gin::Handle<View> child,
view_->AddChildViewAt(child->view(), index); view_->AddChildViewAt(child->view(), index);
} }
void View::RemoveChildView(gin::Handle<View> child) { void View::RemoveChildView(gin_helper::Handle<View> child) {
if (!view_) if (!view_)
return; return;
@ -432,11 +432,11 @@ v8::Local<v8::Function> View::GetConstructor(v8::Isolate* isolate) {
} }
// static // static
gin::Handle<View> View::Create(v8::Isolate* isolate) { gin_helper::Handle<View> View::Create(v8::Isolate* isolate) {
v8::Local<v8::Context> context = isolate->GetCurrentContext(); v8::Local<v8::Context> context = isolate->GetCurrentContext();
v8::Local<v8::Object> obj; v8::Local<v8::Object> obj;
if (GetConstructor(isolate)->NewInstance(context, 0, nullptr).ToLocal(&obj)) { if (GetConstructor(isolate)->NewInstance(context, 0, nullptr).ToLocal(&obj)) {
gin::Handle<View> view; gin_helper::Handle<View> view;
if (gin::ConvertFromV8(isolate, obj, &view)) if (gin::ConvertFromV8(isolate, obj, &view))
return view; return view;
} }

View file

@ -14,10 +14,10 @@
#include "ui/views/view_observer.h" #include "ui/views/view_observer.h"
#include "v8/include/v8-value.h" #include "v8/include/v8-value.h"
namespace gin { namespace gin_helper {
template <typename T> template <typename T>
class Handle; class Handle;
} // namespace gin } // namespace gin_helper
namespace electron::api { namespace electron::api {
@ -25,7 +25,7 @@ class View : public gin_helper::EventEmitter<View>,
private views::ViewObserver { private views::ViewObserver {
public: public:
static gin_helper::WrappableBase* New(gin::Arguments* args); static gin_helper::WrappableBase* New(gin::Arguments* args);
static gin::Handle<View> Create(v8::Isolate* isolate); static gin_helper::Handle<View> Create(v8::Isolate* isolate);
// Return the cached constructor function. // Return the cached constructor function.
static v8::Local<v8::Function> GetConstructor(v8::Isolate* isolate); static v8::Local<v8::Function> GetConstructor(v8::Isolate* isolate);
@ -33,8 +33,9 @@ class View : public gin_helper::EventEmitter<View>,
static void BuildPrototype(v8::Isolate* isolate, static void BuildPrototype(v8::Isolate* isolate,
v8::Local<v8::FunctionTemplate> prototype); v8::Local<v8::FunctionTemplate> prototype);
void AddChildViewAt(gin::Handle<View> child, std::optional<size_t> index); void AddChildViewAt(gin_helper::Handle<View> child,
void RemoveChildView(gin::Handle<View> child); std::optional<size_t> index);
void RemoveChildView(gin_helper::Handle<View> child);
void SetBounds(const gfx::Rect& bounds); void SetBounds(const gfx::Rect& bounds);
gfx::Rect GetBounds() const; gfx::Rect GetBounds() const;
@ -70,7 +71,7 @@ class View : public gin_helper::EventEmitter<View>,
views::View* child) override; views::View* child) override;
void ApplyBorderRadius(); void ApplyBorderRadius();
void ReorderChildView(gin::Handle<View> child, size_t index); void ReorderChildView(gin_helper::Handle<View> child, size_t index);
std::vector<ChildPair> child_views_; std::vector<ChildPair> child_views_;
std::optional<int> border_radius_; std::optional<int> border_radius_;

View file

@ -75,7 +75,6 @@
#include "electron/mas.h" #include "electron/mas.h"
#include "gin/arguments.h" #include "gin/arguments.h"
#include "gin/data_object_builder.h" #include "gin/data_object_builder.h"
#include "gin/handle.h"
#include "gin/object_template_builder.h" #include "gin/object_template_builder.h"
#include "gin/wrappable.h" #include "gin/wrappable.h"
#include "media/base/mime_util.h" #include "media/base/mime_util.h"
@ -132,6 +131,7 @@
#include "shell/common/gin_converters/value_converter.h" #include "shell/common/gin_converters/value_converter.h"
#include "shell/common/gin_helper/dictionary.h" #include "shell/common/gin_helper/dictionary.h"
#include "shell/common/gin_helper/error_thrower.h" #include "shell/common/gin_helper/error_thrower.h"
#include "shell/common/gin_helper/handle.h"
#include "shell/common/gin_helper/locker.h" #include "shell/common/gin_helper/locker.h"
#include "shell/common/gin_helper/object_template_builder.h" #include "shell/common/gin_helper/object_template_builder.h"
#include "shell/common/gin_helper/promise.h" #include "shell/common/gin_helper/promise.h"
@ -829,7 +829,7 @@ WebContents::WebContents(v8::Isolate* isolate,
// Obtain the session. // Obtain the session.
std::string partition; std::string partition;
gin::Handle<api::Session> session; gin_helper::Handle<api::Session> session;
if (options.Get("session", &session) && !session.IsEmpty()) { if (options.Get("session", &session) && !session.IsEmpty()) {
} else if (options.Get("partition", &partition)) { } else if (options.Get("partition", &partition)) {
session = Session::FromPartition(isolate, partition); session = Session::FromPartition(isolate, partition);
@ -907,7 +907,7 @@ void WebContents::InitZoomController(content::WebContents* web_contents,
void WebContents::InitWithSessionAndOptions( void WebContents::InitWithSessionAndOptions(
v8::Isolate* isolate, v8::Isolate* isolate,
std::unique_ptr<content::WebContents> owned_web_contents, std::unique_ptr<content::WebContents> owned_web_contents,
gin::Handle<api::Session> session, gin_helper::Handle<api::Session> session,
const gin_helper::Dictionary& options) { const gin_helper::Dictionary& options) {
Observe(owned_web_contents.get()); Observe(owned_web_contents.get());
InitWithWebContents(std::move(owned_web_contents), session->browser_context(), InitWithWebContents(std::move(owned_web_contents), session->browser_context(),
@ -1118,7 +1118,7 @@ void WebContents::OnDidAddMessageToConsole(
v8::Isolate* isolate = JavascriptEnvironment::GetIsolate(); v8::Isolate* isolate = JavascriptEnvironment::GetIsolate();
v8::HandleScope handle_scope(isolate); v8::HandleScope handle_scope(isolate);
gin::Handle<gin_helper::internal::Event> event = gin_helper::Handle<gin_helper::internal::Event> event =
gin_helper::internal::Event::New(isolate); gin_helper::internal::Event::New(isolate);
v8::Local<v8::Object> event_object = event.ToV8().As<v8::Object>(); v8::Local<v8::Object> event_object = event.ToV8().As<v8::Object>();
@ -1487,7 +1487,7 @@ void WebContents::RendererUnresponsive(
base::RepeatingClosure hang_monitor_restarter) { base::RepeatingClosure hang_monitor_restarter) {
v8::Isolate* isolate = JavascriptEnvironment::GetIsolate(); v8::Isolate* isolate = JavascriptEnvironment::GetIsolate();
v8::HandleScope handle_scope(isolate); v8::HandleScope handle_scope(isolate);
gin::Handle<gin_helper::internal::Event> event = gin_helper::Handle<gin_helper::internal::Event> event =
gin_helper::internal::Event::New(isolate); gin_helper::internal::Event::New(isolate);
v8::Local<v8::Object> event_object = event.ToV8().As<v8::Object>(); v8::Local<v8::Object> event_object = event.ToV8().As<v8::Object>();
gin::Dictionary dict(isolate, event_object); gin::Dictionary dict(isolate, event_object);
@ -1672,7 +1672,7 @@ content::JavaScriptDialogManager* WebContents::GetJavaScriptDialogManager(
void WebContents::OnAudioStateChanged(bool audible) { void WebContents::OnAudioStateChanged(bool audible) {
v8::Isolate* isolate = JavascriptEnvironment::GetIsolate(); v8::Isolate* isolate = JavascriptEnvironment::GetIsolate();
v8::HandleScope handle_scope(isolate); v8::HandleScope handle_scope(isolate);
gin::Handle<gin_helper::internal::Event> event = gin_helper::Handle<gin_helper::internal::Event> event =
gin_helper::internal::Event::New(isolate); gin_helper::internal::Event::New(isolate);
v8::Local<v8::Object> event_object = event.ToV8().As<v8::Object>(); v8::Local<v8::Object> event_object = event.ToV8().As<v8::Object>();
gin::Dictionary dict(isolate, event_object); gin::Dictionary dict(isolate, event_object);
@ -1940,7 +1940,7 @@ bool WebContents::EmitNavigationEvent(
v8::Isolate* isolate = JavascriptEnvironment::GetIsolate(); v8::Isolate* isolate = JavascriptEnvironment::GetIsolate();
v8::HandleScope handle_scope(isolate); v8::HandleScope handle_scope(isolate);
gin::Handle<gin_helper::internal::Event> event = gin_helper::Handle<gin_helper::internal::Event> event =
gin_helper::internal::Event::New(isolate); gin_helper::internal::Event::New(isolate);
v8::Local<v8::Object> event_object = event.ToV8().As<v8::Object>(); v8::Local<v8::Object> event_object = event.ToV8().As<v8::Object>();
@ -3599,7 +3599,7 @@ void WebContents::OnPaint(const gfx::Rect& dirty_rect,
v8::Isolate* isolate = JavascriptEnvironment::GetIsolate(); v8::Isolate* isolate = JavascriptEnvironment::GetIsolate();
v8::HandleScope handle_scope(isolate); v8::HandleScope handle_scope(isolate);
gin::Handle<gin_helper::internal::Event> event = gin_helper::Handle<gin_helper::internal::Event> event =
gin_helper::internal::Event::New(isolate); gin_helper::internal::Event::New(isolate);
v8::Local<v8::Object> event_object = event.ToV8().As<v8::Object>(); v8::Local<v8::Object> event_object = event.ToV8().As<v8::Object>();
gin_helper::Dictionary dict(isolate, event_object); gin_helper::Dictionary dict(isolate, event_object);
@ -4514,11 +4514,11 @@ ElectronBrowserContext* WebContents::GetBrowserContext() const {
} }
// static // static
gin::Handle<WebContents> WebContents::New( gin_helper::Handle<WebContents> WebContents::New(
v8::Isolate* isolate, v8::Isolate* isolate,
const gin_helper::Dictionary& options) { const gin_helper::Dictionary& options) {
gin::Handle<WebContents> handle = gin_helper::Handle<WebContents> handle =
gin::CreateHandle(isolate, new WebContents(isolate, options)); gin_helper::CreateHandle(isolate, new WebContents(isolate, options));
v8::TryCatch try_catch(isolate); v8::TryCatch try_catch(isolate);
gin_helper::CallMethod(isolate, handle.get(), "_init"); gin_helper::CallMethod(isolate, handle.get(), "_init");
if (try_catch.HasCaught()) { if (try_catch.HasCaught()) {
@ -4528,11 +4528,11 @@ gin::Handle<WebContents> WebContents::New(
} }
// static // static
gin::Handle<WebContents> WebContents::CreateAndTake( gin_helper::Handle<WebContents> WebContents::CreateAndTake(
v8::Isolate* isolate, v8::Isolate* isolate,
std::unique_ptr<content::WebContents> web_contents, std::unique_ptr<content::WebContents> web_contents,
Type type) { Type type) {
gin::Handle<WebContents> handle = gin::CreateHandle( gin_helper::Handle<WebContents> handle = gin_helper::CreateHandle(
isolate, new WebContents(isolate, std::move(web_contents), type)); isolate, new WebContents(isolate, std::move(web_contents), type));
v8::TryCatch try_catch(isolate); v8::TryCatch try_catch(isolate);
gin_helper::CallMethod(isolate, handle.get(), "_init"); gin_helper::CallMethod(isolate, handle.get(), "_init");
@ -4552,7 +4552,7 @@ WebContents* WebContents::From(content::WebContents* web_contents) {
} }
// static // static
gin::Handle<WebContents> WebContents::FromOrCreate( gin_helper::Handle<WebContents> WebContents::FromOrCreate(
v8::Isolate* isolate, v8::Isolate* isolate,
content::WebContents* web_contents) { content::WebContents* web_contents) {
WebContents* api_web_contents = From(web_contents); WebContents* api_web_contents = From(web_contents);
@ -4564,15 +4564,15 @@ gin::Handle<WebContents> WebContents::FromOrCreate(
node::errors::TriggerUncaughtException(isolate, try_catch); node::errors::TriggerUncaughtException(isolate, try_catch);
} }
} }
return gin::CreateHandle(isolate, api_web_contents); return gin_helper::CreateHandle(isolate, api_web_contents);
} }
// static // static
gin::Handle<WebContents> WebContents::CreateFromWebPreferences( gin_helper::Handle<WebContents> WebContents::CreateFromWebPreferences(
v8::Isolate* isolate, v8::Isolate* isolate,
const gin_helper::Dictionary& web_preferences) { const gin_helper::Dictionary& web_preferences) {
// Check if webPreferences has |webContents| option. // Check if webPreferences has |webContents| option.
gin::Handle<WebContents> web_contents; gin_helper::Handle<WebContents> web_contents;
if (web_preferences.GetHidden("webContents", &web_contents) && if (web_preferences.GetHidden("webContents", &web_contents) &&
!web_contents.IsEmpty()) { !web_contents.IsEmpty()) {
// Set webPreferences from options if using an existing webContents. // Set webPreferences from options if using an existing webContents.
@ -4627,37 +4627,38 @@ using electron::api::GetAllWebContents;
using electron::api::WebContents; using electron::api::WebContents;
using electron::api::WebFrameMain; using electron::api::WebFrameMain;
gin::Handle<WebContents> WebContentsFromID(v8::Isolate* isolate, int32_t id) { gin_helper::Handle<WebContents> WebContentsFromID(v8::Isolate* isolate,
int32_t id) {
WebContents* contents = WebContents::FromID(id); WebContents* contents = WebContents::FromID(id);
return contents ? gin::CreateHandle(isolate, contents) return contents ? gin_helper::CreateHandle(isolate, contents)
: gin::Handle<WebContents>(); : gin_helper::Handle<WebContents>();
} }
gin::Handle<WebContents> WebContentsFromFrame(v8::Isolate* isolate, gin_helper::Handle<WebContents> WebContentsFromFrame(v8::Isolate* isolate,
WebFrameMain* web_frame) { WebFrameMain* web_frame) {
content::RenderFrameHost* rfh = web_frame->render_frame_host(); content::RenderFrameHost* rfh = web_frame->render_frame_host();
content::WebContents* source = content::WebContents::FromRenderFrameHost(rfh); content::WebContents* source = content::WebContents::FromRenderFrameHost(rfh);
WebContents* contents = WebContents::From(source); WebContents* contents = WebContents::From(source);
return contents ? gin::CreateHandle(isolate, contents) return contents ? gin_helper::CreateHandle(isolate, contents)
: gin::Handle<WebContents>(); : gin_helper::Handle<WebContents>();
} }
gin::Handle<WebContents> WebContentsFromDevToolsTargetID( gin_helper::Handle<WebContents> WebContentsFromDevToolsTargetID(
v8::Isolate* isolate, v8::Isolate* isolate,
std::string target_id) { std::string target_id) {
auto agent_host = content::DevToolsAgentHost::GetForId(target_id); auto agent_host = content::DevToolsAgentHost::GetForId(target_id);
WebContents* contents = WebContents* contents =
agent_host ? WebContents::From(agent_host->GetWebContents()) : nullptr; agent_host ? WebContents::From(agent_host->GetWebContents()) : nullptr;
return contents ? gin::CreateHandle(isolate, contents) return contents ? gin_helper::CreateHandle(isolate, contents)
: gin::Handle<WebContents>(); : gin_helper::Handle<WebContents>();
} }
std::vector<gin::Handle<WebContents>> GetAllWebContentsAsV8( std::vector<gin_helper::Handle<WebContents>> GetAllWebContentsAsV8(
v8::Isolate* isolate) { v8::Isolate* isolate) {
std::vector<gin::Handle<WebContents>> list; std::vector<gin_helper::Handle<WebContents>> list;
for (auto iter = base::IDMap<WebContents*>::iterator(&GetAllWebContents()); for (auto iter = base::IDMap<WebContents*>::iterator(&GetAllWebContents());
!iter.IsAtEnd(); iter.Advance()) { !iter.IsAtEnd(); iter.Advance()) {
list.push_back(gin::CreateHandle(isolate, iter.GetCurrentValue())); list.push_back(gin_helper::CreateHandle(isolate, iter.GetCurrentValue()));
} }
return list; return list;
} }

View file

@ -30,7 +30,6 @@
#include "content/public/browser/web_contents_observer.h" #include "content/public/browser/web_contents_observer.h"
#include "content/public/common/stop_find_action.h" #include "content/public/common/stop_find_action.h"
#include "electron/buildflags/buildflags.h" #include "electron/buildflags/buildflags.h"
#include "gin/handle.h"
#include "printing/buildflags/buildflags.h" #include "printing/buildflags/buildflags.h"
#include "shell/browser/api/save_page_handler.h" #include "shell/browser/api/save_page_handler.h"
#include "shell/browser/background_throttling_source.h" #include "shell/browser/background_throttling_source.h"
@ -43,6 +42,7 @@
#include "shell/common/api/api.mojom.h" #include "shell/common/api/api.mojom.h"
#include "shell/common/gin_helper/cleaned_up_at_exit.h" #include "shell/common/gin_helper/cleaned_up_at_exit.h"
#include "shell/common/gin_helper/constructible.h" #include "shell/common/gin_helper/constructible.h"
#include "shell/common/gin_helper/handle.h"
#include "shell/common/gin_helper/pinnable.h" #include "shell/common/gin_helper/pinnable.h"
#include "shell/common/gin_helper/wrappable.h" #include "shell/common/gin_helper/wrappable.h"
#include "shell/common/web_contents_utility.mojom.h" #include "shell/common/web_contents_utility.mojom.h"
@ -135,13 +135,14 @@ class WebContents final : public ExclusiveAccessContext,
}; };
// Create a new WebContents and return the V8 wrapper of it. // Create a new WebContents and return the V8 wrapper of it.
static gin::Handle<WebContents> New(v8::Isolate* isolate, static gin_helper::Handle<WebContents> New(
v8::Isolate* isolate,
const gin_helper::Dictionary& options); const gin_helper::Dictionary& options);
// Create a new V8 wrapper for an existing |web_content|. // Create a new V8 wrapper for an existing |web_content|.
// //
// The lifetime of |web_contents| will be managed by this class. // The lifetime of |web_contents| will be managed by this class.
static gin::Handle<WebContents> CreateAndTake( static gin_helper::Handle<WebContents> CreateAndTake(
v8::Isolate* isolate, v8::Isolate* isolate,
std::unique_ptr<content::WebContents> web_contents, std::unique_ptr<content::WebContents> web_contents,
Type type); Type type);
@ -160,11 +161,11 @@ class WebContents final : public ExclusiveAccessContext,
// //
// The lifetime of |web_contents| is NOT managed by this class, and the type // The lifetime of |web_contents| is NOT managed by this class, and the type
// of this wrapper is always REMOTE. // of this wrapper is always REMOTE.
static gin::Handle<WebContents> FromOrCreate( static gin_helper::Handle<WebContents> FromOrCreate(
v8::Isolate* isolate, v8::Isolate* isolate,
content::WebContents* web_contents); content::WebContents* web_contents);
static gin::Handle<WebContents> CreateFromWebPreferences( static gin_helper::Handle<WebContents> CreateFromWebPreferences(
v8::Isolate* isolate, v8::Isolate* isolate,
const gin_helper::Dictionary& web_preferences); const gin_helper::Dictionary& web_preferences);
@ -478,7 +479,7 @@ class WebContents final : public ExclusiveAccessContext,
void InitWithSessionAndOptions( void InitWithSessionAndOptions(
v8::Isolate* isolate, v8::Isolate* isolate,
std::unique_ptr<content::WebContents> web_contents, std::unique_ptr<content::WebContents> web_contents,
gin::Handle<class Session> session, gin_helper::Handle<class Session> session,
const gin_helper::Dictionary& options); const gin_helper::Dictionary& options);
#if BUILDFLAG(ENABLE_ELECTRON_EXTENSIONS) #if BUILDFLAG(ENABLE_ELECTRON_EXTENSIONS)

View file

@ -30,7 +30,7 @@
namespace electron::api { namespace electron::api {
WebContentsView::WebContentsView(v8::Isolate* isolate, WebContentsView::WebContentsView(v8::Isolate* isolate,
gin::Handle<WebContents> web_contents) gin_helper::Handle<WebContents> web_contents)
: View(web_contents->inspectable_web_contents()->GetView()), : View(web_contents->inspectable_web_contents()->GetView()),
web_contents_(isolate, web_contents.ToV8()), web_contents_(isolate, web_contents.ToV8()),
api_web_contents_(web_contents.get()) { api_web_contents_(web_contents.get()) {
@ -47,9 +47,10 @@ WebContentsView::~WebContentsView() {
api_web_contents_->Destroy(); api_web_contents_->Destroy();
} }
gin::Handle<WebContents> WebContentsView::GetWebContents(v8::Isolate* isolate) { gin_helper::Handle<WebContents> WebContentsView::GetWebContents(
v8::Isolate* isolate) {
if (api_web_contents_) if (api_web_contents_)
return gin::CreateHandle(isolate, api_web_contents_.get()); return gin_helper::CreateHandle(isolate, api_web_contents_.get());
else else
return {}; return {};
} }
@ -122,7 +123,7 @@ void WebContentsView::OnViewRemovedFromWidget(views::View* observed_view) {
} }
// static // static
gin::Handle<WebContentsView> WebContentsView::Create( gin_helper::Handle<WebContentsView> WebContentsView::Create(
v8::Isolate* isolate, v8::Isolate* isolate,
const gin_helper::Dictionary& web_preferences) { const gin_helper::Dictionary& web_preferences) {
v8::Local<v8::Context> context = isolate->GetCurrentContext(); v8::Local<v8::Context> context = isolate->GetCurrentContext();
@ -133,7 +134,7 @@ gin::Handle<WebContentsView> WebContentsView::Create(
if (GetConstructor(isolate) if (GetConstructor(isolate)
->NewInstance(context, 1, &arg) ->NewInstance(context, 1, &arg)
.ToLocal(&web_contents_view_obj)) { .ToLocal(&web_contents_view_obj)) {
gin::Handle<WebContentsView> web_contents_view; gin_helper::Handle<WebContentsView> web_contents_view;
if (gin::ConvertFromV8(isolate, web_contents_view_obj, &web_contents_view)) if (gin::ConvertFromV8(isolate, web_contents_view_obj, &web_contents_view))
return web_contents_view; return web_contents_view;
} }
@ -173,7 +174,7 @@ gin_helper::WrappableBase* WebContentsView::New(gin_helper::Arguments* args) {
} }
if (options.Get("webContents", &existing_web_contents_value)) { if (options.Get("webContents", &existing_web_contents_value)) {
gin::Handle<WebContents> existing_web_contents; gin_helper::Handle<WebContents> existing_web_contents;
if (!gin::ConvertFromV8(args->isolate(), existing_web_contents_value, if (!gin::ConvertFromV8(args->isolate(), existing_web_contents_value,
&existing_web_contents)) { &existing_web_contents)) {
args->ThrowError("options.webContents must be a WebContents"); args->ThrowError("options.webContents must be a WebContents");

View file

@ -25,7 +25,7 @@ class WebContentsView : public View,
public DraggableRegionProvider { public DraggableRegionProvider {
public: public:
// Create a new instance of WebContentsView. // Create a new instance of WebContentsView.
static gin::Handle<WebContentsView> Create( static gin_helper::Handle<WebContentsView> Create(
v8::Isolate* isolate, v8::Isolate* isolate,
const gin_helper::Dictionary& web_preferences); const gin_helper::Dictionary& web_preferences);
@ -37,7 +37,7 @@ class WebContentsView : public View,
v8::Local<v8::FunctionTemplate> prototype); v8::Local<v8::FunctionTemplate> prototype);
// Public APIs. // Public APIs.
gin::Handle<WebContents> GetWebContents(v8::Isolate* isolate); gin_helper::Handle<WebContents> GetWebContents(v8::Isolate* isolate);
void SetBackgroundColor(std::optional<WrappedSkColor> color); void SetBackgroundColor(std::optional<WrappedSkColor> color);
void SetBorderRadius(int radius); void SetBorderRadius(int radius);
@ -45,7 +45,8 @@ class WebContentsView : public View,
protected: protected:
// Takes an existing WebContents. // Takes an existing WebContents.
WebContentsView(v8::Isolate* isolate, gin::Handle<WebContents> web_contents); WebContentsView(v8::Isolate* isolate,
gin_helper::Handle<WebContents> web_contents);
~WebContentsView() override; ~WebContentsView() override;
// content::WebContentsObserver: // content::WebContentsObserver:

View file

@ -17,7 +17,6 @@
#include "content/public/browser/frame_tree_node_id.h" #include "content/public/browser/frame_tree_node_id.h"
#include "content/public/browser/render_frame_host.h" #include "content/public/browser/render_frame_host.h"
#include "content/public/common/isolated_world_ids.h" #include "content/public/common/isolated_world_ids.h"
#include "gin/handle.h"
#include "gin/object_template_builder.h" #include "gin/object_template_builder.h"
#include "services/service_manager/public/cpp/interface_provider.h" #include "services/service_manager/public/cpp/interface_provider.h"
#include "shell/browser/api/message_port.h" #include "shell/browser/api/message_port.h"
@ -31,6 +30,7 @@
#include "shell/common/gin_converters/value_converter.h" #include "shell/common/gin_converters/value_converter.h"
#include "shell/common/gin_helper/dictionary.h" #include "shell/common/gin_helper/dictionary.h"
#include "shell/common/gin_helper/error_thrower.h" #include "shell/common/gin_helper/error_thrower.h"
#include "shell/common/gin_helper/handle.h"
#include "shell/common/gin_helper/object_template_builder.h" #include "shell/common/gin_helper/object_template_builder.h"
#include "shell/common/gin_helper/promise.h" #include "shell/common/gin_helper/promise.h"
#include "shell/common/node_includes.h" #include "shell/common/node_includes.h"
@ -347,7 +347,7 @@ void WebFrameMain::PostMessage(v8::Isolate* isolate,
return; return;
} }
std::vector<gin::Handle<MessagePort>> wrapped_ports; std::vector<gin_helper::Handle<MessagePort>> wrapped_ports;
if (transfer && !transfer.value()->IsUndefined()) { if (transfer && !transfer.value()->IsUndefined()) {
if (!gin::ConvertFromV8(isolate, *transfer, &wrapped_ports)) { if (!gin::ConvertFromV8(isolate, *transfer, &wrapped_ports)) {
isolate->ThrowException(v8::Exception::Error( isolate->ThrowException(v8::Exception::Error(
@ -539,12 +539,13 @@ void WebFrameMain::DOMContentLoaded() {
} }
// static // static
gin::Handle<WebFrameMain> WebFrameMain::New(v8::Isolate* isolate) { gin_helper::Handle<WebFrameMain> WebFrameMain::New(v8::Isolate* isolate) {
return {}; return {};
} }
// static // static
gin::Handle<WebFrameMain> WebFrameMain::From(v8::Isolate* isolate, gin_helper::Handle<WebFrameMain> WebFrameMain::From(
v8::Isolate* isolate,
content::RenderFrameHost* rfh) { content::RenderFrameHost* rfh) {
if (!rfh) if (!rfh)
return {}; return {};
@ -575,9 +576,9 @@ gin::Handle<WebFrameMain> WebFrameMain::From(v8::Isolate* isolate,
} }
if (web_frame) if (web_frame)
return gin::CreateHandle(isolate, web_frame); return gin_helper::CreateHandle(isolate, web_frame);
auto handle = gin::CreateHandle(isolate, new WebFrameMain(rfh)); auto handle = gin_helper::CreateHandle(isolate, new WebFrameMain(rfh));
// Prevent garbage collection of frame until it has been deleted internally. // Prevent garbage collection of frame until it has been deleted internally.
handle->Pin(isolate); handle->Pin(isolate);
@ -678,7 +679,7 @@ v8::Local<v8::Value> FromIdIfExists(gin_helper::ErrorThrower thrower,
WebFrameMain* web_frame = WebFrameMain::FromRenderFrameHost(rfh); WebFrameMain* web_frame = WebFrameMain::FromRenderFrameHost(rfh);
if (!web_frame) if (!web_frame)
return v8::Null(thrower.isolate()); return v8::Null(thrower.isolate());
return gin::CreateHandle(thrower.isolate(), web_frame).ToV8(); return gin_helper::CreateHandle(thrower.isolate(), web_frame).ToV8();
} }
v8::Local<v8::Value> FromFtnIdIfExists(gin_helper::ErrorThrower thrower, v8::Local<v8::Value> FromFtnIdIfExists(gin_helper::ErrorThrower thrower,
@ -691,7 +692,7 @@ v8::Local<v8::Value> FromFtnIdIfExists(gin_helper::ErrorThrower thrower,
content::FrameTreeNodeId(frame_tree_node_id)); content::FrameTreeNodeId(frame_tree_node_id));
if (!web_frame) if (!web_frame)
return v8::Null(thrower.isolate()); return v8::Null(thrower.isolate());
return gin::CreateHandle(thrower.isolate(), web_frame).ToV8(); return gin_helper::CreateHandle(thrower.isolate(), web_frame).ToV8();
} }
void Initialize(v8::Local<v8::Object> exports, void Initialize(v8::Local<v8::Object> exports,

View file

@ -32,10 +32,12 @@ class RenderFrameHost;
namespace gin { namespace gin {
class Arguments; class Arguments;
} // namespace gin
namespace gin_helper {
template <typename T> template <typename T>
class Handle; class Handle;
} // namespace gin } // namespace gin_helper
namespace gin_helper { namespace gin_helper {
template <typename T> template <typename T>
@ -53,9 +55,9 @@ class WebFrameMain final : public gin_helper::DeprecatedWrappable<WebFrameMain>,
public gin_helper::Constructible<WebFrameMain> { public gin_helper::Constructible<WebFrameMain> {
public: public:
// Create a new WebFrameMain and return the V8 wrapper of it. // Create a new WebFrameMain and return the V8 wrapper of it.
static gin::Handle<WebFrameMain> New(v8::Isolate* isolate); static gin_helper::Handle<WebFrameMain> New(v8::Isolate* isolate);
static gin::Handle<WebFrameMain> From( static gin_helper::Handle<WebFrameMain> From(
v8::Isolate* isolate, v8::Isolate* isolate,
content::RenderFrameHost* render_frame_host); content::RenderFrameHost* render_frame_host);
static WebFrameMain* FromFrameTreeNodeId( static WebFrameMain* FromFrameTreeNodeId(

View file

@ -19,7 +19,6 @@
#include "extensions/common/url_pattern.h" #include "extensions/common/url_pattern.h"
#include "gin/converter.h" #include "gin/converter.h"
#include "gin/dictionary.h" #include "gin/dictionary.h"
#include "gin/handle.h"
#include "gin/object_template_builder.h" #include "gin/object_template_builder.h"
#include "shell/browser/api/electron_api_session.h" #include "shell/browser/api/electron_api_session.h"
#include "shell/browser/api/electron_api_web_contents.h" #include "shell/browser/api/electron_api_web_contents.h"
@ -33,6 +32,7 @@
#include "shell/common/gin_converters/std_converter.h" #include "shell/common/gin_converters/std_converter.h"
#include "shell/common/gin_converters/value_converter.h" #include "shell/common/gin_converters/value_converter.h"
#include "shell/common/gin_helper/dictionary.h" #include "shell/common/gin_helper/dictionary.h"
#include "shell/common/gin_helper/handle.h"
#include "shell/common/node_util.h" #include "shell/common/node_util.h"
static constexpr auto ResourceTypes = static constexpr auto ResourceTypes =
@ -733,10 +733,10 @@ void WebRequest::HandleSimpleEvent(SimpleEvent event,
} }
// static // static
gin::Handle<WebRequest> WebRequest::FromOrCreate( gin_helper::Handle<WebRequest> WebRequest::FromOrCreate(
v8::Isolate* isolate, v8::Isolate* isolate,
content::BrowserContext* browser_context) { content::BrowserContext* browser_context) {
gin::Handle<WebRequest> handle = From(isolate, browser_context); gin_helper::Handle<WebRequest> handle = From(isolate, browser_context);
if (handle.IsEmpty()) { if (handle.IsEmpty()) {
// Make sure the |Session| object has the |webRequest| property created. // Make sure the |Session| object has the |webRequest| property created.
v8::Local<v8::Value> web_request = v8::Local<v8::Value> web_request =
@ -750,16 +750,17 @@ gin::Handle<WebRequest> WebRequest::FromOrCreate(
} }
// static // static
gin::Handle<WebRequest> WebRequest::Create( gin_helper::Handle<WebRequest> WebRequest::Create(
v8::Isolate* isolate, v8::Isolate* isolate,
content::BrowserContext* browser_context) { content::BrowserContext* browser_context) {
DCHECK(From(isolate, browser_context).IsEmpty()) DCHECK(From(isolate, browser_context).IsEmpty())
<< "WebRequest already created"; << "WebRequest already created";
return gin::CreateHandle(isolate, new WebRequest(isolate, browser_context)); return gin_helper::CreateHandle(isolate,
new WebRequest(isolate, browser_context));
} }
// static // static
gin::Handle<WebRequest> WebRequest::From( gin_helper::Handle<WebRequest> WebRequest::From(
v8::Isolate* isolate, v8::Isolate* isolate,
content::BrowserContext* browser_context) { content::BrowserContext* browser_context) {
if (!browser_context) if (!browser_context)
@ -768,7 +769,7 @@ gin::Handle<WebRequest> WebRequest::From(
static_cast<UserData*>(browser_context->GetUserData(kUserDataKey)); static_cast<UserData*>(browser_context->GetUserData(kUserDataKey));
if (!user_data) if (!user_data)
return {}; return {};
return gin::CreateHandle(isolate, user_data->data.get()); return gin_helper::CreateHandle(isolate, user_data->data.get());
} }
} // namespace electron::api } // namespace electron::api

View file

@ -24,10 +24,12 @@ enum class WebRequestResourceType : uint8_t;
namespace gin { namespace gin {
class Arguments; class Arguments;
} // namespace gin
namespace gin_helper {
template <typename T> template <typename T>
class Handle; class Handle;
} // namespace gin } // namespace gin_helper
namespace electron::api { namespace electron::api {
@ -38,17 +40,18 @@ class WebRequest final : public gin_helper::DeprecatedWrappable<WebRequest>,
// is no one. // is no one.
// Note that the lifetime of WebRequest object is managed by Session, instead // Note that the lifetime of WebRequest object is managed by Session, instead
// of the caller. // of the caller.
static gin::Handle<WebRequest> FromOrCreate( static gin_helper::Handle<WebRequest> FromOrCreate(
v8::Isolate* isolate, v8::Isolate* isolate,
content::BrowserContext* browser_context); content::BrowserContext* browser_context);
// Return a new WebRequest object, this should only be called by Session. // Return a new WebRequest object, this should only be called by Session.
static gin::Handle<WebRequest> Create( static gin_helper::Handle<WebRequest> Create(
v8::Isolate* isolate, v8::Isolate* isolate,
content::BrowserContext* browser_context); content::BrowserContext* browser_context);
// Find the WebRequest object attached to |browser_context|. // Find the WebRequest object attached to |browser_context|.
static gin::Handle<WebRequest> From(v8::Isolate* isolate, static gin_helper::Handle<WebRequest> From(
v8::Isolate* isolate,
content::BrowserContext* browser_context); content::BrowserContext* browser_context);
static const char* GetClassName() { return "WebRequest"; } static const char* GetClassName() { return "WebRequest"; }

View file

@ -9,13 +9,13 @@
#include "base/trace_event/trace_event.h" #include "base/trace_event/trace_event.h"
#include "base/values.h" #include "base/values.h"
#include "gin/handle.h"
#include "shell/browser/api/message_port.h" #include "shell/browser/api/message_port.h"
#include "shell/browser/javascript_environment.h" #include "shell/browser/javascript_environment.h"
#include "shell/common/api/api.mojom.h" #include "shell/common/api/api.mojom.h"
#include "shell/common/gin_converters/blink_converter.h" #include "shell/common/gin_converters/blink_converter.h"
#include "shell/common/gin_helper/dictionary.h" #include "shell/common/gin_helper/dictionary.h"
#include "shell/common/gin_helper/event.h" #include "shell/common/gin_helper/event.h"
#include "shell/common/gin_helper/handle.h"
#include "shell/common/gin_helper/reply_channel.h" #include "shell/common/gin_helper/reply_channel.h"
#include "shell/common/v8_util.h" #include "shell/common/v8_util.h"
@ -26,14 +26,14 @@ namespace electron {
template <typename T> template <typename T>
class IpcDispatcher { class IpcDispatcher {
public: public:
void Message(gin::Handle<gin_helper::internal::Event>& event, void Message(gin_helper::Handle<gin_helper::internal::Event>& event,
const std::string& channel, const std::string& channel,
blink::CloneableMessage args) { blink::CloneableMessage args) {
TRACE_EVENT1("electron", "IpcDispatcher::Message", "channel", channel); TRACE_EVENT1("electron", "IpcDispatcher::Message", "channel", channel);
emitter()->EmitWithoutEvent("-ipc-message", event, channel, args); emitter()->EmitWithoutEvent("-ipc-message", event, channel, args);
} }
void Invoke(gin::Handle<gin_helper::internal::Event>& event, void Invoke(gin_helper::Handle<gin_helper::internal::Event>& event,
const std::string& channel, const std::string& channel,
blink::CloneableMessage arguments) { blink::CloneableMessage arguments) {
TRACE_EVENT1("electron", "IpcDispatcher::Invoke", "channel", channel); TRACE_EVENT1("electron", "IpcDispatcher::Invoke", "channel", channel);
@ -41,7 +41,8 @@ class IpcDispatcher {
std::move(arguments)); std::move(arguments));
} }
void ReceivePostMessage(gin::Handle<gin_helper::internal::Event>& event, void ReceivePostMessage(
gin_helper::Handle<gin_helper::internal::Event>& event,
const std::string& channel, const std::string& channel,
blink::TransferableMessage message) { blink::TransferableMessage message) {
TRACE_EVENT1("electron", "IpcDispatcher::ReceivePostMessage", "channel", TRACE_EVENT1("electron", "IpcDispatcher::ReceivePostMessage", "channel",
@ -56,7 +57,7 @@ class IpcDispatcher {
std::move(wrapped_ports)); std::move(wrapped_ports));
} }
void MessageSync(gin::Handle<gin_helper::internal::Event>& event, void MessageSync(gin_helper::Handle<gin_helper::internal::Event>& event,
const std::string& channel, const std::string& channel,
blink::CloneableMessage arguments) { blink::CloneableMessage arguments) {
TRACE_EVENT1("electron", "IpcDispatcher::MessageSync", "channel", channel); TRACE_EVENT1("electron", "IpcDispatcher::MessageSync", "channel", channel);
@ -64,7 +65,7 @@ class IpcDispatcher {
std::move(arguments)); std::move(arguments));
} }
void MessageHost(gin::Handle<gin_helper::internal::Event>& event, void MessageHost(gin_helper::Handle<gin_helper::internal::Event>& event,
const std::string& channel, const std::string& channel,
blink::CloneableMessage arguments) { blink::CloneableMessage arguments) {
TRACE_EVENT1("electron", "IpcDispatcher::MessageHost", "channel", channel); TRACE_EVENT1("electron", "IpcDispatcher::MessageHost", "channel", channel);

View file

@ -12,12 +12,12 @@
#include "base/task/single_thread_task_runner.h" #include "base/task/single_thread_task_runner.h"
#include "gin/arguments.h" #include "gin/arguments.h"
#include "gin/data_object_builder.h" #include "gin/data_object_builder.h"
#include "gin/handle.h"
#include "gin/object_template_builder.h" #include "gin/object_template_builder.h"
#include "shell/browser/javascript_environment.h" #include "shell/browser/javascript_environment.h"
#include "shell/common/gin_helper/dictionary.h" #include "shell/common/gin_helper/dictionary.h"
#include "shell/common/gin_helper/error_thrower.h" #include "shell/common/gin_helper/error_thrower.h"
#include "shell/common/gin_helper/event_emitter_caller.h" #include "shell/common/gin_helper/event_emitter_caller.h"
#include "shell/common/gin_helper/handle.h"
#include "shell/common/gin_helper/wrappable.h" #include "shell/common/gin_helper/wrappable.h"
#include "shell/common/node_includes.h" #include "shell/common/node_includes.h"
#include "shell/common/v8_util.h" #include "shell/common/v8_util.h"
@ -42,8 +42,8 @@ MessagePort::~MessagePort() {
} }
// static // static
gin::Handle<MessagePort> MessagePort::Create(v8::Isolate* isolate) { gin_helper::Handle<MessagePort> MessagePort::Create(v8::Isolate* isolate) {
return gin::CreateHandle(isolate, new MessagePort()); return gin_helper::CreateHandle(isolate, new MessagePort());
} }
bool MessagePort::IsEntangled() const { bool MessagePort::IsEntangled() const {
@ -73,7 +73,7 @@ void MessagePort::PostMessage(gin::Arguments* args) {
} }
v8::Local<v8::Value> transferables; v8::Local<v8::Value> transferables;
std::vector<gin::Handle<MessagePort>> wrapped_ports; std::vector<gin_helper::Handle<MessagePort>> wrapped_ports;
if (args->GetNext(&transferables)) { if (args->GetNext(&transferables)) {
std::vector<v8::Local<v8::Value>> wrapped_port_values; std::vector<v8::Local<v8::Value>> wrapped_port_values;
if (!gin::ConvertFromV8(args->isolate(), transferables, if (!gin::ConvertFromV8(args->isolate(), transferables,
@ -190,10 +190,10 @@ bool MessagePort::HasPendingActivity() const {
} }
// static // static
std::vector<gin::Handle<MessagePort>> MessagePort::EntanglePorts( std::vector<gin_helper::Handle<MessagePort>> MessagePort::EntanglePorts(
v8::Isolate* isolate, v8::Isolate* isolate,
std::vector<blink::MessagePortChannel> channels) { std::vector<blink::MessagePortChannel> channels) {
std::vector<gin::Handle<MessagePort>> wrapped_ports; std::vector<gin_helper::Handle<MessagePort>> wrapped_ports;
for (auto& port : channels) { for (auto& port : channels) {
auto wrapped_port = MessagePort::Create(isolate); auto wrapped_port = MessagePort::Create(isolate);
wrapped_port->Entangle(std::move(port)); wrapped_port->Entangle(std::move(port));
@ -205,7 +205,7 @@ std::vector<gin::Handle<MessagePort>> MessagePort::EntanglePorts(
// static // static
std::vector<blink::MessagePortChannel> MessagePort::DisentanglePorts( std::vector<blink::MessagePortChannel> MessagePort::DisentanglePorts(
v8::Isolate* isolate, v8::Isolate* isolate,
const std::vector<gin::Handle<MessagePort>>& ports, const std::vector<gin_helper::Handle<MessagePort>>& ports,
bool* threw_exception) { bool* threw_exception) {
if (ports.empty()) if (ports.empty())
return {}; return {};

View file

@ -16,9 +16,12 @@
namespace gin { namespace gin {
class Arguments; class Arguments;
} // namespace gin
namespace gin_helper {
template <typename T> template <typename T>
class Handle; class Handle;
} // namespace gin } // namespace gin_helper
namespace mojo { namespace mojo {
class Connector; class Connector;
@ -32,7 +35,7 @@ class MessagePort final : public gin_helper::DeprecatedWrappable<MessagePort>,
private mojo::MessageReceiver { private mojo::MessageReceiver {
public: public:
~MessagePort() override; ~MessagePort() override;
static gin::Handle<MessagePort> Create(v8::Isolate* isolate); static gin_helper::Handle<MessagePort> Create(v8::Isolate* isolate);
void PostMessage(gin::Arguments* args); void PostMessage(gin::Arguments* args);
void Start(); void Start();
@ -46,13 +49,13 @@ class MessagePort final : public gin_helper::DeprecatedWrappable<MessagePort>,
[[nodiscard]] bool IsEntangled() const; [[nodiscard]] bool IsEntangled() const;
[[nodiscard]] bool IsNeutered() const; [[nodiscard]] bool IsNeutered() const;
static std::vector<gin::Handle<MessagePort>> EntanglePorts( static std::vector<gin_helper::Handle<MessagePort>> EntanglePorts(
v8::Isolate* isolate, v8::Isolate* isolate,
std::vector<blink::MessagePortChannel> channels); std::vector<blink::MessagePortChannel> channels);
static std::vector<blink::MessagePortChannel> DisentanglePorts( static std::vector<blink::MessagePortChannel> DisentanglePorts(
v8::Isolate* isolate, v8::Isolate* isolate,
const std::vector<gin::Handle<MessagePort>>& ports, const std::vector<gin_helper::Handle<MessagePort>>& ports,
bool* threw_exception); bool* threw_exception);
// gin_helper::Wrappable // gin_helper::Wrappable

View file

@ -5,8 +5,8 @@
#ifndef ELECTRON_SHELL_BROWSER_API_VIEWS_ELECTRON_API_IMAGE_VIEW_H_ #ifndef ELECTRON_SHELL_BROWSER_API_VIEWS_ELECTRON_API_IMAGE_VIEW_H_
#define ELECTRON_SHELL_BROWSER_API_VIEWS_ELECTRON_API_IMAGE_VIEW_H_ #define ELECTRON_SHELL_BROWSER_API_VIEWS_ELECTRON_API_IMAGE_VIEW_H_
#include "gin/handle.h"
#include "shell/browser/api/electron_api_view.h" #include "shell/browser/api/electron_api_view.h"
#include "shell/common/gin_helper/handle.h"
#include "ui/views/controls/image_view.h" #include "ui/views/controls/image_view.h"
namespace gfx { namespace gfx {

View file

@ -9,12 +9,12 @@
#include "content/public/browser/render_frame_host.h" #include "content/public/browser/render_frame_host.h"
#include "content/public/browser/render_process_host.h" #include "content/public/browser/render_process_host.h"
#include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents.h"
#include "gin/handle.h"
#include "mojo/public/cpp/bindings/self_owned_receiver.h" #include "mojo/public/cpp/bindings/self_owned_receiver.h"
#include "shell/browser/api/electron_api_session.h" #include "shell/browser/api/electron_api_session.h"
#include "shell/common/gin_converters/content_converter.h" #include "shell/common/gin_converters/content_converter.h"
#include "shell/common/gin_converters/frame_converter.h" #include "shell/common/gin_converters/frame_converter.h"
#include "shell/common/gin_helper/event.h" #include "shell/common/gin_helper/event.h"
#include "shell/common/gin_helper/handle.h"
namespace electron { namespace electron {
ElectronApiIPCHandlerImpl::ElectronApiIPCHandlerImpl( ElectronApiIPCHandlerImpl::ElectronApiIPCHandlerImpl(
@ -111,7 +111,7 @@ api::Session* ElectronApiIPCHandlerImpl::GetSession() {
: nullptr; : nullptr;
} }
gin::Handle<gin_helper::internal::Event> gin_helper::Handle<gin_helper::internal::Event>
ElectronApiIPCHandlerImpl::MakeIPCEvent( ElectronApiIPCHandlerImpl::MakeIPCEvent(
v8::Isolate* isolate, v8::Isolate* isolate,
api::Session* session, api::Session* session,
@ -147,7 +147,7 @@ ElectronApiIPCHandlerImpl::MakeIPCEvent(
} }
content::RenderFrameHost* frame = GetRenderFrameHost(); content::RenderFrameHost* frame = GetRenderFrameHost();
gin::Handle<gin_helper::internal::Event> event = gin_helper::Handle<gin_helper::internal::Event> event =
gin_helper::internal::Event::New(isolate); gin_helper::internal::Event::New(isolate);
gin_helper::Dictionary dict(isolate, event.ToV8().As<v8::Object>()); gin_helper::Dictionary dict(isolate, event.ToV8().As<v8::Object>());
dict.Set("type", "frame"); dict.Set("type", "frame");

View file

@ -67,7 +67,7 @@ class ElectronApiIPCHandlerImpl : public mojom::ElectronApiIPC,
content::RenderFrameHost* GetRenderFrameHost(); content::RenderFrameHost* GetRenderFrameHost();
api::Session* GetSession(); api::Session* GetSession();
gin::Handle<gin_helper::internal::Event> MakeIPCEvent( gin_helper::Handle<gin_helper::internal::Event> MakeIPCEvent(
v8::Isolate* isolate, v8::Isolate* isolate,
api::Session* session, api::Session* session,
bool internal, bool internal,

View file

@ -134,7 +134,7 @@ api::Session* ElectronApiSWIPCHandlerImpl::GetSession() {
return api::Session::FromBrowserContext(GetBrowserContext()); return api::Session::FromBrowserContext(GetBrowserContext());
} }
gin::Handle<gin_helper::internal::Event> gin_helper::Handle<gin_helper::internal::Event>
ElectronApiSWIPCHandlerImpl::MakeIPCEvent( ElectronApiSWIPCHandlerImpl::MakeIPCEvent(
v8::Isolate* isolate, v8::Isolate* isolate,
api::Session* session, api::Session* session,
@ -149,7 +149,7 @@ ElectronApiSWIPCHandlerImpl::MakeIPCEvent(
return {}; return {};
} }
gin::Handle<gin_helper::internal::Event> event = gin_helper::Handle<gin_helper::internal::Event> event =
gin_helper::internal::Event::New(isolate); gin_helper::internal::Event::New(isolate);
v8::Local<v8::Object> event_object = event.ToV8().As<v8::Object>(); v8::Local<v8::Object> event_object = event.ToV8().As<v8::Object>();

View file

@ -11,9 +11,9 @@
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#include "content/public/browser/render_process_host_observer.h" #include "content/public/browser/render_process_host_observer.h"
#include "electron/shell/common/api/api.mojom.h" #include "electron/shell/common/api/api.mojom.h"
#include "gin/handle.h"
#include "mojo/public/cpp/bindings/associated_receiver.h" #include "mojo/public/cpp/bindings/associated_receiver.h"
#include "shell/common/gin_helper/event.h" #include "shell/common/gin_helper/event.h"
#include "shell/common/gin_helper/handle.h"
namespace content { namespace content {
class RenderProcessHost; class RenderProcessHost;
@ -70,7 +70,7 @@ class ElectronApiSWIPCHandlerImpl : public mojom::ElectronApiIPC,
ElectronBrowserContext* GetBrowserContext(); ElectronBrowserContext* GetBrowserContext();
api::Session* GetSession(); api::Session* GetSession();
gin::Handle<gin_helper::internal::Event> MakeIPCEvent( gin_helper::Handle<gin_helper::internal::Event> MakeIPCEvent(
v8::Isolate* isolate, v8::Isolate* isolate,
api::Session* session, api::Session* session,
bool internal, bool internal,

View file

@ -48,7 +48,7 @@ void ElectronNSSCryptoModuleDelegate::RequestPasswordOnUIThread(
v8::Isolate* isolate = electron::JavascriptEnvironment::GetIsolate(); v8::Isolate* isolate = electron::JavascriptEnvironment::GetIsolate();
v8::HandleScope handle_scope(isolate); v8::HandleScope handle_scope(isolate);
gin::Handle<gin_helper::internal::Event> event = gin_helper::Handle<gin_helper::internal::Event> event =
gin_helper::internal::Event::New(isolate); gin_helper::internal::Event::New(isolate);
v8::Local<v8::Object> event_object = event.ToV8().As<v8::Object>(); v8::Local<v8::Object> event_object = event.ToV8().As<v8::Object>();
gin_helper::Dictionary dict(isolate, event_object); gin_helper::Dictionary dict(isolate, event_object);

View file

@ -8,11 +8,11 @@
#include <string_view> #include <string_view>
#include <utility> #include <utility>
#include "gin/handle.h"
#include "gin/object_template_builder.h" #include "gin/object_template_builder.h"
#include "shell/browser/javascript_environment.h" #include "shell/browser/javascript_environment.h"
#include "shell/common/gin_helper/event.h" #include "shell/common/gin_helper/event.h"
#include "shell/common/gin_helper/event_emitter.h" #include "shell/common/gin_helper/event_emitter.h"
#include "shell/common/gin_helper/handle.h"
namespace gin_helper { namespace gin_helper {
@ -32,7 +32,7 @@ class EventEmitterMixin {
v8::Local<v8::Object> wrapper; v8::Local<v8::Object> wrapper;
if (!static_cast<T*>(this)->GetWrapper(isolate).ToLocal(&wrapper)) if (!static_cast<T*>(this)->GetWrapper(isolate).ToLocal(&wrapper))
return false; return false;
gin::Handle<internal::Event> event = internal::Event::New(isolate); gin_helper::Handle<internal::Event> event = internal::Event::New(isolate);
gin_helper::EmitEvent(isolate, wrapper, name, event, gin_helper::EmitEvent(isolate, wrapper, name, event,
std::forward<Args>(args)...); std::forward<Args>(args)...);
return event->GetDefaultPrevented(); return event->GetDefaultPrevented();

View file

@ -670,7 +670,7 @@ void ElectronURLLoaderFactory::StartLoadingHttp(
request->method != net::HttpRequestHeaders::kHeadMethod) request->method != net::HttpRequestHeaders::kHeadMethod)
dict.Get("uploadData", &upload_data); dict.Get("uploadData", &upload_data);
gin::Handle<api::Session> session; gin_helper::Handle<api::Session> session;
auto* browser_context = auto* browser_context =
dict.Get("session", &session) && !session.IsEmpty() dict.Get("session", &session) && !session.IsEmpty()
? session->browser_context() ? session->browser_context()

View file

@ -4,11 +4,11 @@
#include <vector> #include <vector>
#include "gin/handle.h"
#include "shell/common/asar/archive.h" #include "shell/common/asar/archive.h"
#include "shell/common/asar/asar_util.h" #include "shell/common/asar/asar_util.h"
#include "shell/common/gin_converters/file_path_converter.h" #include "shell/common/gin_converters/file_path_converter.h"
#include "shell/common/gin_helper/dictionary.h" #include "shell/common/gin_helper/dictionary.h"
#include "shell/common/gin_helper/handle.h"
#include "shell/common/node_includes.h" #include "shell/common/node_includes.h"
namespace { namespace {

View file

@ -16,7 +16,6 @@
#include "base/strings/pattern.h" #include "base/strings/pattern.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "gin/arguments.h" #include "gin/arguments.h"
#include "gin/handle.h"
#include "gin/object_template_builder.h" #include "gin/object_template_builder.h"
#include "gin/per_isolate_data.h" #include "gin/per_isolate_data.h"
#include "net/base/data_url.h" #include "net/base/data_url.h"
@ -29,6 +28,7 @@
#include "shell/common/gin_helper/dictionary.h" #include "shell/common/gin_helper/dictionary.h"
#include "shell/common/gin_helper/error_thrower.h" #include "shell/common/gin_helper/error_thrower.h"
#include "shell/common/gin_helper/function_template_extensions.h" #include "shell/common/gin_helper/function_template_extensions.h"
#include "shell/common/gin_helper/handle.h"
#include "shell/common/gin_helper/object_template_builder.h" #include "shell/common/gin_helper/object_template_builder.h"
#include "shell/common/node_includes.h" #include "shell/common/node_includes.h"
#include "shell/common/node_util.h" #include "shell/common/node_util.h"
@ -338,7 +338,7 @@ float NativeImage::GetAspectRatio(const std::optional<float> scale_factor) {
return static_cast<float>(size.width()) / static_cast<float>(size.height()); return static_cast<float>(size.width()) / static_cast<float>(size.height());
} }
gin::Handle<NativeImage> NativeImage::Resize(gin::Arguments* args, gin_helper::Handle<NativeImage> NativeImage::Resize(gin::Arguments* args,
base::Value::Dict options) { base::Value::Dict options) {
float scale_factor = GetScaleFactorFromOptions(args); float scale_factor = GetScaleFactorFromOptions(args);
@ -375,7 +375,7 @@ gin::Handle<NativeImage> NativeImage::Resize(gin::Arguments* args,
image_.AsImageSkia(), method, size)}); image_.AsImageSkia(), method, size)});
} }
gin::Handle<NativeImage> NativeImage::Crop(v8::Isolate* isolate, gin_helper::Handle<NativeImage> NativeImage::Crop(v8::Isolate* isolate,
const gfx::Rect& rect) { const gfx::Rect& rect) {
return Create(isolate, gfx::Image{gfx::ImageSkiaOperations::ExtractSubset( return Create(isolate, gfx::Image{gfx::ImageSkiaOperations::ExtractSubset(
image_.AsImageSkia(), rect)}); image_.AsImageSkia(), rect)});
@ -424,18 +424,18 @@ bool NativeImage::IsTemplateImage() {
#endif #endif
// static // static
gin::Handle<NativeImage> NativeImage::CreateEmpty(v8::Isolate* isolate) { gin_helper::Handle<NativeImage> NativeImage::CreateEmpty(v8::Isolate* isolate) {
return Create(isolate, gfx::Image{}); return Create(isolate, gfx::Image{});
} }
// static // static
gin::Handle<NativeImage> NativeImage::Create(v8::Isolate* isolate, gin_helper::Handle<NativeImage> NativeImage::Create(v8::Isolate* isolate,
const gfx::Image& image) { const gfx::Image& image) {
return gin::CreateHandle(isolate, new NativeImage(isolate, image)); return gin_helper::CreateHandle(isolate, new NativeImage(isolate, image));
} }
// static // static
gin::Handle<NativeImage> NativeImage::CreateFromPNG( gin_helper::Handle<NativeImage> NativeImage::CreateFromPNG(
v8::Isolate* isolate, v8::Isolate* isolate,
const base::span<const uint8_t> data) { const base::span<const uint8_t> data) {
gfx::ImageSkia image_skia; gfx::ImageSkia image_skia;
@ -444,7 +444,7 @@ gin::Handle<NativeImage> NativeImage::CreateFromPNG(
} }
// static // static
gin::Handle<NativeImage> NativeImage::CreateFromJPEG( gin_helper::Handle<NativeImage> NativeImage::CreateFromJPEG(
v8::Isolate* isolate, v8::Isolate* isolate,
const base::span<const uint8_t> buffer) { const base::span<const uint8_t> buffer) {
gfx::ImageSkia image_skia; gfx::ImageSkia image_skia;
@ -453,19 +453,20 @@ gin::Handle<NativeImage> NativeImage::CreateFromJPEG(
} }
// static // static
gin::Handle<NativeImage> NativeImage::CreateFromPath( gin_helper::Handle<NativeImage> NativeImage::CreateFromPath(
v8::Isolate* isolate, v8::Isolate* isolate,
const base::FilePath& path) { const base::FilePath& path) {
base::FilePath image_path = NormalizePath(path); base::FilePath image_path = NormalizePath(path);
#if BUILDFLAG(IS_WIN) #if BUILDFLAG(IS_WIN)
if (image_path.MatchesExtension(FILE_PATH_LITERAL(".ico"))) { if (image_path.MatchesExtension(FILE_PATH_LITERAL(".ico"))) {
return gin::CreateHandle(isolate, new NativeImage(isolate, image_path)); return gin_helper::CreateHandle(isolate,
new NativeImage(isolate, image_path));
} }
#endif #endif
gfx::ImageSkia image_skia; gfx::ImageSkia image_skia;
electron::util::PopulateImageSkiaRepsFromPath(&image_skia, image_path); electron::util::PopulateImageSkiaRepsFromPath(&image_skia, image_path);
gfx::Image image(image_skia); gfx::Image image(image_skia);
gin::Handle<NativeImage> handle = Create(isolate, image); gin_helper::Handle<NativeImage> handle = Create(isolate, image);
#if BUILDFLAG(IS_MAC) #if BUILDFLAG(IS_MAC)
if (IsTemplateFilename(image_path)) if (IsTemplateFilename(image_path))
handle->SetTemplateImage(true); handle->SetTemplateImage(true);
@ -474,7 +475,7 @@ gin::Handle<NativeImage> NativeImage::CreateFromPath(
} }
// static // static
gin::Handle<NativeImage> NativeImage::CreateFromBitmap( gin_helper::Handle<NativeImage> NativeImage::CreateFromBitmap(
gin_helper::ErrorThrower thrower, gin_helper::ErrorThrower thrower,
v8::Local<v8::Value> buffer, v8::Local<v8::Value> buffer,
const gin_helper::Dictionary& options) { const gin_helper::Dictionary& options) {
@ -520,7 +521,7 @@ gin::Handle<NativeImage> NativeImage::CreateFromBitmap(
} }
// static // static
gin::Handle<NativeImage> NativeImage::CreateFromBuffer( gin_helper::Handle<NativeImage> NativeImage::CreateFromBuffer(
gin_helper::ErrorThrower thrower, gin_helper::ErrorThrower thrower,
v8::Local<v8::Value> buffer, v8::Local<v8::Value> buffer,
gin::Arguments* args) { gin::Arguments* args) {
@ -548,7 +549,8 @@ gin::Handle<NativeImage> NativeImage::CreateFromBuffer(
} }
// static // static
gin::Handle<NativeImage> NativeImage::CreateFromDataURL(v8::Isolate* isolate, gin_helper::Handle<NativeImage> NativeImage::CreateFromDataURL(
v8::Isolate* isolate,
const GURL& url) { const GURL& url) {
std::string mime_type, charset, data; std::string mime_type, charset, data;
if (net::DataURL::Parse(url, &mime_type, &charset, &data)) { if (net::DataURL::Parse(url, &mime_type, &charset, &data)) {
@ -562,7 +564,8 @@ gin::Handle<NativeImage> NativeImage::CreateFromDataURL(v8::Isolate* isolate,
} }
#if !BUILDFLAG(IS_MAC) #if !BUILDFLAG(IS_MAC)
gin::Handle<NativeImage> NativeImage::CreateFromNamedImage(gin::Arguments* args, gin_helper::Handle<NativeImage> NativeImage::CreateFromNamedImage(
gin::Arguments* args,
std::string name) { std::string name) {
return CreateEmpty(args->isolate()); return CreateEmpty(args->isolate());
} }

View file

@ -34,14 +34,13 @@ class Size;
namespace gin { namespace gin {
class Arguments; class Arguments;
template <typename T>
class Handle;
} // namespace gin } // namespace gin
namespace gin_helper { namespace gin_helper {
class Dictionary; class Dictionary;
class ErrorThrower; class ErrorThrower;
template <typename T>
class Handle;
} // namespace gin_helper } // namespace gin_helper
namespace electron::api { namespace electron::api {
@ -58,27 +57,30 @@ class NativeImage final : public gin_helper::DeprecatedWrappable<NativeImage> {
NativeImage(const NativeImage&) = delete; NativeImage(const NativeImage&) = delete;
NativeImage& operator=(const NativeImage&) = delete; NativeImage& operator=(const NativeImage&) = delete;
static gin::Handle<NativeImage> CreateEmpty(v8::Isolate* isolate); static gin_helper::Handle<NativeImage> CreateEmpty(v8::Isolate* isolate);
static gin::Handle<NativeImage> Create(v8::Isolate* isolate, static gin_helper::Handle<NativeImage> Create(v8::Isolate* isolate,
const gfx::Image& image); const gfx::Image& image);
static gin::Handle<NativeImage> CreateFromPNG(v8::Isolate* isolate, static gin_helper::Handle<NativeImage> CreateFromPNG(
base::span<const uint8_t> data);
static gin::Handle<NativeImage> CreateFromJPEG(
v8::Isolate* isolate, v8::Isolate* isolate,
base::span<const uint8_t> data); base::span<const uint8_t> data);
static gin::Handle<NativeImage> CreateFromPath(v8::Isolate* isolate, static gin_helper::Handle<NativeImage> CreateFromJPEG(
v8::Isolate* isolate,
base::span<const uint8_t> data);
static gin_helper::Handle<NativeImage> CreateFromPath(
v8::Isolate* isolate,
const base::FilePath& path); const base::FilePath& path);
static gin::Handle<NativeImage> CreateFromBitmap( static gin_helper::Handle<NativeImage> CreateFromBitmap(
gin_helper::ErrorThrower thrower, gin_helper::ErrorThrower thrower,
v8::Local<v8::Value> buffer, v8::Local<v8::Value> buffer,
const gin_helper::Dictionary& options); const gin_helper::Dictionary& options);
static gin::Handle<NativeImage> CreateFromBuffer( static gin_helper::Handle<NativeImage> CreateFromBuffer(
gin_helper::ErrorThrower thrower, gin_helper::ErrorThrower thrower,
v8::Local<v8::Value> buffer, v8::Local<v8::Value> buffer,
gin::Arguments* args); gin::Arguments* args);
static gin::Handle<NativeImage> CreateFromDataURL(v8::Isolate* isolate, static gin_helper::Handle<NativeImage> CreateFromDataURL(v8::Isolate* isolate,
const GURL& url); const GURL& url);
static gin::Handle<NativeImage> CreateFromNamedImage(gin::Arguments* args, static gin_helper::Handle<NativeImage> CreateFromNamedImage(
gin::Arguments* args,
std::string name); std::string name);
#if !BUILDFLAG(IS_LINUX) #if !BUILDFLAG(IS_LINUX)
static v8::Local<v8::Promise> CreateThumbnailFromPath( static v8::Local<v8::Promise> CreateThumbnailFromPath(
@ -114,9 +116,10 @@ class NativeImage final : public gin_helper::DeprecatedWrappable<NativeImage> {
std::vector<float> GetScaleFactors(); std::vector<float> GetScaleFactors();
v8::Local<v8::Value> GetBitmap(gin::Arguments* args); v8::Local<v8::Value> GetBitmap(gin::Arguments* args);
v8::Local<v8::Value> GetNativeHandle(gin_helper::ErrorThrower thrower); v8::Local<v8::Value> GetNativeHandle(gin_helper::ErrorThrower thrower);
gin::Handle<NativeImage> Resize(gin::Arguments* args, gin_helper::Handle<NativeImage> Resize(gin::Arguments* args,
base::Value::Dict options); base::Value::Dict options);
gin::Handle<NativeImage> Crop(v8::Isolate* isolate, const gfx::Rect& rect); gin_helper::Handle<NativeImage> Crop(v8::Isolate* isolate,
const gfx::Rect& rect);
std::string ToDataURL(gin::Arguments* args); std::string ToDataURL(gin::Arguments* args);
bool IsEmpty(); bool IsEmpty();
gfx::Size GetSize(const std::optional<float> scale_factor); gfx::Size GetSize(const std::optional<float> scale_factor);

View file

@ -16,8 +16,8 @@
#include "base/strings/sys_string_conversions.h" #include "base/strings/sys_string_conversions.h"
#include "base/task/bind_post_task.h" #include "base/task/bind_post_task.h"
#include "gin/arguments.h" #include "gin/arguments.h"
#include "gin/handle.h"
#include "shell/common/gin_converters/image_converter.h" #include "shell/common/gin_converters/image_converter.h"
#include "shell/common/gin_helper/handle.h"
#include "shell/common/gin_helper/promise.h" #include "shell/common/gin_helper/promise.h"
#include "shell/common/mac_util.h" #include "shell/common/mac_util.h"
#include "ui/gfx/color_utils.h" #include "ui/gfx/color_utils.h"
@ -103,7 +103,8 @@ v8::Local<v8::Promise> NativeImage::CreateThumbnailFromPath(
return handle; return handle;
} }
gin::Handle<NativeImage> NativeImage::CreateFromNamedImage(gin::Arguments* args, gin_helper::Handle<NativeImage> NativeImage::CreateFromNamedImage(
gin::Arguments* args,
std::string name) { std::string name) {
@autoreleasepool { @autoreleasepool {
std::vector<double> hsl_shift; std::vector<double> hsl_shift;

View file

@ -4,7 +4,6 @@
#include <string> #include <string>
#include "gin/handle.h"
#include "net/base/filename_util.h" #include "net/base/filename_util.h"
#include "net/base/network_change_notifier.h" #include "net/base/network_change_notifier.h"
#include "net/http/http_util.h" #include "net/http/http_util.h"
@ -17,6 +16,7 @@
#include "shell/common/gin_converters/net_converter.h" #include "shell/common/gin_converters/net_converter.h"
#include "shell/common/gin_helper/dictionary.h" #include "shell/common/gin_helper/dictionary.h"
#include "shell/common/gin_helper/error_thrower.h" #include "shell/common/gin_helper/error_thrower.h"
#include "shell/common/gin_helper/handle.h"
#include "shell/common/gin_helper/object_template_builder.h" #include "shell/common/gin_helper/object_template_builder.h"
#include "shell/common/gin_helper/promise.h" #include "shell/common/gin_helper/promise.h"
#include "shell/common/node_includes.h" #include "shell/common/node_includes.h"

View file

@ -17,7 +17,6 @@
#include "base/memory/raw_ptr.h" #include "base/memory/raw_ptr.h"
#include "base/notreached.h" #include "base/notreached.h"
#include "base/sequence_checker.h" #include "base/sequence_checker.h"
#include "gin/handle.h"
#include "gin/object_template_builder.h" #include "gin/object_template_builder.h"
#include "mojo/public/cpp/bindings/remote.h" #include "mojo/public/cpp/bindings/remote.h"
#include "mojo/public/cpp/system/data_pipe_producer.h" #include "mojo/public/cpp/system/data_pipe_producer.h"
@ -43,6 +42,7 @@
#include "shell/common/gin_converters/gurl_converter.h" #include "shell/common/gin_converters/gurl_converter.h"
#include "shell/common/gin_converters/net_converter.h" #include "shell/common/gin_converters/net_converter.h"
#include "shell/common/gin_helper/dictionary.h" #include "shell/common/gin_helper/dictionary.h"
#include "shell/common/gin_helper/handle.h"
#include "shell/common/gin_helper/object_template_builder.h" #include "shell/common/gin_helper/object_template_builder.h"
#include "shell/common/gin_helper/promise.h" #include "shell/common/gin_helper/promise.h"
#include "shell/common/node_includes.h" #include "shell/common/node_includes.h"
@ -167,12 +167,12 @@ class JSChunkedDataPipeGetter final
: public gin_helper::DeprecatedWrappable<JSChunkedDataPipeGetter>, : public gin_helper::DeprecatedWrappable<JSChunkedDataPipeGetter>,
public network::mojom::ChunkedDataPipeGetter { public network::mojom::ChunkedDataPipeGetter {
public: public:
static gin::Handle<JSChunkedDataPipeGetter> Create( static gin_helper::Handle<JSChunkedDataPipeGetter> Create(
v8::Isolate* isolate, v8::Isolate* isolate,
v8::Local<v8::Function> body_func, v8::Local<v8::Function> body_func,
mojo::PendingReceiver<network::mojom::ChunkedDataPipeGetter> mojo::PendingReceiver<network::mojom::ChunkedDataPipeGetter>
chunked_data_pipe_getter) { chunked_data_pipe_getter) {
return gin::CreateHandle( return gin_helper::CreateHandle(
isolate, new JSChunkedDataPipeGetter( isolate, new JSChunkedDataPipeGetter(
isolate, body_func, std::move(chunked_data_pipe_getter))); isolate, body_func, std::move(chunked_data_pipe_getter)));
} }
@ -390,7 +390,8 @@ void SimpleURLLoaderWrapper::Start() {
void SimpleURLLoaderWrapper::Pin() { void SimpleURLLoaderWrapper::Pin() {
// Prevent ourselves from being GC'd until the request is complete. Must be // Prevent ourselves from being GC'd until the request is complete. Must be
// called after gin::CreateHandle, otherwise the wrapper isn't initialized. // called after gin_helper::CreateHandle, otherwise the wrapper isn't
// initialized.
v8::Isolate* isolate = JavascriptEnvironment::GetIsolate(); v8::Isolate* isolate = JavascriptEnvironment::GetIsolate();
pinned_wrapper_.Reset(isolate, GetWrapper(isolate).ToLocalChecked()); pinned_wrapper_.Reset(isolate, GetWrapper(isolate).ToLocalChecked());
} }
@ -522,7 +523,7 @@ SimpleURLLoaderWrapper::GetURLLoaderFactoryForURL(const GURL& url) {
} }
// static // static
gin::Handle<SimpleURLLoaderWrapper> SimpleURLLoaderWrapper::Create( gin_helper::Handle<SimpleURLLoaderWrapper> SimpleURLLoaderWrapper::Create(
gin::Arguments* args) { gin::Arguments* args) {
gin_helper::Dictionary opts; gin_helper::Dictionary opts;
if (!args->GetNext(&opts)) { if (!args->GetNext(&opts)) {
@ -697,7 +698,7 @@ gin::Handle<SimpleURLLoaderWrapper> SimpleURLLoaderWrapper::Create(
ElectronBrowserContext* browser_context = nullptr; ElectronBrowserContext* browser_context = nullptr;
if (electron::IsBrowserProcess()) { if (electron::IsBrowserProcess()) {
std::string partition; std::string partition;
gin::Handle<Session> session; gin_helper::Handle<Session> session;
if (!opts.Get("session", &session)) { if (!opts.Get("session", &session)) {
if (opts.Get("partition", &partition)) if (opts.Get("partition", &partition))
session = Session::FromPartition(args->isolate(), partition); session = Session::FromPartition(args->isolate(), partition);
@ -707,7 +708,7 @@ gin::Handle<SimpleURLLoaderWrapper> SimpleURLLoaderWrapper::Create(
browser_context = session->browser_context(); browser_context = session->browser_context();
} }
auto ret = gin::CreateHandle( auto ret = gin_helper::CreateHandle(
args->isolate(), args->isolate(),
new SimpleURLLoaderWrapper(browser_context, std::move(request), options)); new SimpleURLLoaderWrapper(browser_context, std::move(request), options));
ret->Pin(); ret->Pin();

View file

@ -27,9 +27,12 @@
namespace gin { namespace gin {
class Arguments; class Arguments;
} // namespace gin
namespace gin_helper {
template <typename T> template <typename T>
class Handle; class Handle;
} // namespace gin } // namespace gin_helper
namespace net { namespace net {
class AuthChallengeInfo; class AuthChallengeInfo;
@ -56,7 +59,8 @@ class SimpleURLLoaderWrapper final
private network::mojom::URLLoaderNetworkServiceObserver { private network::mojom::URLLoaderNetworkServiceObserver {
public: public:
~SimpleURLLoaderWrapper() override; ~SimpleURLLoaderWrapper() override;
static gin::Handle<SimpleURLLoaderWrapper> Create(gin::Arguments* args); static gin_helper::Handle<SimpleURLLoaderWrapper> Create(
gin::Arguments* args);
void Cancel(); void Cancel();

View file

@ -4,9 +4,9 @@
#include "shell/common/gin_converters/image_converter.h" #include "shell/common/gin_converters/image_converter.h"
#include "gin/handle.h"
#include "shell/common/api/electron_api_native_image.h" #include "shell/common/api/electron_api_native_image.h"
#include "shell/common/gin_converters/file_path_converter.h" #include "shell/common/gin_converters/file_path_converter.h"
#include "shell/common/gin_helper/handle.h"
#include "ui/gfx/image/image_skia.h" #include "ui/gfx/image/image_skia.h"
namespace gin { namespace gin {

View file

@ -15,7 +15,6 @@
#include "base/values.h" #include "base/values.h"
#include "gin/converter.h" #include "gin/converter.h"
#include "gin/dictionary.h" #include "gin/dictionary.h"
#include "gin/handle.h"
#include "gin/object_template_builder.h" #include "gin/object_template_builder.h"
#include "net/cert/x509_certificate.h" #include "net/cert/x509_certificate.h"
#include "net/cert/x509_util.h" #include "net/cert/x509_util.h"
@ -32,6 +31,7 @@
#include "shell/common/gin_converters/gurl_converter.h" #include "shell/common/gin_converters/gurl_converter.h"
#include "shell/common/gin_converters/std_converter.h" #include "shell/common/gin_converters/std_converter.h"
#include "shell/common/gin_converters/value_converter.h" #include "shell/common/gin_converters/value_converter.h"
#include "shell/common/gin_helper/handle.h"
#include "shell/common/gin_helper/promise.h" #include "shell/common/gin_helper/promise.h"
#include "shell/common/node_includes.h" #include "shell/common/node_includes.h"
#include "shell/common/node_util.h" #include "shell/common/node_util.h"
@ -259,12 +259,13 @@ namespace {
class ChunkedDataPipeReadableStream final class ChunkedDataPipeReadableStream final
: public gin_helper::DeprecatedWrappable<ChunkedDataPipeReadableStream> { : public gin_helper::DeprecatedWrappable<ChunkedDataPipeReadableStream> {
public: public:
static gin::Handle<ChunkedDataPipeReadableStream> Create( static gin_helper::Handle<ChunkedDataPipeReadableStream> Create(
v8::Isolate* isolate, v8::Isolate* isolate,
network::ResourceRequestBody* request, network::ResourceRequestBody* request,
network::DataElementChunkedDataPipe* data_element) { network::DataElementChunkedDataPipe* data_element) {
return gin::CreateHandle(isolate, new ChunkedDataPipeReadableStream( return gin_helper::CreateHandle(
isolate, request, data_element)); isolate,
new ChunkedDataPipeReadableStream(isolate, request, data_element));
} }
// gin_helper::Wrappable // gin_helper::Wrappable

View file

@ -23,7 +23,7 @@ class EventEmitterMixin;
// class Example : public gin_helper::DeprecatedWrappable<Example>, // class Example : public gin_helper::DeprecatedWrappable<Example>,
// public gin_helper::Constructible<Example> { // public gin_helper::Constructible<Example> {
// public: // public:
// static gin::Handle<Example> New(...usual gin method arguments...); // static gin_helper::Handle<Example> New(...usual gin method arguments...);
// static void FillObjectTemplate( // static void FillObjectTemplate(
// v8::Isolate*, // v8::Isolate*,
// v8::Local<v8::ObjectTemplate>); // v8::Local<v8::ObjectTemplate>);

View file

@ -4,14 +4,14 @@
#include "shell/common/gin_helper/event.h" #include "shell/common/gin_helper/event.h"
#include "gin/dictionary.h" #include "gin/dictionary.h"
#include "gin/handle.h"
#include "gin/object_template_builder.h" #include "gin/object_template_builder.h"
#include "shell/common/gin_helper/handle.h"
namespace gin_helper::internal { namespace gin_helper::internal {
// static // static
gin::Handle<Event> Event::New(v8::Isolate* isolate) { gin_helper::Handle<Event> Event::New(v8::Isolate* isolate) {
return gin::CreateHandle(isolate, new Event()); return gin_helper::CreateHandle(isolate, new Event());
} }
// static // static
v8::Local<v8::ObjectTemplate> Event::FillObjectTemplate( v8::Local<v8::ObjectTemplate> Event::FillObjectTemplate(

View file

@ -8,10 +8,10 @@
#include "shell/common/gin_helper/constructible.h" #include "shell/common/gin_helper/constructible.h"
#include "shell/common/gin_helper/wrappable.h" #include "shell/common/gin_helper/wrappable.h"
namespace gin { namespace gin_helper {
template <typename T> template <typename T>
class Handle; class Handle;
} // namespace gin } // namespace gin_helper
namespace v8 { namespace v8 {
class Isolate; class Isolate;
@ -27,7 +27,7 @@ class Event final : public gin_helper::DeprecatedWrappable<Event>,
public gin_helper::Constructible<Event> { public gin_helper::Constructible<Event> {
public: public:
// gin_helper::Constructible // gin_helper::Constructible
static gin::Handle<Event> New(v8::Isolate* isolate); static gin_helper::Handle<Event> New(v8::Isolate* isolate);
static v8::Local<v8::ObjectTemplate> FillObjectTemplate( static v8::Local<v8::ObjectTemplate> FillObjectTemplate(
v8::Isolate* isolate, v8::Isolate* isolate,
v8::Local<v8::ObjectTemplate> prototype); v8::Local<v8::ObjectTemplate> prototype);

View file

@ -8,9 +8,9 @@
#include <string_view> #include <string_view>
#include <utility> #include <utility>
#include "gin/handle.h"
#include "shell/common/gin_helper/event.h" #include "shell/common/gin_helper/event.h"
#include "shell/common/gin_helper/event_emitter_caller.h" #include "shell/common/gin_helper/event_emitter_caller.h"
#include "shell/common/gin_helper/handle.h"
#include "shell/common/gin_helper/wrappable.h" #include "shell/common/gin_helper/wrappable.h"
namespace content { namespace content {
@ -31,7 +31,7 @@ class EventEmitter : public gin_helper::Wrappable<T> {
v8::Local<v8::Object> wrapper = this->GetWrapper(); v8::Local<v8::Object> wrapper = this->GetWrapper();
if (wrapper.IsEmpty()) if (wrapper.IsEmpty())
return false; return false;
gin::Handle<internal::Event> event = internal::Event::New(isolate); gin_helper::Handle<internal::Event> event = internal::Event::New(isolate);
// It's possible that |this| will be deleted by EmitEvent, so save anything // It's possible that |this| will be deleted by EmitEvent, so save anything
// we need from |this| before calling EmitEvent. // we need from |this| before calling EmitEvent.
EmitEvent(isolate, wrapper, name, event, std::forward<Args>(args)...); EmitEvent(isolate, wrapper, name, event, std::forward<Args>(args)...);

View file

@ -0,0 +1,77 @@
// Copyright (c) 2025 GitHub, Inc.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#ifndef ELECTRON_SHELL_COMMON_GIN_HELPER_HANDLE_H_
#define ELECTRON_SHELL_COMMON_GIN_HELPER_HANDLE_H_
#include "base/memory/raw_ptr.h"
#include "gin/converter.h"
namespace gin_helper {
// You can use gin_helper::Handle on the stack to retain a gin_helper::Wrappable
// object. Currently we don't have a mechanism for retaining a
// gin_helper::Wrappable object in the C++ heap because strong references from
// C++ to V8 can cause memory leaks. Copied from
// https://chromium-review.googlesource.com/c/chromium/src/+/6734440 Should be
// removed once https://github.com/electron/electron/issues/47922 is complete.
template <typename T>
class Handle {
public:
Handle() : object_(nullptr) {}
Handle(v8::Local<v8::Value> wrapper, T* object)
: wrapper_(wrapper), object_(object) {}
bool IsEmpty() const { return !object_; }
void Clear() {
wrapper_.Clear();
object_ = NULL;
}
T* operator->() const { return object_; }
v8::Local<v8::Value> ToV8() const { return wrapper_; }
T* get() const { return object_; }
private:
v8::Local<v8::Value> wrapper_;
raw_ptr<T> object_;
};
// This function is a convenient way to create a handle from a raw pointer
// without having to write out the type of the object explicitly.
template <typename T>
gin_helper::Handle<T> CreateHandle(v8::Isolate* isolate, T* object) {
v8::Local<v8::Object> wrapper;
if (!object->GetWrapper(isolate).ToLocal(&wrapper) || wrapper.IsEmpty())
return gin_helper::Handle<T>();
return gin_helper::Handle<T>(wrapper, object);
}
} // namespace gin_helper
namespace gin {
template <typename T>
struct Converter<gin_helper::Handle<T>> {
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
const gin_helper::Handle<T>& val) {
return val.ToV8();
}
static bool FromV8(v8::Isolate* isolate,
v8::Local<v8::Value> val,
gin_helper::Handle<T>* out) {
T* object = NULL;
if (!Converter<T*>::FromV8(isolate, val, &object)) {
return false;
}
*out = gin_helper::Handle<T>(val, object);
return true;
}
};
} // namespace gin
#endif // ELECTRON_SHELL_COMMON_GIN_HELPER_HANDLE_H_

View file

@ -6,18 +6,19 @@
#include "base/debug/stack_trace.h" #include "base/debug/stack_trace.h"
#include "gin/data_object_builder.h" #include "gin/data_object_builder.h"
#include "gin/handle.h"
#include "gin/object_template_builder.h" #include "gin/object_template_builder.h"
#include "shell/browser/javascript_environment.h" #include "shell/browser/javascript_environment.h"
#include "shell/common/gin_converters/blink_converter.h" #include "shell/common/gin_converters/blink_converter.h"
#include "shell/common/gin_helper/handle.h"
namespace gin_helper::internal { namespace gin_helper::internal {
// static // static
using InvokeCallback = electron::mojom::ElectronApiIPC::InvokeCallback; using InvokeCallback = electron::mojom::ElectronApiIPC::InvokeCallback;
gin::Handle<ReplyChannel> ReplyChannel::Create(v8::Isolate* isolate, gin_helper::Handle<ReplyChannel> ReplyChannel::Create(v8::Isolate* isolate,
InvokeCallback callback) { InvokeCallback callback) {
return gin::CreateHandle(isolate, new ReplyChannel(std::move(callback))); return gin_helper::CreateHandle(isolate,
new ReplyChannel(std::move(callback)));
} }
gin::ObjectTemplateBuilder ReplyChannel::GetObjectTemplateBuilder( gin::ObjectTemplateBuilder ReplyChannel::GetObjectTemplateBuilder(

View file

@ -8,10 +8,10 @@
#include "shell/common/api/api.mojom.h" #include "shell/common/api/api.mojom.h"
#include "shell/common/gin_helper/wrappable.h" #include "shell/common/gin_helper/wrappable.h"
namespace gin { namespace gin_helper {
template <typename T> template <typename T>
class Handle; class Handle;
} // namespace gin } // namespace gin_helper
namespace v8 { namespace v8 {
class Isolate; class Isolate;
@ -29,7 +29,7 @@ namespace gin_helper::internal {
class ReplyChannel : public gin_helper::DeprecatedWrappable<ReplyChannel> { class ReplyChannel : public gin_helper::DeprecatedWrappable<ReplyChannel> {
public: public:
using InvokeCallback = electron::mojom::ElectronApiIPC::InvokeCallback; using InvokeCallback = electron::mojom::ElectronApiIPC::InvokeCallback;
static gin::Handle<ReplyChannel> Create(v8::Isolate* isolate, static gin_helper::Handle<ReplyChannel> Create(v8::Isolate* isolate,
InvokeCallback callback); InvokeCallback callback);
// gin_helper::Wrappable // gin_helper::Wrappable

View file

@ -17,7 +17,7 @@ struct DeprecatedWrapperInfo;
namespace gin_helper { namespace gin_helper {
// Wrappable is a base class for C++ objects that have corresponding v8 wrapper // Wrappable is a base class for C++ objects that have corresponding v8 wrapper
// objects. To retain a Wrappable object on the stack, use a gin::Handle. // objects. To retain a Wrappable object on the stack, use a gin_helper::Handle.
// //
// USAGE: // USAGE:
// // my_class.h // // my_class.h
@ -27,9 +27,9 @@ namespace gin_helper {
// }; // };
// //
// Subclasses should also typically have private constructors and expose a // Subclasses should also typically have private constructors and expose a
// static Create function that returns a gin::Handle. Forcing creators through // static Create function that returns a gin_helper::Handle. Forcing creators
// this static Create function will enforce that clients actually create a // through this static Create function will enforce that clients actually create
// wrapper for the object. If clients fail to create a wrapper for a wrappable // a wrapper for the object. If clients fail to create a wrapper for a wrappable
// object, the object will leak because we use the weak callback from the // object, the object will leak because we use the weak callback from the
// wrapper as the signal to delete the wrapped object. // wrapper as the signal to delete the wrapped object.
class WrappableBase { class WrappableBase {

View file

@ -8,7 +8,6 @@
#include "content/public/renderer/render_frame_observer.h" #include "content/public/renderer/render_frame_observer.h"
#include "content/public/renderer/worker_thread.h" #include "content/public/renderer/worker_thread.h"
#include "gin/dictionary.h" #include "gin/dictionary.h"
#include "gin/handle.h"
#include "gin/object_template_builder.h" #include "gin/object_template_builder.h"
#include "services/service_manager/public/cpp/interface_provider.h" #include "services/service_manager/public/cpp/interface_provider.h"
#include "shell/common/api/api.mojom.h" #include "shell/common/api/api.mojom.h"
@ -17,6 +16,7 @@
#include "shell/common/gin_helper/dictionary.h" #include "shell/common/gin_helper/dictionary.h"
#include "shell/common/gin_helper/error_thrower.h" #include "shell/common/gin_helper/error_thrower.h"
#include "shell/common/gin_helper/function_template_extensions.h" #include "shell/common/gin_helper/function_template_extensions.h"
#include "shell/common/gin_helper/handle.h"
#include "shell/common/gin_helper/promise.h" #include "shell/common/gin_helper/promise.h"
#include "shell/common/gin_helper/wrappable.h" #include "shell/common/gin_helper/wrappable.h"
#include "shell/common/node_bindings.h" #include "shell/common/node_bindings.h"
@ -59,8 +59,8 @@ class IPCBase : public gin_helper::DeprecatedWrappable<T> {
public: public:
static gin::DeprecatedWrapperInfo kWrapperInfo; static gin::DeprecatedWrapperInfo kWrapperInfo;
static gin::Handle<T> Create(v8::Isolate* isolate) { static gin_helper::Handle<T> Create(v8::Isolate* isolate) {
return gin::CreateHandle(isolate, new T(isolate)); return gin_helper::CreateHandle(isolate, new T(isolate));
} }
void SendMessage(v8::Isolate* isolate, void SendMessage(v8::Isolate* isolate,

View file

@ -17,7 +17,6 @@
#include "content/public/renderer/render_frame.h" #include "content/public/renderer/render_frame.h"
#include "content/public/renderer/render_frame_observer.h" #include "content/public/renderer/render_frame_observer.h"
#include "content/public/renderer/render_frame_visitor.h" #include "content/public/renderer/render_frame_visitor.h"
#include "gin/handle.h"
#include "gin/object_template_builder.h" #include "gin/object_template_builder.h"
#include "services/service_manager/public/cpp/interface_provider.h" #include "services/service_manager/public/cpp/interface_provider.h"
#include "shell/common/api/api.mojom.h" #include "shell/common/api/api.mojom.h"
@ -29,6 +28,7 @@
#include "shell/common/gin_helper/dictionary.h" #include "shell/common/gin_helper/dictionary.h"
#include "shell/common/gin_helper/error_thrower.h" #include "shell/common/gin_helper/error_thrower.h"
#include "shell/common/gin_helper/function_template_extensions.h" #include "shell/common/gin_helper/function_template_extensions.h"
#include "shell/common/gin_helper/handle.h"
#include "shell/common/gin_helper/object_template_builder.h" #include "shell/common/gin_helper/object_template_builder.h"
#include "shell/common/gin_helper/promise.h" #include "shell/common/gin_helper/promise.h"
#include "shell/common/gin_helper/wrappable.h" #include "shell/common/gin_helper/wrappable.h"
@ -383,14 +383,17 @@ class WebFrameRenderer final
.Build(); .Build();
} }
static const char* GetClassName() { return "WebFrame"; } static const char* GetClassName() { return "WebFrame"; }
static gin::Handle<WebFrameRenderer> New(v8::Isolate* isolate) { return {}; } static gin_helper::Handle<WebFrameRenderer> New(v8::Isolate* isolate) {
return {};
}
static gin::DeprecatedWrapperInfo kWrapperInfo; static gin::DeprecatedWrapperInfo kWrapperInfo;
static gin::Handle<WebFrameRenderer> Create( static gin_helper::Handle<WebFrameRenderer> Create(
v8::Isolate* isolate, v8::Isolate* isolate,
content::RenderFrame* render_frame) { content::RenderFrame* render_frame) {
return gin::CreateHandle(isolate, new WebFrameRenderer(render_frame)); return gin_helper::CreateHandle(isolate,
new WebFrameRenderer(render_frame));
} }
explicit WebFrameRenderer(content::RenderFrame* render_frame) explicit WebFrameRenderer(content::RenderFrame* render_frame)

View file

@ -8,12 +8,12 @@
#include "base/no_destructor.h" #include "base/no_destructor.h"
#include "gin/data_object_builder.h" #include "gin/data_object_builder.h"
#include "gin/handle.h"
#include "gin/object_template_builder.h" #include "gin/object_template_builder.h"
#include "shell/browser/api/message_port.h" #include "shell/browser/api/message_port.h"
#include "shell/browser/javascript_environment.h" #include "shell/browser/javascript_environment.h"
#include "shell/common/gin_helper/dictionary.h" #include "shell/common/gin_helper/dictionary.h"
#include "shell/common/gin_helper/event_emitter_caller.h" #include "shell/common/gin_helper/event_emitter_caller.h"
#include "shell/common/gin_helper/handle.h"
#include "shell/common/node_includes.h" #include "shell/common/node_includes.h"
#include "shell/common/v8_util.h" #include "shell/common/v8_util.h"
#include "third_party/blink/public/common/messaging/transferable_message_mojom_traits.h" #include "third_party/blink/public/common/messaging/transferable_message_mojom_traits.h"
@ -107,8 +107,8 @@ bool ParentPort::Accept(mojo::Message* mojo_message) {
} }
// static // static
gin::Handle<ParentPort> ParentPort::Create(v8::Isolate* isolate) { gin_helper::Handle<ParentPort> ParentPort::Create(v8::Isolate* isolate) {
return gin::CreateHandle(isolate, ParentPort::GetInstance()); return gin_helper::CreateHandle(isolate, ParentPort::GetInstance());
} }
// static // static

View file

@ -22,9 +22,12 @@ class Isolate;
namespace gin { namespace gin {
class Arguments; class Arguments;
} // namespace gin
namespace gin_helper {
template <typename T> template <typename T>
class Handle; class Handle;
} // namespace gin } // namespace gin_helper
namespace electron { namespace electron {
@ -36,7 +39,7 @@ class ParentPort final : public gin_helper::DeprecatedWrappable<ParentPort>,
private mojo::MessageReceiver { private mojo::MessageReceiver {
public: public:
static ParentPort* GetInstance(); static ParentPort* GetInstance();
static gin::Handle<ParentPort> Create(v8::Isolate* isolate); static gin_helper::Handle<ParentPort> Create(v8::Isolate* isolate);
ParentPort(const ParentPort&) = delete; ParentPort(const ParentPort&) = delete;
ParentPort& operator=(const ParentPort&) = delete; ParentPort& operator=(const ParentPort&) = delete;