refactor: remove uses of v8::Isolate::GetCurrent (#24179)

This commit is contained in:
Shelley Vohr 2020-06-22 09:35:24 -07:00 committed by GitHub
parent 563a8c83ea
commit 61a05caa78
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
24 changed files with 69 additions and 46 deletions

View file

@ -39,6 +39,7 @@
#include "shell/browser/api/gpuinfo_manager.h"
#include "shell/browser/electron_browser_context.h"
#include "shell/browser/electron_browser_main_parts.h"
#include "shell/browser/javascript_environment.h"
#include "shell/browser/login_handler.h"
#include "shell/browser/relauncher.h"
#include "shell/common/application_info.h"
@ -819,7 +820,7 @@ void App::RenderProcessReady(content::RenderProcessHost* host) {
content::WebContents* web_contents =
ElectronBrowserClient::Get()->GetWebContentsFromProcessID(host->GetID());
if (web_contents) {
v8::Isolate* isolate = v8::Isolate::GetCurrent();
v8::Isolate* isolate = JavascriptEnvironment::GetIsolate();
v8::HandleScope scope(isolate);
WebContents::FromOrCreate(isolate, web_contents);
}

View file

@ -21,6 +21,7 @@
#include "net/cookies/cookie_util.h"
#include "shell/browser/cookie_change_notifier.h"
#include "shell/browser/electron_browser_context.h"
#include "shell/browser/javascript_environment.h"
#include "shell/common/gin_converters/gurl_converter.h"
#include "shell/common/gin_converters/value_converter.h"
#include "shell/common/gin_helper/dictionary.h"
@ -365,7 +366,7 @@ v8::Local<v8::Promise> Cookies::FlushStore(v8::Isolate* isolate) {
}
void Cookies::OnCookieChanged(const net::CookieChangeInfo& change) {
v8::Isolate* isolate = v8::Isolate::GetCurrent();
v8::Isolate* isolate = JavascriptEnvironment::GetIsolate();
v8::HandleScope scope(isolate);
Emit("changed", gin::ConvertToV8(isolate, change.cookie),
gin::ConvertToV8(isolate, change.cause),

View file

@ -14,6 +14,7 @@
#include "content/public/browser/web_contents.h"
#include "gin/object_template_builder.h"
#include "gin/per_isolate_data.h"
#include "shell/browser/javascript_environment.h"
#include "shell/common/gin_converters/value_converter.h"
#include "shell/common/node_includes.h"
@ -41,7 +42,7 @@ void Debugger::DispatchProtocolMessage(DevToolsAgentHost* agent_host,
base::span<const uint8_t> message) {
DCHECK(agent_host == agent_host_);
v8::Isolate* isolate = v8::Isolate::GetCurrent();
v8::Isolate* isolate = JavascriptEnvironment::GetIsolate();
v8::Locker locker(isolate);
v8::HandleScope handle_scope(isolate);

View file

@ -19,6 +19,7 @@
#include "content/public/browser/render_process_host.h"
#include "gin/object_template_builder.h"
#include "shell/browser/api/electron_api_web_contents.h"
#include "shell/browser/javascript_environment.h"
#include "shell/common/api/electron_api_native_image.h"
#include "shell/common/gin_converters/gfx_converter.h"
#include "shell/common/gin_helper/dictionary.h"
@ -162,7 +163,7 @@ void DesktopCapturer::UpdateSourcesList(DesktopMediaList* list) {
// |media_list_sources|.
if (!webrtc::DxgiDuplicatorController::Instance()->GetDeviceNames(
&device_names)) {
v8::Isolate* isolate = v8::Isolate::GetCurrent();
v8::Isolate* isolate = JavascriptEnvironment::GetIsolate();
v8::Locker locker(isolate);
v8::HandleScope scope(isolate);
gin_helper::CallMethod(this, "_onerror", "Failed to get sources.");
@ -195,7 +196,7 @@ void DesktopCapturer::UpdateSourcesList(DesktopMediaList* list) {
}
if (!capture_window_ && !capture_screen_) {
v8::Isolate* isolate = v8::Isolate::GetCurrent();
v8::Isolate* isolate = JavascriptEnvironment::GetIsolate();
v8::Locker locker(isolate);
v8::HandleScope scope(isolate);
gin_helper::CallMethod(this, "_onfinished", captured_sources_);

View file

@ -8,6 +8,7 @@
#include <utility>
#include "shell/browser/api/ui_event.h"
#include "shell/browser/javascript_environment.h"
#include "shell/browser/native_window.h"
#include "shell/common/gin_converters/accelerator_converter.h"
#include "shell/common/gin_converters/callback_converter.h"
@ -37,7 +38,7 @@ bool InvokeBoolMethod(const Menu* menu,
const char* method,
int command_id,
bool default_value = false) {
v8::Isolate* isolate = v8::Isolate::GetCurrent();
v8::Isolate* isolate = JavascriptEnvironment::GetIsolate();
v8::HandleScope scope(isolate);
// We need to cast off const here because GetWrapper() is non-const, but
// ui::SimpleMenuModel::Delegate's methods are const.
@ -67,7 +68,7 @@ bool Menu::GetAcceleratorForCommandIdWithParams(
int command_id,
bool use_default_accelerator,
ui::Accelerator* accelerator) const {
v8::Isolate* isolate = v8::Isolate::GetCurrent();
v8::Isolate* isolate = JavascriptEnvironment::GetIsolate();
v8::HandleScope scope(isolate);
v8::Local<v8::Value> val = gin_helper::CallMethod(
isolate, const_cast<Menu*>(this), "_getAcceleratorForCommandId",
@ -81,21 +82,21 @@ bool Menu::ShouldRegisterAcceleratorForCommandId(int command_id) const {
}
void Menu::ExecuteCommand(int command_id, int flags) {
v8::Isolate* isolate = v8::Isolate::GetCurrent();
v8::Isolate* isolate = JavascriptEnvironment::GetIsolate();
v8::HandleScope scope(isolate);
gin_helper::CallMethod(isolate, const_cast<Menu*>(this), "_executeCommand",
CreateEventFromFlags(flags), command_id);
}
void Menu::OnMenuWillShow(ui::SimpleMenuModel* source) {
v8::Isolate* isolate = v8::Isolate::GetCurrent();
v8::Isolate* isolate = JavascriptEnvironment::GetIsolate();
v8::HandleScope scope(isolate);
gin_helper::CallMethod(isolate, const_cast<Menu*>(this), "_menuWillShow");
}
base::OnceClosure Menu::BindSelfToClosure(base::OnceClosure callback) {
// return ((callback, ref) => { callback() }).bind(null, callback, this)
v8::Isolate* isolate = v8::Isolate::GetCurrent();
v8::Isolate* isolate = JavascriptEnvironment::GetIsolate();
v8::Locker locker(isolate);
v8::HandleScope scope(isolate);
v8::Local<v8::Object> self;

View file

@ -14,6 +14,7 @@
#include "gin/handle.h"
#include "gin/object_template_builder.h"
#include "shell/browser/electron_browser_context.h"
#include "shell/browser/javascript_environment.h"
#include "shell/common/gin_converters/value_converter.h"
#include "shell/common/gin_helper/dictionary.h"
#include "shell/common/gin_helper/function_template_extensions.h"
@ -87,7 +88,7 @@ ServiceWorkerContext::~ServiceWorkerContext() {
void ServiceWorkerContext::OnReportConsoleMessage(
int64_t version_id,
const content::ConsoleMessage& message) {
v8::Isolate* isolate = v8::Isolate::GetCurrent();
v8::Isolate* isolate = JavascriptEnvironment::GetIsolate();
v8::HandleScope scope(isolate);
Emit("console-message",
gin::DataObjectBuilder(isolate)

View file

@ -55,6 +55,7 @@
#include "shell/browser/electron_browser_context.h"
#include "shell/browser/electron_browser_main_parts.h"
#include "shell/browser/electron_permission_manager.h"
#include "shell/browser/javascript_environment.h"
#include "shell/browser/media/media_device_id_salt.h"
#include "shell/browser/net/cert_verifier_client.h"
#include "shell/browser/session_preferences.h"
@ -300,7 +301,7 @@ void Session::OnDownloadCreated(content::DownloadManager* manager,
if (item->IsSavePackageDownload())
return;
v8::Isolate* isolate = v8::Isolate::GetCurrent();
v8::Isolate* isolate = JavascriptEnvironment::GetIsolate();
v8::Locker locker(isolate);
v8::HandleScope handle_scope(isolate);
auto handle = DownloadItem::FromOrCreate(isolate, item);
@ -346,7 +347,7 @@ v8::Local<v8::Promise> Session::ResolveProxy(gin::Arguments* args) {
}
v8::Local<v8::Promise> Session::GetCacheSize() {
auto* isolate = v8::Isolate::GetCurrent();
auto* isolate = JavascriptEnvironment::GetIsolate();
gin_helper::Promise<int64_t> promise(isolate);
auto handle = promise.GetHandle();
@ -370,7 +371,7 @@ v8::Local<v8::Promise> Session::GetCacheSize() {
}
v8::Local<v8::Promise> Session::ClearCache() {
auto* isolate = v8::Isolate::GetCurrent();
auto* isolate = JavascriptEnvironment::GetIsolate();
gin_helper::Promise<void> promise(isolate);
auto handle = promise.GetHandle();
@ -562,7 +563,7 @@ v8::Local<v8::Promise> Session::ClearHostResolverCache(gin::Arguments* args) {
}
v8::Local<v8::Promise> Session::ClearAuthCache() {
auto* isolate = v8::Isolate::GetCurrent();
auto* isolate = JavascriptEnvironment::GetIsolate();
gin_helper::Promise<void> promise(isolate);
v8::Local<v8::Promise> handle = promise.GetHandle();
@ -646,7 +647,7 @@ void Session::CreateInterruptedDownload(const gin_helper::Dictionary& options) {
options.Get("lastModified", &last_modified);
options.Get("eTag", &etag);
options.Get("startTime", &start_time);
v8::Isolate* isolate = v8::Isolate::GetCurrent();
v8::Isolate* isolate = JavascriptEnvironment::GetIsolate();
if (path.empty() || url_chain.empty() || length == 0) {
isolate->ThrowException(v8::Exception::Error(gin::StringToV8(
isolate, "Must pass non-empty path, urlChain and length.")));
@ -680,7 +681,7 @@ std::vector<base::FilePath::StringType> Session::GetPreloads() const {
#if BUILDFLAG(ENABLE_ELECTRON_EXTENSIONS)
v8::Local<v8::Promise> Session::LoadExtension(
const base::FilePath& extension_path) {
v8::Isolate* isolate = v8::Isolate::GetCurrent();
v8::Isolate* isolate = JavascriptEnvironment::GetIsolate();
gin_helper::Promise<const extensions::Extension*> promise(isolate);
v8::Local<v8::Promise> handle = promise.GetHandle();
if (browser_context()->IsOffTheRecord()) {
@ -723,7 +724,7 @@ v8::Local<v8::Value> Session::GetExtension(const std::string& extension_id) {
auto* registry = extensions::ExtensionRegistry::Get(browser_context());
const extensions::Extension* extension =
registry->GetInstalledExtension(extension_id);
v8::Isolate* isolate = v8::Isolate::GetCurrent();
v8::Isolate* isolate = JavascriptEnvironment::GetIsolate();
if (extension) {
return gin::ConvertToV8(isolate, extension);
} else {
@ -854,7 +855,7 @@ void SetSpellCheckerDictionaryDownloadURL(gin_helper::ErrorThrower thrower,
}
v8::Local<v8::Promise> Session::ListWordsInSpellCheckerDictionary() {
v8::Isolate* isolate = v8::Isolate::GetCurrent();
v8::Isolate* isolate = JavascriptEnvironment::GetIsolate();
gin_helper::Promise<std::set<std::string>> promise(isolate);
v8::Local<v8::Promise> handle = promise.GetHandle();

View file

@ -12,6 +12,7 @@
#include "shell/browser/api/electron_api_menu.h"
#include "shell/browser/api/ui_event.h"
#include "shell/browser/browser.h"
#include "shell/browser/javascript_environment.h"
#include "shell/common/api/electron_api_native_image.h"
#include "shell/common/gin_converters/gfx_converter.h"
#include "shell/common/gin_converters/guid_converter.h"
@ -343,7 +344,7 @@ gfx::Rect Tray::GetBounds() {
bool Tray::CheckAlive() {
if (!tray_icon_) {
v8::Isolate* isolate = v8::Isolate::GetCurrent();
v8::Isolate* isolate = JavascriptEnvironment::GetIsolate();
v8::Locker locker(isolate);
v8::HandleScope scope(isolate);
gin_helper::ErrorThrower(isolate).ThrowError("Tray is destroyed");

View file

@ -24,6 +24,7 @@
#include "services/network/public/mojom/url_loader_factory.mojom.h"
#include "shell/browser/api/electron_api_session.h"
#include "shell/browser/electron_browser_context.h"
#include "shell/browser/javascript_environment.h"
#include "shell/common/gin_converters/callback_converter.h"
#include "shell/common/gin_converters/gurl_converter.h"
#include "shell/common/gin_converters/net_converter.h"
@ -282,7 +283,7 @@ SimpleURLLoaderWrapper::SimpleURLLoaderWrapper(
void SimpleURLLoaderWrapper::Pin() {
// Prevent ourselves from being GC'd until the request is complete. Must be
// called after gin::CreateHandle, otherwise the wrapper isn't initialized.
v8::Isolate* isolate = v8::Isolate::GetCurrent();
v8::Isolate* isolate = JavascriptEnvironment::GetIsolate();
pinned_wrapper_.Reset(isolate, GetWrapper(isolate).ToLocalChecked());
}
@ -420,7 +421,7 @@ gin::Handle<SimpleURLLoaderWrapper> SimpleURLLoaderWrapper::Create(
void SimpleURLLoaderWrapper::OnDataReceived(base::StringPiece string_piece,
base::OnceClosure resume) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
v8::Isolate* isolate = v8::Isolate::GetCurrent();
v8::Isolate* isolate = JavascriptEnvironment::GetIsolate();
v8::HandleScope handle_scope(isolate);
auto array_buffer = v8::ArrayBuffer::New(isolate, string_piece.size());
auto backing_store = array_buffer->GetBackingStore();
@ -445,7 +446,7 @@ void SimpleURLLoaderWrapper::OnRetry(base::OnceClosure start_retry) {}
void SimpleURLLoaderWrapper::OnResponseStarted(
const GURL& final_url,
const network::mojom::URLResponseHead& response_head) {
v8::Isolate* isolate = v8::Isolate::GetCurrent();
v8::Isolate* isolate = JavascriptEnvironment::GetIsolate();
v8::HandleScope scope(isolate);
gin::Dictionary dict = gin::Dictionary::CreateEmpty(isolate);
dict.Set("statusCode", response_head.headers->response_code());

View file

@ -16,6 +16,7 @@
#include "shell/browser/api/electron_api_session.h"
#include "shell/browser/api/electron_api_web_contents.h"
#include "shell/browser/electron_browser_context.h"
#include "shell/browser/javascript_environment.h"
#include "shell/common/gin_converters/callback_converter.h"
#include "shell/common/gin_converters/gurl_converter.h"
#include "shell/common/gin_converters/net_converter.h"
@ -409,7 +410,7 @@ void WebRequest::HandleSimpleEvent(SimpleEvent event,
if (!MatchesFilterCondition(request_info, info.url_patterns))
return;
v8::Isolate* isolate = v8::Isolate::GetCurrent();
v8::Isolate* isolate = JavascriptEnvironment::GetIsolate();
v8::HandleScope handle_scope(isolate);
gin::Dictionary details(isolate, v8::Object::New(isolate));
FillDetails(&details, request_info, args...);
@ -432,7 +433,7 @@ int WebRequest::HandleResponseEvent(ResponseEvent event,
callbacks_[request_info->id] = std::move(callback);
v8::Isolate* isolate = v8::Isolate::GetCurrent();
v8::Isolate* isolate = JavascriptEnvironment::GetIsolate();
v8::HandleScope handle_scope(isolate);
gin::Dictionary details(isolate, v8::Object::New(isolate));
FillDetails(&details, request_info, args...);
@ -454,7 +455,7 @@ void WebRequest::OnListenerResult(uint64_t id,
int result = net::OK;
if (response->IsObject()) {
v8::Isolate* isolate = v8::Isolate::GetCurrent();
v8::Isolate* isolate = JavascriptEnvironment::GetIsolate();
gin::Dictionary dict(isolate, response.As<v8::Object>());
bool cancel = false;

View file

@ -8,6 +8,7 @@
#include "gin/data_object_builder.h"
#include "gin/object_template_builder.h"
#include "shell/browser/javascript_environment.h"
#include "shell/common/gin_converters/blink_converter.h"
#include "shell/common/gin_converters/std_converter.h"
@ -19,7 +20,7 @@ Event::Event() {}
Event::~Event() {
if (callback_) {
v8::Isolate* isolate = v8::Isolate::GetCurrent();
v8::Isolate* isolate = electron::JavascriptEnvironment::GetIsolate();
v8::HandleScope scope(isolate);
auto message = gin::DataObjectBuilder(isolate)
.Set("error", "reply was never sent")

View file

@ -13,6 +13,7 @@
#include "gin/data_object_builder.h"
#include "gin/handle.h"
#include "gin/object_template_builder.h"
#include "shell/browser/javascript_environment.h"
#include "shell/common/gin_helper/dictionary.h"
#include "shell/common/gin_helper/error_thrower.h"
#include "shell/common/gin_helper/event_emitter_caller.h"
@ -111,7 +112,7 @@ void MessagePort::Close() {
if (!HasPendingActivity())
Unpin();
v8::Isolate* isolate = v8::Isolate::GetCurrent();
v8::Isolate* isolate = JavascriptEnvironment::GetIsolate();
v8::HandleScope scope(isolate);
v8::Local<v8::Object> self;
if (GetWrapper(isolate).ToLocal(&self))
@ -122,7 +123,7 @@ void MessagePort::Entangle(blink::MessagePortDescriptor port) {
DCHECK(port.IsValid());
DCHECK(!connector_);
port_ = std::move(port);
v8::Isolate* isolate = v8::Isolate::GetCurrent();
v8::Isolate* isolate = JavascriptEnvironment::GetIsolate();
v8::HandleScope scope(isolate);
connector_ = std::make_unique<mojo::Connector>(
port_.TakeHandleToEntangleWithEmbedder(),
@ -212,7 +213,7 @@ std::vector<blink::MessagePortChannel> MessagePort::DisentanglePorts(
void MessagePort::Pin() {
if (!pinned_.IsEmpty())
return;
v8::Isolate* isolate = v8::Isolate::GetCurrent();
v8::Isolate* isolate = JavascriptEnvironment::GetIsolate();
v8::HandleScope scope(isolate);
v8::Local<v8::Value> self;
if (GetWrapper(isolate).ToLocal(&self)) {
@ -231,7 +232,7 @@ bool MessagePort::Accept(mojo::Message* mojo_message) {
return false;
}
v8::Isolate* isolate = v8::Isolate::GetCurrent();
v8::Isolate* isolate = JavascriptEnvironment::GetIsolate();
v8::HandleScope scope(isolate);
auto ports = EntanglePorts(isolate, std::move(message.ports));

View file

@ -5,6 +5,7 @@
#include "shell/browser/api/ui_event.h"
#include "gin/data_object_builder.h"
#include "shell/browser/javascript_environment.h"
#include "ui/events/event_constants.h"
#include "v8/include/v8.h"
@ -17,7 +18,7 @@ constexpr int mouse_button_flags =
ui::EF_FORWARD_MOUSE_BUTTON);
v8::Local<v8::Object> CreateEventFromFlags(int flags) {
v8::Isolate* isolate = v8::Isolate::GetCurrent();
v8::Isolate* isolate = JavascriptEnvironment::GetIsolate();
const int is_mouse_click = static_cast<bool>(flags & mouse_button_flags);
return gin::DataObjectBuilder(isolate)
.Set("shiftKey", static_cast<bool>(flags & ui::EF_SHIFT_DOWN))

View file

@ -10,6 +10,7 @@
#include "content/public/browser/render_widget_host_view.h"
#include "shell/browser/api/electron_api_web_contents.h"
#include "shell/browser/javascript_environment.h"
#include "shell/browser/native_window.h"
namespace electron {
@ -28,7 +29,7 @@ void AutofillDriver::ShowAutofillPopup(
const gfx::RectF& bounds,
const std::vector<base::string16>& values,
const std::vector<base::string16>& labels) {
v8::Isolate* isolate = v8::Isolate::GetCurrent();
v8::Isolate* isolate = JavascriptEnvironment::GetIsolate();
v8::HandleScope scope(isolate);
auto* web_contents =
api::WebContents::From(isolate, content::WebContents::FromRenderFrameHost(

View file

@ -75,6 +75,7 @@
#include "shell/browser/electron_quota_permission_context.h"
#include "shell/browser/electron_speech_recognition_manager_delegate.h"
#include "shell/browser/font_defaults.h"
#include "shell/browser/javascript_environment.h"
#include "shell/browser/media/media_capture_devices_dispatcher.h"
#include "shell/browser/native_window.h"
#include "shell/browser/net/network_context_service.h"
@ -1406,7 +1407,7 @@ bool ElectronBrowserClient::WillInterceptWebSocket(
if (!frame)
return false;
v8::Isolate* isolate = v8::Isolate::GetCurrent();
v8::Isolate* isolate = JavascriptEnvironment::GetIsolate();
v8::HandleScope scope(isolate);
auto* browser_context = frame->GetProcess()->GetBrowserContext();
auto web_request = api::WebRequest::FromOrCreate(isolate, browser_context);
@ -1427,7 +1428,7 @@ void ElectronBrowserClient::CreateWebSocket(
const base::Optional<std::string>& user_agent,
mojo::PendingRemote<network::mojom::WebSocketHandshakeClient>
handshake_client) {
v8::Isolate* isolate = v8::Isolate::GetCurrent();
v8::Isolate* isolate = JavascriptEnvironment::GetIsolate();
v8::HandleScope scope(isolate);
auto* browser_context = frame->GetProcess()->GetBrowserContext();
auto web_request = api::WebRequest::FromOrCreate(isolate, browser_context);
@ -1453,7 +1454,7 @@ bool ElectronBrowserClient::WillCreateURLLoaderFactory(
bool* bypass_redirect_checks,
bool* disable_secure_dns,
network::mojom::URLLoaderFactoryOverridePtr* factory_override) {
v8::Isolate* isolate = v8::Isolate::GetCurrent();
v8::Isolate* isolate = JavascriptEnvironment::GetIsolate();
v8::HandleScope scope(isolate);
auto web_request = api::WebRequest::FromOrCreate(isolate, browser_context);
DCHECK(web_request.get());

View file

@ -20,6 +20,7 @@
#include "net/base/filename_util.h"
#include "shell/browser/api/electron_api_download_item.h"
#include "shell/browser/electron_browser_context.h"
#include "shell/browser/javascript_environment.h"
#include "shell/browser/native_window.h"
#include "shell/browser/ui/file_dialog.h"
#include "shell/browser/web_contents_preferences.h"
@ -116,7 +117,7 @@ void ElectronDownloadManagerDelegate::OnDownloadPathGenerated(
!web_preferences || web_preferences->IsEnabled(options::kOffscreen);
settings.force_detached = offscreen;
v8::Isolate* isolate = v8::Isolate::GetCurrent();
v8::Isolate* isolate = JavascriptEnvironment::GetIsolate();
v8::HandleScope scope(isolate);
gin_helper::Promise<gin_helper::Dictionary> dialog_promise(isolate);
auto dialog_callback = base::BindOnce(

View file

@ -6,6 +6,7 @@
#include "content/public/browser/navigation_handle.h"
#include "shell/browser/api/electron_api_web_contents.h"
#include "shell/browser/javascript_environment.h"
namespace electron {
@ -28,7 +29,7 @@ ElectronNavigationThrottle::WillRedirectRequest() {
return PROCEED;
}
v8::Isolate* isolate = v8::Isolate::GetCurrent();
v8::Isolate* isolate = JavascriptEnvironment::GetIsolate();
v8::HandleScope scope(isolate);
auto api_contents = electron::api::WebContents::From(isolate, contents);
if (api_contents.IsEmpty()) {

View file

@ -8,6 +8,7 @@
#include <utility>
#include "gin/object_template_builder.h"
#include "shell/browser/javascript_environment.h"
#include "shell/common/gin_helper/event_emitter.h"
namespace gin_helper {
@ -22,7 +23,7 @@ class EventEmitterMixin {
// this.emit(name, new Event(), args...);
template <typename... Args>
bool Emit(base::StringPiece name, Args&&... args) {
v8::Isolate* isolate = v8::Isolate::GetCurrent();
v8::Isolate* isolate = electron::JavascriptEnvironment::GetIsolate();
v8::Locker locker(isolate);
v8::HandleScope handle_scope(isolate);
v8::Local<v8::Object> wrapper;
@ -38,7 +39,7 @@ class EventEmitterMixin {
bool EmitCustomEvent(base::StringPiece name,
v8::Local<v8::Object> custom_event,
Args&&... args) {
v8::Isolate* isolate = v8::Isolate::GetCurrent();
v8::Isolate* isolate = electron::JavascriptEnvironment::GetIsolate();
v8::HandleScope scope(isolate);
v8::Local<v8::Object> wrapper;
if (!static_cast<T*>(this)->GetWrapper(isolate).ToLocal(&wrapper))

View file

@ -15,6 +15,7 @@
#include "gin/arguments.h"
#include "gin/dictionary.h"
#include "shell/browser/api/electron_api_web_contents.h"
#include "shell/browser/javascript_environment.h"
#include "shell/common/gin_converters/callback_converter.h"
#include "shell/common/gin_converters/gurl_converter.h"
#include "shell/common/gin_converters/net_converter.h"
@ -50,7 +51,7 @@ void LoginHandler::EmitEvent(
const GURL& url,
scoped_refptr<net::HttpResponseHeaders> response_headers,
bool first_auth_attempt) {
v8::Isolate* isolate = v8::Isolate::GetCurrent();
v8::Isolate* isolate = JavascriptEnvironment::GetIsolate();
v8::HandleScope scope(isolate);
auto api_web_contents = api::WebContents::From(isolate, web_contents());

View file

@ -9,6 +9,7 @@
#include "base/memory/ref_counted.h"
#include "net/cert/x509_certificate.h"
#include "shell/browser/javascript_environment.h"
#include "shell/common/gin_helper/promise.h"
namespace electron {

View file

@ -89,7 +89,7 @@ v8::Local<v8::Promise> ShowCertificateTrust(
electron::NativeWindow* parent_window,
const scoped_refptr<net::X509Certificate>& cert,
const std::string& message) {
v8::Isolate* isolate = v8::Isolate::GetCurrent();
v8::Isolate* isolate = electron::JavascriptEnvironment::GetIsolate();
gin_helper::Promise<void> promise(isolate);
v8::Local<v8::Promise> handle = promise.GetHandle();

View file

@ -10,6 +10,7 @@
#include "net/cert/cert_database.h"
#include "net/cert/x509_util_win.h"
#include "shell/browser/javascript_environment.h"
namespace certificate_trust {
@ -60,7 +61,7 @@ v8::Local<v8::Promise> ShowCertificateTrust(
electron::NativeWindow* parent_window,
const scoped_refptr<net::X509Certificate>& cert,
const std::string& message) {
v8::Isolate* isolate = v8::Isolate::GetCurrent();
v8::Isolate* isolate = electron::JavascriptEnvironment::GetIsolate();
gin_helper::Promise<void> promise(isolate);
v8::Local<v8::Promise> handle = promise.GetHandle();

View file

@ -10,6 +10,7 @@
#include "base/callback.h"
#include "base/files/file_util.h"
#include "base/strings/string_util.h"
#include "shell/browser/javascript_environment.h"
#include "shell/browser/native_window_views.h"
#include "shell/browser/unresponsive_suppressor.h"
#include "shell/common/gin_converters/file_path_converter.h"
@ -204,7 +205,7 @@ class FileChooserDialog {
void FileChooserDialog::OnFileDialogResponse(GtkWidget* widget, int response) {
gtk_widget_hide(dialog_);
v8::Isolate* isolate = v8::Isolate::GetCurrent();
v8::Isolate* isolate = electron::JavascriptEnvironment::GetIsolate();
v8::HandleScope scope(isolate);
if (save_promise_) {
gin_helper::Dictionary dict =

View file

@ -26,6 +26,7 @@
#include "net/base/directory_lister.h"
#include "net/base/mime_util.h"
#include "shell/browser/electron_browser_context.h"
#include "shell/browser/javascript_environment.h"
#include "shell/browser/native_window.h"
#include "shell/browser/ui/file_dialog.h"
#include "shell/common/gin_converters/callback_converter.h"
@ -57,7 +58,7 @@ class FileSelectHelper : public base::RefCounted<FileSelectHelper>,
}
void ShowOpenDialog(const file_dialog::DialogSettings& settings) {
v8::Isolate* isolate = v8::Isolate::GetCurrent();
v8::Isolate* isolate = electron::JavascriptEnvironment::GetIsolate();
v8::HandleScope scope(isolate);
gin_helper::Promise<gin_helper::Dictionary> promise(isolate);
@ -68,7 +69,7 @@ class FileSelectHelper : public base::RefCounted<FileSelectHelper>,
}
void ShowSaveDialog(const file_dialog::DialogSettings& settings) {
v8::Isolate* isolate = v8::Isolate::GetCurrent();
v8::Isolate* isolate = electron::JavascriptEnvironment::GetIsolate();
v8::HandleScope scope(isolate);
gin_helper::Promise<gin_helper::Dictionary> promise(isolate);