diff --git a/shell/browser/api/electron_api_app.cc b/shell/browser/api/electron_api_app.cc index 06cf9fc521bb..ebb6cd875a7a 100644 --- a/shell/browser/api/electron_api_app.cc +++ b/shell/browser/api/electron_api_app.cc @@ -1856,8 +1856,8 @@ void Initialize(v8::Local exports, v8::Local unused, v8::Local context, void* priv) { - v8::Isolate* isolate = context->GetIsolate(); - gin_helper::Dictionary dict(isolate, exports); + v8::Isolate* const isolate = electron::JavascriptEnvironment::GetIsolate(); + gin_helper::Dictionary dict{isolate, exports}; dict.Set("app", electron::api::App::Create(isolate)); } diff --git a/shell/browser/api/electron_api_auto_updater.cc b/shell/browser/api/electron_api_auto_updater.cc index 49d283838e7d..f509912749bd 100644 --- a/shell/browser/api/electron_api_auto_updater.cc +++ b/shell/browser/api/electron_api_auto_updater.cc @@ -152,8 +152,8 @@ void Initialize(v8::Local exports, v8::Local unused, v8::Local context, void* priv) { - v8::Isolate* isolate = context->GetIsolate(); - gin_helper::Dictionary dict(isolate, exports); + v8::Isolate* const isolate = electron::JavascriptEnvironment::GetIsolate(); + gin_helper::Dictionary dict{isolate, exports}; dict.Set("autoUpdater", AutoUpdater::Create(isolate)); } diff --git a/shell/browser/api/electron_api_base_window.cc b/shell/browser/api/electron_api_base_window.cc index c1a1026cbdde..fd7ba60029bf 100644 --- a/shell/browser/api/electron_api_base_window.cc +++ b/shell/browser/api/electron_api_base_window.cc @@ -1302,7 +1302,7 @@ void Initialize(v8::Local exports, v8::Local unused, v8::Local context, void* priv) { - v8::Isolate* isolate = context->GetIsolate(); + v8::Isolate* const isolate = electron::JavascriptEnvironment::GetIsolate(); BaseWindow::SetConstructor(isolate, base::BindRepeating(&BaseWindow::New)); gin_helper::Dictionary constructor(isolate, diff --git a/shell/browser/api/electron_api_browser_window.cc b/shell/browser/api/electron_api_browser_window.cc index f4af58e8b1be..625c4229845a 100644 --- a/shell/browser/api/electron_api_browser_window.cc +++ b/shell/browser/api/electron_api_browser_window.cc @@ -341,8 +341,8 @@ void Initialize(v8::Local exports, v8::Local unused, v8::Local context, void* priv) { - v8::Isolate* isolate = context->GetIsolate(); - gin_helper::Dictionary dict(isolate, exports); + v8::Isolate* const isolate = electron::JavascriptEnvironment::GetIsolate(); + gin_helper::Dictionary dict{isolate, exports}; dict.Set("BrowserWindow", gin_helper::CreateConstructor( isolate, base::BindRepeating(&BrowserWindow::New))); diff --git a/shell/browser/api/electron_api_content_tracing.cc b/shell/browser/api/electron_api_content_tracing.cc index 70215fb7650b..278ec587df98 100644 --- a/shell/browser/api/electron_api_content_tracing.cc +++ b/shell/browser/api/electron_api_content_tracing.cc @@ -13,6 +13,7 @@ #include "base/threading/thread_restrictions.h" #include "base/trace_event/trace_config.h" #include "content/public/browser/tracing_controller.h" +#include "shell/browser/javascript_environment.h" #include "shell/common/gin_converters/callback_converter.h" #include "shell/common/gin_converters/file_path_converter.h" #include "shell/common/gin_converters/value_converter.h" @@ -171,7 +172,8 @@ void Initialize(v8::Local exports, v8::Local unused, v8::Local context, void* priv) { - gin_helper::Dictionary dict(context->GetIsolate(), exports); + v8::Isolate* const isolate = electron::JavascriptEnvironment::GetIsolate(); + gin_helper::Dictionary dict{isolate, exports}; dict.SetMethod("getCategories", &GetCategories); dict.SetMethod("startRecording", &StartTracing); dict.SetMethod("stopRecording", &StopRecording); diff --git a/shell/browser/api/electron_api_crash_reporter.cc b/shell/browser/api/electron_api_crash_reporter.cc index 7ded05d46100..989dc67b50c8 100644 --- a/shell/browser/api/electron_api_crash_reporter.cc +++ b/shell/browser/api/electron_api_crash_reporter.cc @@ -21,6 +21,7 @@ #include "electron/mas.h" #include "gin/arguments.h" #include "gin/data_object_builder.h" +#include "shell/browser/javascript_environment.h" #include "shell/common/electron_paths.h" #include "shell/common/gin_converters/callback_converter.h" #include "shell/common/gin_converters/file_path_converter.h" @@ -261,7 +262,8 @@ void Initialize(v8::Local exports, v8::Local unused, v8::Local context, void* priv) { - gin_helper::Dictionary dict(context->GetIsolate(), exports); + v8::Isolate* const isolate = electron::JavascriptEnvironment::GetIsolate(); + gin_helper::Dictionary dict(isolate, exports); dict.SetMethod("start", &electron::api::crash_reporter::Start); #if IS_MAS_BUILD() dict.SetMethod("addExtraParameter", &electron::api::crash_reporter::NoOp); diff --git a/shell/browser/api/electron_api_desktop_capturer.cc b/shell/browser/api/electron_api_desktop_capturer.cc index ee3588ca8ee9..2999ba2a1738 100644 --- a/shell/browser/api/electron_api_desktop_capturer.cc +++ b/shell/browser/api/electron_api_desktop_capturer.cc @@ -539,7 +539,8 @@ void Initialize(v8::Local exports, v8::Local unused, v8::Local context, void* priv) { - gin_helper::Dictionary dict(context->GetIsolate(), exports); + v8::Isolate* const isolate = electron::JavascriptEnvironment::GetIsolate(); + gin_helper::Dictionary dict{isolate, exports}; dict.SetMethod("createDesktopCapturer", &electron::api::DesktopCapturer::Create); dict.SetMethod( diff --git a/shell/browser/api/electron_api_dialog.cc b/shell/browser/api/electron_api_dialog.cc index b5feef3eed00..9311c26e4d47 100644 --- a/shell/browser/api/electron_api_dialog.cc +++ b/shell/browser/api/electron_api_dialog.cc @@ -5,6 +5,7 @@ #include #include +#include "shell/browser/javascript_environment.h" #include "shell/browser/ui/certificate_trust.h" #include "shell/browser/ui/file_dialog.h" #include "shell/browser/ui/message_box.h" @@ -89,8 +90,8 @@ void Initialize(v8::Local exports, v8::Local unused, v8::Local context, void* priv) { - v8::Isolate* isolate = context->GetIsolate(); - gin_helper::Dictionary dict(isolate, exports); + v8::Isolate* const isolate = electron::JavascriptEnvironment::GetIsolate(); + gin_helper::Dictionary dict{isolate, exports}; dict.SetMethod("showMessageBoxSync", &ShowMessageBoxSync); dict.SetMethod("showMessageBox", &ShowMessageBox); dict.SetMethod("_closeMessageBox", &electron::CloseMessageBox); diff --git a/shell/browser/api/electron_api_event_emitter.cc b/shell/browser/api/electron_api_event_emitter.cc index d346b757e2e9..13b4ea238237 100644 --- a/shell/browser/api/electron_api_event_emitter.cc +++ b/shell/browser/api/electron_api_event_emitter.cc @@ -7,6 +7,7 @@ #include "base/functional/bind.h" #include "base/no_destructor.h" #include "gin/dictionary.h" +#include "shell/browser/javascript_environment.h" #include "shell/common/gin_converters/callback_converter.h" #include "shell/common/node_includes.h" #include "v8/include/v8.h" @@ -27,9 +28,8 @@ void Initialize(v8::Local exports, v8::Local unused, v8::Local context, void* priv) { - v8::Isolate* isolate = context->GetIsolate(); - - gin::Dictionary dict(isolate, exports); + v8::Isolate* const isolate = electron::JavascriptEnvironment::GetIsolate(); + gin::Dictionary dict{isolate, exports}; dict.Set("setEventEmitterPrototype", base::BindRepeating(&SetEventEmitterPrototype)); } diff --git a/shell/browser/api/electron_api_global_shortcut.cc b/shell/browser/api/electron_api_global_shortcut.cc index c60569f6454e..5535227ad592 100644 --- a/shell/browser/api/electron_api_global_shortcut.cc +++ b/shell/browser/api/electron_api_global_shortcut.cc @@ -247,8 +247,8 @@ void Initialize(v8::Local exports, v8::Local unused, v8::Local context, void* priv) { - v8::Isolate* isolate = context->GetIsolate(); - gin::Dictionary dict(isolate, exports); + v8::Isolate* const isolate = electron::JavascriptEnvironment::GetIsolate(); + gin::Dictionary dict{isolate, exports}; dict.Set("globalShortcut", electron::api::GlobalShortcut::Create(isolate)); } diff --git a/shell/browser/api/electron_api_in_app_purchase.cc b/shell/browser/api/electron_api_in_app_purchase.cc index a7b478d511bd..ca3df5b56594 100644 --- a/shell/browser/api/electron_api_in_app_purchase.cc +++ b/shell/browser/api/electron_api_in_app_purchase.cc @@ -216,8 +216,8 @@ void Initialize(v8::Local exports, v8::Local context, void* priv) { #if BUILDFLAG(IS_MAC) - v8::Isolate* isolate = context->GetIsolate(); - gin_helper::Dictionary dict(isolate, exports); + v8::Isolate* const isolate = electron::JavascriptEnvironment::GetIsolate(); + gin_helper::Dictionary dict{isolate, exports}; dict.Set("inAppPurchase", InAppPurchase::Create(isolate)); #endif } diff --git a/shell/browser/api/electron_api_menu.cc b/shell/browser/api/electron_api_menu.cc index 414d327d3cf7..2387a7cd9ef1 100644 --- a/shell/browser/api/electron_api_menu.cc +++ b/shell/browser/api/electron_api_menu.cc @@ -325,9 +325,8 @@ void Initialize(v8::Local exports, v8::Local unused, v8::Local context, void* priv) { - v8::Isolate* isolate = context->GetIsolate(); - - gin_helper::Dictionary dict(isolate, exports); + v8::Isolate* const isolate = electron::JavascriptEnvironment::GetIsolate(); + gin_helper::Dictionary dict{isolate, exports}; dict.Set("Menu", Menu::GetConstructor(context)); #if BUILDFLAG(IS_MAC) dict.SetMethod("setApplicationMenu", &Menu::SetApplicationMenu); diff --git a/shell/browser/api/electron_api_native_theme.cc b/shell/browser/api/electron_api_native_theme.cc index a16284e3ef97..6fbadcf4f0f4 100644 --- a/shell/browser/api/electron_api_native_theme.cc +++ b/shell/browser/api/electron_api_native_theme.cc @@ -137,8 +137,8 @@ void Initialize(v8::Local exports, v8::Local unused, v8::Local context, void* priv) { - v8::Isolate* isolate = context->GetIsolate(); - gin::Dictionary dict(isolate, exports); + v8::Isolate* const isolate = electron::JavascriptEnvironment::GetIsolate(); + gin::Dictionary dict{isolate, exports}; dict.Set("nativeTheme", NativeTheme::Create(isolate)); } diff --git a/shell/browser/api/electron_api_notification.cc b/shell/browser/api/electron_api_notification.cc index b3eb3fa1e1b7..af392d4ac9be 100644 --- a/shell/browser/api/electron_api_notification.cc +++ b/shell/browser/api/electron_api_notification.cc @@ -251,8 +251,8 @@ void Initialize(v8::Local exports, v8::Local unused, v8::Local context, void* priv) { - v8::Isolate* isolate = context->GetIsolate(); - gin_helper::Dictionary dict(isolate, exports); + v8::Isolate* const isolate = electron::JavascriptEnvironment::GetIsolate(); + gin_helper::Dictionary dict{isolate, exports}; dict.Set("Notification", Notification::GetConstructor(context)); dict.SetMethod("isSupported", &Notification::IsSupported); } diff --git a/shell/browser/api/electron_api_power_monitor.cc b/shell/browser/api/electron_api_power_monitor.cc index 5d45e42c4c33..1d723bf492f4 100644 --- a/shell/browser/api/electron_api_power_monitor.cc +++ b/shell/browser/api/electron_api_power_monitor.cc @@ -197,8 +197,8 @@ void Initialize(v8::Local exports, v8::Local unused, v8::Local context, void* priv) { - v8::Isolate* isolate = context->GetIsolate(); - gin_helper::Dictionary dict(isolate, exports); + v8::Isolate* const isolate = electron::JavascriptEnvironment::GetIsolate(); + gin_helper::Dictionary dict{isolate, exports}; dict.SetMethod("createPowerMonitor", base::BindRepeating(&PowerMonitor::Create)); dict.SetMethod("getSystemIdleState", diff --git a/shell/browser/api/electron_api_power_save_blocker.cc b/shell/browser/api/electron_api_power_save_blocker.cc index 43256354e0dc..39267b21b898 100644 --- a/shell/browser/api/electron_api_power_save_blocker.cc +++ b/shell/browser/api/electron_api_power_save_blocker.cc @@ -14,6 +14,7 @@ #include "gin/object_template_builder.h" #include "services/device/public/mojom/wake_lock_provider.mojom.h" #include "services/service_manager/public/cpp/connector.h" +#include "shell/browser/javascript_environment.h" #include "shell/common/node_includes.h" namespace gin { @@ -139,8 +140,8 @@ void Initialize(v8::Local exports, v8::Local unused, v8::Local context, void* priv) { - v8::Isolate* isolate = context->GetIsolate(); - gin::Dictionary dict(isolate, exports); + v8::Isolate* const isolate = electron::JavascriptEnvironment::GetIsolate(); + gin::Dictionary dict{isolate, exports}; dict.Set("powerSaveBlocker", electron::api::PowerSaveBlocker::Create(isolate)); } diff --git a/shell/browser/api/electron_api_printing.cc b/shell/browser/api/electron_api_printing.cc index 8b63f4a368b3..5a41d28c03c4 100644 --- a/shell/browser/api/electron_api_printing.cc +++ b/shell/browser/api/electron_api_printing.cc @@ -5,6 +5,7 @@ #include "chrome/browser/browser_process.h" #include "gin/converter.h" #include "printing/buildflags/buildflags.h" +#include "shell/browser/javascript_environment.h" #include "shell/common/gin_helper/dictionary.h" #include "shell/common/node_includes.h" #include "shell/common/thread_restrictions.h" @@ -78,8 +79,8 @@ void Initialize(v8::Local exports, v8::Local unused, v8::Local context, void* priv) { - v8::Isolate* isolate = context->GetIsolate(); - gin_helper::Dictionary dict(isolate, exports); + v8::Isolate* const isolate = electron::JavascriptEnvironment::GetIsolate(); + gin_helper::Dictionary dict{isolate, exports}; #if BUILDFLAG(ENABLE_PRINTING) dict.SetMethod("getPrinterListAsync", base::BindRepeating(&GetPrinterListAsync)); diff --git a/shell/browser/api/electron_api_protocol.cc b/shell/browser/api/electron_api_protocol.cc index 493e7ede9cd1..65baf074b483 100644 --- a/shell/browser/api/electron_api_protocol.cc +++ b/shell/browser/api/electron_api_protocol.cc @@ -14,6 +14,7 @@ #include "gin/handle.h" #include "gin/object_template_builder.h" #include "shell/browser/browser.h" +#include "shell/browser/javascript_environment.h" #include "shell/browser/protocol_registry.h" #include "shell/common/gin_converters/callback_converter.h" #include "shell/common/gin_converters/net_converter.h" @@ -359,8 +360,8 @@ void Initialize(v8::Local exports, v8::Local unused, v8::Local context, void* priv) { - v8::Isolate* isolate = context->GetIsolate(); - gin_helper::Dictionary dict(isolate, exports); + v8::Isolate* const isolate = electron::JavascriptEnvironment::GetIsolate(); + gin_helper::Dictionary dict{isolate, exports}; dict.Set("Protocol", electron::api::Protocol::GetConstructor(context)); dict.SetMethod("registerSchemesAsPrivileged", &RegisterSchemesAsPrivileged); dict.SetMethod("getStandardSchemes", &electron::api::GetStandardSchemes); diff --git a/shell/browser/api/electron_api_push_notifications.cc b/shell/browser/api/electron_api_push_notifications.cc index 28ee7ab4d9f2..55fa9e1a190a 100644 --- a/shell/browser/api/electron_api_push_notifications.cc +++ b/shell/browser/api/electron_api_push_notifications.cc @@ -61,7 +61,7 @@ void Initialize(v8::Local exports, v8::Local unused, v8::Local context, void* priv) { - v8::Isolate* isolate = context->GetIsolate(); + v8::Isolate* const isolate = electron::JavascriptEnvironment::GetIsolate(); gin::Dictionary dict(isolate, exports); dict.Set("pushNotifications", electron::api::PushNotifications::Create(isolate)); diff --git a/shell/browser/api/electron_api_safe_storage.cc b/shell/browser/api/electron_api_safe_storage.cc index e815ec06ac18..ae48684472fd 100644 --- a/shell/browser/api/electron_api_safe_storage.cc +++ b/shell/browser/api/electron_api_safe_storage.cc @@ -7,6 +7,7 @@ #include "components/os_crypt/sync/os_crypt.h" #include "shell/browser/browser.h" #include "shell/browser/browser_process_impl.h" +#include "shell/browser/javascript_environment.h" #include "shell/common/gin_converters/base_converter.h" #include "shell/common/gin_converters/callback_converter.h" #include "shell/common/gin_helper/dictionary.h" @@ -131,7 +132,7 @@ void Initialize(v8::Local exports, v8::Local unused, v8::Local context, void* priv) { - v8::Isolate* isolate = context->GetIsolate(); + v8::Isolate* const isolate = electron::JavascriptEnvironment::GetIsolate(); gin_helper::Dictionary dict(isolate, exports); dict.SetMethod("decryptString", &DecryptString); dict.SetMethod("encryptString", &EncryptString); diff --git a/shell/browser/api/electron_api_screen.cc b/shell/browser/api/electron_api_screen.cc index 09c204bd4327..cdd0a888dfa6 100644 --- a/shell/browser/api/electron_api_screen.cc +++ b/shell/browser/api/electron_api_screen.cc @@ -223,7 +223,7 @@ void Initialize(v8::Local exports, v8::Local unused, v8::Local context, void* priv) { - v8::Isolate* isolate = context->GetIsolate(); + v8::Isolate* const isolate = electron::JavascriptEnvironment::GetIsolate(); gin_helper::Dictionary dict(isolate, exports); dict.SetMethod("createScreen", base::BindRepeating(&Screen::Create)); } diff --git a/shell/browser/api/electron_api_service_worker_main.cc b/shell/browser/api/electron_api_service_worker_main.cc index 61a7187bec5c..2a7d9ba53e3a 100644 --- a/shell/browser/api/electron_api_service_worker_main.cc +++ b/shell/browser/api/electron_api_service_worker_main.cc @@ -354,8 +354,8 @@ void Initialize(v8::Local exports, v8::Local unused, v8::Local context, void* priv) { - v8::Isolate* isolate = context->GetIsolate(); - gin_helper::Dictionary dict(isolate, exports); + v8::Isolate* const isolate = electron::JavascriptEnvironment::GetIsolate(); + gin_helper::Dictionary dict{isolate, exports}; dict.Set("ServiceWorkerMain", ServiceWorkerMain::GetConstructor(context)); } diff --git a/shell/browser/api/electron_api_session.cc b/shell/browser/api/electron_api_session.cc index 36a39f92cb80..b4522dca8144 100644 --- a/shell/browser/api/electron_api_session.cc +++ b/shell/browser/api/electron_api_session.cc @@ -1864,7 +1864,7 @@ void Initialize(v8::Local exports, v8::Local unused, v8::Local context, void* priv) { - v8::Isolate* isolate = context->GetIsolate(); + v8::Isolate* const isolate = electron::JavascriptEnvironment::GetIsolate(); gin_helper::Dictionary dict(isolate, exports); dict.Set("Session", Session::GetConstructor(context)); dict.SetMethod("fromPartition", &FromPartition); diff --git a/shell/browser/api/electron_api_system_preferences.cc b/shell/browser/api/electron_api_system_preferences.cc index f641aa997922..05771ddbe681 100644 --- a/shell/browser/api/electron_api_system_preferences.cc +++ b/shell/browser/api/electron_api_system_preferences.cc @@ -115,7 +115,7 @@ void Initialize(v8::Local exports, v8::Local unused, v8::Local context, void* priv) { - v8::Isolate* isolate = context->GetIsolate(); + v8::Isolate* const isolate = electron::JavascriptEnvironment::GetIsolate(); gin_helper::Dictionary dict(isolate, exports); dict.Set("systemPreferences", SystemPreferences::Create(isolate)); } diff --git a/shell/browser/api/electron_api_tray.cc b/shell/browser/api/electron_api_tray.cc index da76f6c8c1a4..fdad80db72c9 100644 --- a/shell/browser/api/electron_api_tray.cc +++ b/shell/browser/api/electron_api_tray.cc @@ -445,9 +445,8 @@ void Initialize(v8::Local exports, v8::Local unused, v8::Local context, void* priv) { - v8::Isolate* isolate = context->GetIsolate(); - - gin::Dictionary dict(isolate, exports); + v8::Isolate* const isolate = electron::JavascriptEnvironment::GetIsolate(); + gin::Dictionary dict{isolate, exports}; dict.Set("Tray", Tray::GetConstructor(context)); } diff --git a/shell/browser/api/electron_api_utility_process.cc b/shell/browser/api/electron_api_utility_process.cc index 83cd96bbdbfc..3fb28cb7e2c1 100644 --- a/shell/browser/api/electron_api_utility_process.cc +++ b/shell/browser/api/electron_api_utility_process.cc @@ -530,8 +530,8 @@ void Initialize(v8::Local exports, v8::Local unused, v8::Local context, void* priv) { - v8::Isolate* isolate = context->GetIsolate(); - gin_helper::Dictionary dict(isolate, exports); + v8::Isolate* const isolate = electron::JavascriptEnvironment::GetIsolate(); + gin_helper::Dictionary dict{isolate, exports}; dict.SetMethod("_fork", &electron::api::UtilityProcessWrapper::Create); } diff --git a/shell/browser/api/electron_api_view.cc b/shell/browser/api/electron_api_view.cc index 5d82abe2d213..c5c6c96754f1 100644 --- a/shell/browser/api/electron_api_view.cc +++ b/shell/browser/api/electron_api_view.cc @@ -470,9 +470,8 @@ void Initialize(v8::Local exports, v8::Local unused, v8::Local context, void* priv) { - v8::Isolate* isolate = context->GetIsolate(); - - gin_helper::Dictionary dict(isolate, exports); + v8::Isolate* const isolate = electron::JavascriptEnvironment::GetIsolate(); + gin_helper::Dictionary dict{isolate, exports}; dict.Set("View", View::GetConstructor(isolate)); } diff --git a/shell/browser/api/electron_api_web_contents.cc b/shell/browser/api/electron_api_web_contents.cc index 4292802b89d5..8283ab88377e 100644 --- a/shell/browser/api/electron_api_web_contents.cc +++ b/shell/browser/api/electron_api_web_contents.cc @@ -4653,8 +4653,8 @@ void Initialize(v8::Local exports, v8::Local unused, v8::Local context, void* priv) { - v8::Isolate* isolate = context->GetIsolate(); - gin_helper::Dictionary dict(isolate, exports); + v8::Isolate* const isolate = electron::JavascriptEnvironment::GetIsolate(); + gin_helper::Dictionary dict{isolate, exports}; dict.Set("WebContents", WebContents::GetConstructor(context)); dict.SetMethod("fromId", &WebContentsFromID); dict.SetMethod("fromFrame", &WebContentsFromFrame); diff --git a/shell/browser/api/electron_api_web_contents_view.cc b/shell/browser/api/electron_api_web_contents_view.cc index 32ca981adcfe..6fdf5d050795 100644 --- a/shell/browser/api/electron_api_web_contents_view.cc +++ b/shell/browser/api/electron_api_web_contents_view.cc @@ -228,8 +228,8 @@ void Initialize(v8::Local exports, v8::Local unused, v8::Local context, void* priv) { - v8::Isolate* isolate = context->GetIsolate(); - gin_helper::Dictionary dict(isolate, exports); + v8::Isolate* const isolate = electron::JavascriptEnvironment::GetIsolate(); + gin_helper::Dictionary dict{isolate, exports}; dict.Set("WebContentsView", WebContentsView::GetConstructor(isolate)); } diff --git a/shell/browser/api/electron_api_web_frame_main.cc b/shell/browser/api/electron_api_web_frame_main.cc index c8bb3575a3c8..45aca8f58536 100644 --- a/shell/browser/api/electron_api_web_frame_main.cc +++ b/shell/browser/api/electron_api_web_frame_main.cc @@ -674,8 +674,8 @@ void Initialize(v8::Local exports, v8::Local unused, v8::Local context, void* priv) { - v8::Isolate* isolate = context->GetIsolate(); - gin_helper::Dictionary dict(isolate, exports); + v8::Isolate* const isolate = electron::JavascriptEnvironment::GetIsolate(); + gin_helper::Dictionary dict{isolate, exports}; dict.Set("WebFrameMain", WebFrameMain::GetConstructor(context)); dict.SetMethod("fromId", &FromID); dict.SetMethod("_fromIdIfExists", &FromIdIfExists); diff --git a/shell/browser/api/electron_api_web_view_manager.cc b/shell/browser/api/electron_api_web_view_manager.cc index 55b86d1b217b..03938517bf28 100644 --- a/shell/browser/api/electron_api_web_view_manager.cc +++ b/shell/browser/api/electron_api_web_view_manager.cc @@ -3,6 +3,7 @@ // found in the LICENSE file. #include "content/public/browser/browser_context.h" +#include "shell/browser/javascript_environment.h" #include "shell/browser/web_contents_preferences.h" #include "shell/browser/web_contents_zoom_controller.h" #include "shell/browser/web_view_manager.h" @@ -40,7 +41,8 @@ void Initialize(v8::Local exports, v8::Local unused, v8::Local context, void* priv) { - gin_helper::Dictionary dict(context->GetIsolate(), exports); + v8::Isolate* const isolate = electron::JavascriptEnvironment::GetIsolate(); + gin_helper::Dictionary dict{isolate, exports}; dict.SetMethod("addGuest", &AddGuest); dict.SetMethod("removeGuest", &RemoveGuest); } diff --git a/shell/browser/api/message_port.cc b/shell/browser/api/message_port.cc index 215ae3fed0c9..7dba05fb6d8c 100644 --- a/shell/browser/api/message_port.cc +++ b/shell/browser/api/message_port.cc @@ -316,8 +316,8 @@ void Initialize(v8::Local exports, v8::Local unused, v8::Local context, void* priv) { - v8::Isolate* isolate = context->GetIsolate(); - gin_helper::Dictionary dict(isolate, exports); + v8::Isolate* const isolate = electron::JavascriptEnvironment::GetIsolate(); + gin_helper::Dictionary dict{isolate, exports}; dict.SetMethod("createPair", &CreatePair); } diff --git a/shell/browser/api/views/electron_api_image_view.cc b/shell/browser/api/views/electron_api_image_view.cc index a7bdd448917c..c0578c777761 100644 --- a/shell/browser/api/views/electron_api_image_view.cc +++ b/shell/browser/api/views/electron_api_image_view.cc @@ -4,6 +4,7 @@ #include "shell/browser/api/views/electron_api_image_view.h" +#include "shell/browser/javascript_environment.h" #include "shell/common/gin_converters/image_converter.h" #include "shell/common/gin_helper/constructor.h" #include "shell/common/gin_helper/dictionary.h" @@ -49,8 +50,8 @@ void Initialize(v8::Local exports, v8::Local unused, v8::Local context, void* priv) { - v8::Isolate* isolate = context->GetIsolate(); - gin_helper::Dictionary dict(isolate, exports); + v8::Isolate* const isolate = electron::JavascriptEnvironment::GetIsolate(); + gin_helper::Dictionary dict{isolate, exports}; dict.Set("ImageView", gin_helper::CreateConstructor( isolate, base::BindRepeating(&ImageView::New))); } diff --git a/shell/browser/electron_browser_main_parts.cc b/shell/browser/electron_browser_main_parts.cc index 82407eb8e9e2..7d8cbf08a266 100644 --- a/shell/browser/electron_browser_main_parts.cc +++ b/shell/browser/electron_browser_main_parts.cc @@ -237,8 +237,8 @@ void ElectronBrowserMainParts::PostEarlyInitialization() { node_bindings_->Initialize(js_env_->isolate()->GetCurrentContext()); // Create the global environment. node_env_ = node_bindings_->CreateEnvironment( - js_env_->isolate()->GetCurrentContext(), js_env_->platform(), - js_env_->max_young_generation_size_in_bytes()); + js_env_->isolate(), js_env_->isolate()->GetCurrentContext(), + js_env_->platform(), js_env_->max_young_generation_size_in_bytes()); node_env_->set_trace_sync_io(node_env_->options()->trace_sync_io); diff --git a/shell/common/api/crashpad_support.cc b/shell/common/api/crashpad_support.cc index 610630439503..72c334a22db5 100644 --- a/shell/common/api/crashpad_support.cc +++ b/shell/common/api/crashpad_support.cc @@ -27,7 +27,8 @@ void Initialize(v8::Local exports, v8::Local unused, v8::Local context, void* priv) { - gin_helper::Dictionary dict(context->GetIsolate(), exports); + v8::Isolate* const isolate = v8::Isolate::GetCurrent(); + gin_helper::Dictionary dict{isolate, exports}; #if BUILDFLAG(IS_LINUX) dict.SetMethod("getCrashdumpSignalFD", &GetCrashdumpSignalFD); dict.SetMethod("getCrashpadHandlerPID", &GetCrashpadHandlerPID); diff --git a/shell/common/api/electron_api_asar.cc b/shell/common/api/electron_api_asar.cc index 810f3ffdb6d0..9cf46892b19e 100644 --- a/shell/common/api/electron_api_asar.cc +++ b/shell/common/api/electron_api_asar.cc @@ -213,7 +213,7 @@ void Initialize(v8::Local exports, v8::Local unused, v8::Local context, void* priv) { - auto* isolate = exports->GetIsolate(); + v8::Isolate* const isolate = v8::Isolate::GetCurrent(); auto cons = Archive::CreateFunctionTemplate(isolate) ->GetFunction(context) diff --git a/shell/common/api/electron_api_clipboard.cc b/shell/common/api/electron_api_clipboard.cc index 84f9dd2a6cd7..17563f1e1d70 100644 --- a/shell/common/api/electron_api_clipboard.cc +++ b/shell/common/api/electron_api_clipboard.cc @@ -294,7 +294,8 @@ void Initialize(v8::Local exports, v8::Local unused, v8::Local context, void* priv) { - gin_helper::Dictionary dict(context->GetIsolate(), exports); + v8::Isolate* const isolate = v8::Isolate::GetCurrent(); + gin_helper::Dictionary dict{isolate, exports}; dict.SetMethod("availableFormats", &electron::api::Clipboard::AvailableFormats); dict.SetMethod("has", &electron::api::Clipboard::Has); diff --git a/shell/common/api/electron_api_command_line.cc b/shell/common/api/electron_api_command_line.cc index f1bacd59afb4..5225a43ec636 100644 --- a/shell/common/api/electron_api_command_line.cc +++ b/shell/common/api/electron_api_command_line.cc @@ -64,7 +64,8 @@ void Initialize(v8::Local exports, v8::Local unused, v8::Local context, void* priv) { - gin_helper::Dictionary dict(context->GetIsolate(), exports); + v8::Isolate* const isolate = v8::Isolate::GetCurrent(); + gin_helper::Dictionary dict{isolate, exports}; dict.SetMethod("hasSwitch", &HasSwitch); dict.SetMethod("getSwitchValue", &GetSwitchValue); dict.SetMethod("appendSwitch", &AppendSwitch); diff --git a/shell/common/api/electron_api_environment.cc b/shell/common/api/electron_api_environment.cc index bb1efae4760d..fd4a7a920e54 100644 --- a/shell/common/api/electron_api_environment.cc +++ b/shell/common/api/electron_api_environment.cc @@ -29,7 +29,8 @@ void Initialize(v8::Local exports, v8::Local unused, v8::Local context, void* priv) { - gin_helper::Dictionary dict(context->GetIsolate(), exports); + v8::Isolate* const isolate = v8::Isolate::GetCurrent(); + gin_helper::Dictionary dict{isolate, exports}; dict.SetMethod("getVar", &GetVar); dict.SetMethod("hasVar", &HasVar); dict.SetMethod("setVar", &SetVar); diff --git a/shell/common/api/electron_api_native_image.cc b/shell/common/api/electron_api_native_image.cc index 3aff3757a0f3..ad2afb911f13 100644 --- a/shell/common/api/electron_api_native_image.cc +++ b/shell/common/api/electron_api_native_image.cc @@ -619,8 +619,8 @@ void Initialize(v8::Local exports, v8::Local unused, v8::Local context, void* priv) { - v8::Isolate* isolate = context->GetIsolate(); - gin_helper::Dictionary dict(isolate, exports); + v8::Isolate* const isolate = v8::Isolate::GetCurrent(); + gin_helper::Dictionary dict{isolate, exports}; auto native_image = gin_helper::Dictionary::CreateEmpty(isolate); dict.Set("nativeImage", native_image); diff --git a/shell/common/api/electron_api_net.cc b/shell/common/api/electron_api_net.cc index 78a3b0a26ca7..818de5802e68 100644 --- a/shell/common/api/electron_api_net.cc +++ b/shell/common/api/electron_api_net.cc @@ -80,9 +80,9 @@ void Initialize(v8::Local exports, v8::Local unused, v8::Local context, void* priv) { - v8::Isolate* isolate = context->GetIsolate(); + v8::Isolate* const isolate = v8::Isolate::GetCurrent(); - gin_helper::Dictionary dict(isolate, exports); + gin_helper::Dictionary dict{isolate, exports}; dict.SetMethod("isOnline", &IsOnline); dict.SetMethod("isValidHeaderName", &IsValidHeaderName); dict.SetMethod("isValidHeaderValue", &IsValidHeaderValue); diff --git a/shell/common/api/electron_api_shell.cc b/shell/common/api/electron_api_shell.cc index d6097e7efbb8..944e4a6b3603 100644 --- a/shell/common/api/electron_api_shell.cc +++ b/shell/common/api/electron_api_shell.cc @@ -173,7 +173,8 @@ void Initialize(v8::Local exports, v8::Local unused, v8::Local context, void* priv) { - gin_helper::Dictionary dict(context->GetIsolate(), exports); + v8::Isolate* const isolate = v8::Isolate::GetCurrent(); + gin_helper::Dictionary dict{isolate, exports}; dict.SetMethod("showItemInFolder", &platform_util::ShowItemInFolder); dict.SetMethod("openPath", &OpenPath); dict.SetMethod("openExternal", &OpenExternal); diff --git a/shell/common/api/electron_api_testing.cc b/shell/common/api/electron_api_testing.cc index 097da88e158b..9ec0b4c97300 100644 --- a/shell/common/api/electron_api_testing.cc +++ b/shell/common/api/electron_api_testing.cc @@ -45,7 +45,8 @@ void Initialize(v8::Local exports, v8::Local unused, v8::Local context, void* priv) { - gin_helper::Dictionary dict(context->GetIsolate(), exports); + v8::Isolate* const isolate = v8::Isolate::GetCurrent(); + gin_helper::Dictionary dict{isolate, exports}; dict.SetMethod("log", &Log); dict.SetMethod("getLoggingDestination", &GetLoggingDestination); } diff --git a/shell/common/api/electron_api_v8_util.cc b/shell/common/api/electron_api_v8_util.cc index 4f3d8ec65497..51b866e638fd 100644 --- a/shell/common/api/electron_api_v8_util.cc +++ b/shell/common/api/electron_api_v8_util.cc @@ -99,7 +99,8 @@ void Initialize(v8::Local exports, v8::Local unused, v8::Local context, void* priv) { - gin_helper::Dictionary dict(context->GetIsolate(), exports); + v8::Isolate* const isolate = v8::Isolate::GetCurrent(); + gin_helper::Dictionary dict{isolate, exports}; dict.SetMethod("getHiddenValue", &GetHiddenValue); dict.SetMethod("setHiddenValue", &SetHiddenValue); dict.SetMethod("getObjectHash", &GetObjectHash); diff --git a/shell/common/api/features.cc b/shell/common/api/features.cc index af5d5303e6af..7040dcc4c7e8 100644 --- a/shell/common/api/features.cc +++ b/shell/common/api/features.cc @@ -41,7 +41,8 @@ void Initialize(v8::Local exports, v8::Local unused, v8::Local context, void* priv) { - gin_helper::Dictionary dict(context->GetIsolate(), exports); + v8::Isolate* const isolate = v8::Isolate::GetCurrent(); + gin_helper::Dictionary dict{isolate, exports}; dict.SetMethod("isBuiltinSpellCheckerEnabled", &IsBuiltinSpellCheckerEnabled); dict.SetMethod("isPDFViewerEnabled", &IsPDFViewerEnabled); dict.SetMethod("isFakeLocationProviderEnabled", diff --git a/shell/common/node_bindings.cc b/shell/common/node_bindings.cc index f76b26c699f5..bc6843428656 100644 --- a/shell/common/node_bindings.cc +++ b/shell/common/node_bindings.cc @@ -641,6 +641,7 @@ void NodeBindings::Initialize(v8::Local context) { } std::shared_ptr NodeBindings::CreateEnvironment( + v8::Isolate* isolate, v8::Local context, node::MultiIsolatePlatform* platform, size_t max_young_generation_size, @@ -664,7 +665,6 @@ std::shared_ptr NodeBindings::CreateEnvironment( break; } - v8::Isolate* isolate = context->GetIsolate(); gin_helper::Dictionary global(isolate, context->Global()); if (browser_env_ == BrowserEnvironment::kBrowser) { @@ -766,7 +766,7 @@ std::shared_ptr NodeBindings::CreateEnvironment( // could be either kExplicit or kScoped depending on whether we're executing // from within a Node.js or a Blink entrypoint. Instead, the policy is // toggled to kExplicit when entering Node.js through UvRunOnce. - is.policy = context->GetIsolate()->GetMicrotasksPolicy(); + is.policy = isolate->GetMicrotasksPolicy(); // We do not want to use Node.js' message listener as it interferes with // Blink's. @@ -775,8 +775,8 @@ std::shared_ptr NodeBindings::CreateEnvironment( // Isolate message listeners are additive (you can add multiple), so instead // we add an extra one here to ensure that the async hook stack is properly // cleared when errors are thrown. - context->GetIsolate()->AddMessageListenerWithErrorLevel( - ErrorMessageListener, v8::Isolate::kMessageError); + isolate->AddMessageListenerWithErrorLevel(ErrorMessageListener, + v8::Isolate::kMessageError); // We do not want to use the promise rejection callback that Node.js uses, // because it does not send PromiseRejectionEvents to the global script @@ -792,15 +792,14 @@ std::shared_ptr NodeBindings::CreateEnvironment( node::IsolateSettingsFlags::SHOULD_NOT_SET_PREPARE_STACK_TRACE_CALLBACK; } - node::SetIsolateUpForNode(context->GetIsolate(), is); - context->GetIsolate()->SetHostImportModuleDynamicallyCallback( - HostImportModuleDynamically); - context->GetIsolate()->SetHostImportModuleWithPhaseDynamicallyCallback( + node::SetIsolateUpForNode(isolate, is); + isolate->SetHostImportModuleDynamicallyCallback(HostImportModuleDynamically); + isolate->SetHostImportModuleWithPhaseDynamicallyCallback( HostImportModuleWithPhaseDynamically); - context->GetIsolate()->SetHostInitializeImportMetaObjectCallback( + isolate->SetHostInitializeImportMetaObjectCallback( HostInitializeImportMetaObject); - gin_helper::Dictionary process(context->GetIsolate(), env->process_object()); + gin_helper::Dictionary process(isolate, env->process_object()); process.SetReadOnly("type", process_type); if (browser_env_ == BrowserEnvironment::kBrowser || @@ -833,13 +832,14 @@ std::shared_ptr NodeBindings::CreateEnvironment( } std::shared_ptr NodeBindings::CreateEnvironment( + v8::Isolate* const isolate, v8::Local context, node::MultiIsolatePlatform* platform, size_t max_young_generation_size, std::optional> on_app_code_ready) { - return CreateEnvironment(context, platform, max_young_generation_size, - ElectronCommandLine::AsUtf8(), {}, - on_app_code_ready); + return CreateEnvironment( + isolate, context, platform, max_young_generation_size, + ElectronCommandLine::AsUtf8(), {}, on_app_code_ready); } void NodeBindings::LoadEnvironment(node::Environment* env) { diff --git a/shell/common/node_bindings.h b/shell/common/node_bindings.h index d50ad9d52d65..54491be42fd0 100644 --- a/shell/common/node_bindings.h +++ b/shell/common/node_bindings.h @@ -131,6 +131,7 @@ class NodeBindings { // Create the environment and load node.js. std::shared_ptr CreateEnvironment( + v8::Isolate* isolate, v8::Local context, node::MultiIsolatePlatform* platform, size_t max_young_generation_size, @@ -140,6 +141,7 @@ class NodeBindings { std::nullopt); std::shared_ptr CreateEnvironment( + v8::Isolate* isolate, v8::Local context, node::MultiIsolatePlatform* platform, size_t max_young_generation_size = 0, diff --git a/shell/renderer/api/electron_api_context_bridge.cc b/shell/renderer/api/electron_api_context_bridge.cc index da6bf279544b..27184f28639b 100644 --- a/shell/renderer/api/electron_api_context_bridge.cc +++ b/shell/renderer/api/electron_api_context_bridge.cc @@ -1106,8 +1106,8 @@ void Initialize(v8::Local exports, v8::Local unused, v8::Local context, void* priv) { - v8::Isolate* isolate = context->GetIsolate(); - gin_helper::Dictionary dict(isolate, exports); + v8::Isolate* const isolate = v8::Isolate::GetCurrent(); + gin_helper::Dictionary dict{isolate, exports}; dict.SetMethod("executeInWorld", &electron::api::ExecuteInWorld); dict.SetMethod("exposeAPIInWorld", &electron::api::ExposeAPIInWorld); dict.SetMethod("_overrideGlobalValueFromIsolatedWorld", diff --git a/shell/renderer/api/electron_api_crash_reporter_renderer.cc b/shell/renderer/api/electron_api_crash_reporter_renderer.cc index 1045eb611c20..fa91f31203bb 100644 --- a/shell/renderer/api/electron_api_crash_reporter_renderer.cc +++ b/shell/renderer/api/electron_api_crash_reporter_renderer.cc @@ -29,7 +29,8 @@ void Initialize(v8::Local exports, v8::Local unused, v8::Local context, void* priv) { - gin_helper::Dictionary dict(context->GetIsolate(), exports); + v8::Isolate* const isolate = v8::Isolate::GetCurrent(); + gin_helper::Dictionary dict{isolate, exports}; #if IS_MAS_BUILD() dict.SetMethod("addExtraParameter", &SetCrashKeyStub); dict.SetMethod("removeExtraParameter", &ClearCrashKeyStub); diff --git a/shell/renderer/api/electron_api_ipc_renderer.cc b/shell/renderer/api/electron_api_ipc_renderer.cc index a2e8249d6ba5..9045ad9fc4aa 100644 --- a/shell/renderer/api/electron_api_ipc_renderer.cc +++ b/shell/renderer/api/electron_api_ipc_renderer.cc @@ -267,7 +267,8 @@ void Initialize(v8::Local exports, v8::Local unused, v8::Local context, void* priv) { - gin_helper::Dictionary dict(context->GetIsolate(), exports); + v8::Isolate* const isolate = v8::Isolate::GetCurrent(); + gin_helper::Dictionary dict{isolate, exports}; dict.SetMethod("createForRenderFrame", &IPCRenderFrame::Create); dict.SetMethod("createForServiceWorker", &IPCServiceWorker::Create); } diff --git a/shell/renderer/api/electron_api_web_frame.cc b/shell/renderer/api/electron_api_web_frame.cc index 7e24e7f9bc63..575e8fccfc21 100644 --- a/shell/renderer/api/electron_api_web_frame.cc +++ b/shell/renderer/api/electron_api_web_frame.cc @@ -963,8 +963,8 @@ void Initialize(v8::Local exports, void* priv) { using namespace electron::api; // NOLINT(build/namespaces) - v8::Isolate* isolate = context->GetIsolate(); - gin_helper::Dictionary dict(isolate, exports); + v8::Isolate* const isolate = v8::Isolate::GetCurrent(); + gin_helper::Dictionary dict{isolate, exports}; dict.Set("mainFrame", WebFrameRenderer::Create( isolate, electron::GetRenderFrame(exports))); } diff --git a/shell/renderer/api/electron_api_web_utils.cc b/shell/renderer/api/electron_api_web_utils.cc index c1c399f89bf5..48f1933d8795 100644 --- a/shell/renderer/api/electron_api_web_utils.cc +++ b/shell/renderer/api/electron_api_web_utils.cc @@ -30,8 +30,8 @@ void Initialize(v8::Local exports, v8::Local unused, v8::Local context, void* priv) { - v8::Isolate* isolate = context->GetIsolate(); - gin_helper::Dictionary dict(isolate, exports); + v8::Isolate* const isolate = v8::Isolate::GetCurrent(); + gin_helper::Dictionary dict{isolate, exports}; dict.SetMethod("getPathForFile", &electron::api::web_utils::GetPathForFile); } diff --git a/shell/renderer/electron_render_frame_observer.cc b/shell/renderer/electron_render_frame_observer.cc index c12b79d8dadd..02fb0b35cce2 100644 --- a/shell/renderer/electron_render_frame_observer.cc +++ b/shell/renderer/electron_render_frame_observer.cc @@ -123,7 +123,8 @@ void ElectronRenderFrameObserver::DidInstallConditionalFeatures( context, v8::MicrotasksScope::kDoNotRunMicrotasks); if (ShouldNotifyClient(world_id)) - renderer_client_->DidCreateScriptContext(context, render_frame_); + renderer_client_->DidCreateScriptContext(v8::Isolate::GetCurrent(), context, + render_frame_); auto prefs = render_frame_->GetBlinkPreferences(); bool use_context_isolation = prefs.context_isolation; diff --git a/shell/renderer/electron_renderer_client.cc b/shell/renderer/electron_renderer_client.cc index 4316faca17cc..61b2df668655 100644 --- a/shell/renderer/electron_renderer_client.cc +++ b/shell/renderer/electron_renderer_client.cc @@ -90,6 +90,7 @@ void ElectronRendererClient::UndeferLoad(content::RenderFrame* render_frame) { } void ElectronRendererClient::DidCreateScriptContext( + v8::Isolate* const isolate, v8::Local renderer_context, content::RenderFrame* render_frame) { // TODO(zcbenz): Do not create Node environment if node integration is not @@ -126,7 +127,7 @@ void ElectronRendererClient::DidCreateScriptContext( blink::LoaderFreezeMode::kStrict); std::shared_ptr env = node_bindings_->CreateEnvironment( - renderer_context, nullptr, 0, + isolate, renderer_context, nullptr, 0, base::BindRepeating(&ElectronRendererClient::UndeferLoad, base::Unretained(this), render_frame)); @@ -134,7 +135,6 @@ void ElectronRendererClient::DidCreateScriptContext( // Node.js deletes the global fetch function when their fetch implementation // is disabled, so we need to save and re-add it after the Node.js environment // is loaded. See corresponding change in node/init.ts. - v8::Isolate* isolate = env->isolate(); v8::Local global = renderer_context->Global(); std::vector keys = {"fetch", "Response", "FormData", diff --git a/shell/renderer/electron_renderer_client.h b/shell/renderer/electron_renderer_client.h index 1cabd0a546a1..7184741d2c37 100644 --- a/shell/renderer/electron_renderer_client.h +++ b/shell/renderer/electron_renderer_client.h @@ -29,7 +29,8 @@ class ElectronRendererClient : public RendererClientBase { ElectronRendererClient& operator=(const ElectronRendererClient&) = delete; // electron::RendererClientBase: - void DidCreateScriptContext(v8::Local context, + void DidCreateScriptContext(v8::Isolate* isolate, + v8::Local context, content::RenderFrame* render_frame) override; void WillReleaseScriptContext(v8::Local context, content::RenderFrame* render_frame) override; diff --git a/shell/renderer/electron_sandboxed_renderer_client.cc b/shell/renderer/electron_sandboxed_renderer_client.cc index 9d16dc7af8d5..702ab6879536 100644 --- a/shell/renderer/electron_sandboxed_renderer_client.cc +++ b/shell/renderer/electron_sandboxed_renderer_client.cc @@ -108,6 +108,7 @@ void ElectronSandboxedRendererClient::RunScriptsAtDocumentEnd( } void ElectronSandboxedRendererClient::DidCreateScriptContext( + v8::Isolate* const isolate, v8::Local context, content::RenderFrame* render_frame) { // Only allow preload for the main frame or @@ -120,7 +121,6 @@ void ElectronSandboxedRendererClient::DidCreateScriptContext( // Wrap the bundle into a function that receives the binding object as // argument. - auto* isolate = context->GetIsolate(); auto binding = v8::Object::New(isolate); InitializeBindings(binding, context, render_frame); diff --git a/shell/renderer/electron_sandboxed_renderer_client.h b/shell/renderer/electron_sandboxed_renderer_client.h index 3199083b367f..3e36e19c3492 100644 --- a/shell/renderer/electron_sandboxed_renderer_client.h +++ b/shell/renderer/electron_sandboxed_renderer_client.h @@ -34,7 +34,8 @@ class ElectronSandboxedRendererClient : public RendererClientBase { v8::Local context, content::RenderFrame* render_frame); // electron::RendererClientBase: - void DidCreateScriptContext(v8::Local context, + void DidCreateScriptContext(v8::Isolate* isolate, + v8::Local context, content::RenderFrame* render_frame) override; void WillReleaseScriptContext(v8::Local context, content::RenderFrame* render_frame) override; diff --git a/shell/renderer/renderer_client_base.h b/shell/renderer/renderer_client_base.h index 5538ada8a32f..7311e832ae41 100644 --- a/shell/renderer/renderer_client_base.h +++ b/shell/renderer/renderer_client_base.h @@ -56,7 +56,8 @@ class RendererClientBase : public content::ContentRendererClient mojo::ScopedMessagePipeHandle interface_pipe) override; #endif - virtual void DidCreateScriptContext(v8::Local context, + virtual void DidCreateScriptContext(v8::Isolate* isolate, + v8::Local context, content::RenderFrame* render_frame) = 0; virtual void WillReleaseScriptContext(v8::Local context, content::RenderFrame* render_frame) = 0; diff --git a/shell/renderer/web_worker_observer.cc b/shell/renderer/web_worker_observer.cc index ccdaf7911a31..b89e27916bd8 100644 --- a/shell/renderer/web_worker_observer.cc +++ b/shell/renderer/web_worker_observer.cc @@ -49,7 +49,7 @@ WebWorkerObserver::~WebWorkerObserver() = default; void WebWorkerObserver::WorkerScriptReadyForEvaluation( v8::Local worker_context) { v8::Context::Scope context_scope(worker_context); - auto* isolate = worker_context->GetIsolate(); + v8::Isolate* const isolate = v8::Isolate::GetCurrent(); v8::MicrotasksScope microtasks_scope( worker_context, v8::MicrotasksScope::kDoNotRunMicrotasks); @@ -66,7 +66,7 @@ void WebWorkerObserver::WorkerScriptReadyForEvaluation( v8::Maybe initialized = node::InitializeContext(worker_context); CHECK(!initialized.IsNothing() && initialized.FromJust()); std::shared_ptr env = - node_bindings_->CreateEnvironment(worker_context, nullptr); + node_bindings_->CreateEnvironment(isolate, worker_context, nullptr); // We need to use the Blink implementation of fetch in web workers // Node.js deletes the global fetch function when their fetch implementation diff --git a/shell/services/node/node_service.cc b/shell/services/node/node_service.cc index 7acca3c991ad..c9207fc36a1c 100644 --- a/shell/services/node/node_service.cc +++ b/shell/services/node/node_service.cc @@ -136,9 +136,9 @@ void NodeService::Initialize( // Create the global environment. node_env_ = node_bindings_->CreateEnvironment( - js_env_->isolate()->GetCurrentContext(), js_env_->platform(), - js_env_->max_young_generation_size_in_bytes(), params->args, - params->exec_args); + js_env_->isolate(), js_env_->isolate()->GetCurrentContext(), + js_env_->platform(), js_env_->max_young_generation_size_in_bytes(), + params->args, params->exec_args); // Override the default handler set by NodeBindings. node_env_->isolate()->SetFatalErrorHandler(V8FatalErrorCallback); diff --git a/shell/services/node/parent_port.cc b/shell/services/node/parent_port.cc index b3867035647f..c33301f9a170 100644 --- a/shell/services/node/parent_port.cc +++ b/shell/services/node/parent_port.cc @@ -131,8 +131,8 @@ void Initialize(v8::Local exports, v8::Local unused, v8::Local context, void* priv) { - v8::Isolate* isolate = context->GetIsolate(); - gin_helper::Dictionary dict(isolate, exports); + v8::Isolate* const isolate = v8::Isolate::GetCurrent(); + gin_helper::Dictionary dict{isolate, exports}; dict.SetMethod("createParentPort", &electron::ParentPort::Create); }