From 73e791475b79a91f770026b797715ee72edd9878 Mon Sep 17 00:00:00 2001 From: "trop[bot]" <37223003+trop[bot]@users.noreply.github.com> Date: Sat, 30 Nov 2024 06:53:07 -0600 Subject: [PATCH] refactor: return-braced-init-list pt 2 of 2 (#44890) * refactor: more return-braced-init-list, this time for v8 and gin objects Co-authored-by: Charles Kerr * refactor: more return-braced-init-list, this time for v8, gin, std, and base objects Co-authored-by: Charles Kerr --------- Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Charles Kerr --- shell/browser/api/electron_api_data_pipe_holder.cc | 2 +- shell/browser/api/electron_api_download_item.cc | 2 +- shell/browser/api/electron_api_notification.cc | 2 +- shell/browser/api/electron_api_protocol.cc | 2 +- .../api/electron_api_service_worker_context.cc | 2 +- shell/browser/api/electron_api_session.cc | 2 +- .../api/electron_api_system_preferences_win.cc | 2 +- shell/browser/api/electron_api_utility_process.cc | 8 ++++---- shell/browser/api/electron_api_view.cc | 2 +- shell/browser/api/electron_api_web_contents.cc | 4 ++-- .../browser/api/electron_api_web_contents_view.cc | 4 ++-- shell/browser/api/electron_api_web_frame_main.cc | 4 ++-- shell/browser/api/electron_api_web_request.cc | 4 ++-- shell/browser/api/message_port.cc | 4 ++-- shell/browser/browser_win.cc | 6 +++--- shell/browser/electron_browser_client.cc | 4 ++-- shell/browser/electron_browser_context.cc | 2 +- .../browser/electron_web_ui_controller_factory.cc | 2 +- .../extensions/electron_extension_system.cc | 2 +- shell/browser/file_select_helper.cc | 2 +- shell/browser/osr/osr_render_widget_host_view.cc | 4 ++-- shell/browser/osr/osr_web_contents_view.cc | 6 +++--- shell/browser/ui/devtools_manager_delegate.cc | 4 ++-- shell/common/api/electron_api_url_loader.cc | 6 +++--- shell/common/api/electron_api_v8_util.cc | 4 ++-- .../extensions/electron_extensions_api_provider.cc | 2 +- shell/common/gin_helper/event_emitter_caller.h | 2 +- shell/common/gin_helper/trackable_object.h | 2 +- shell/common/mac/codesign_util.cc | 6 +++--- shell/common/node_bindings.cc | 2 +- shell/renderer/api/electron_api_context_bridge.cc | 14 +++++++------- shell/renderer/api/electron_api_ipc_renderer.cc | 8 ++++---- shell/renderer/electron_api_service_impl.cc | 2 +- .../renderer/electron_sandboxed_renderer_client.cc | 2 +- shell/renderer/renderer_client_base.cc | 2 +- 35 files changed, 64 insertions(+), 64 deletions(-) diff --git a/shell/browser/api/electron_api_data_pipe_holder.cc b/shell/browser/api/electron_api_data_pipe_holder.cc index 03b28431c793..f2cc6a9f9bb3 100644 --- a/shell/browser/api/electron_api_data_pipe_holder.cc +++ b/shell/browser/api/electron_api_data_pipe_holder.cc @@ -188,7 +188,7 @@ gin::Handle DataPipeHolder::From(v8::Isolate* isolate, if (gin::ConvertFromV8(isolate, object.ToLocalChecked(), &handle)) return handle; } - return gin::Handle(); + return {}; } } // namespace electron::api diff --git a/shell/browser/api/electron_api_download_item.cc b/shell/browser/api/electron_api_download_item.cc index feddcc94ae1b..04488d350706 100644 --- a/shell/browser/api/electron_api_download_item.cc +++ b/shell/browser/api/electron_api_download_item.cc @@ -209,7 +209,7 @@ const GURL& DownloadItem::GetURL() const { v8::Local DownloadItem::GetURLChain() const { if (!CheckAlive()) - return v8::Local(); + return {}; return gin::ConvertToV8(isolate_, download_item_->GetUrlChain()); } diff --git a/shell/browser/api/electron_api_notification.cc b/shell/browser/api/electron_api_notification.cc index 999f55b39ddd..459a2e1b7e2b 100644 --- a/shell/browser/api/electron_api_notification.cc +++ b/shell/browser/api/electron_api_notification.cc @@ -81,7 +81,7 @@ gin::Handle Notification::New(gin_helper::ErrorThrower thrower, gin::Arguments* args) { if (!Browser::Get()->is_ready()) { thrower.ThrowError("Cannot create Notification before app is ready"); - return gin::Handle(); + return {}; } return gin::CreateHandle(thrower.isolate(), new Notification(args)); } diff --git a/shell/browser/api/electron_api_protocol.cc b/shell/browser/api/electron_api_protocol.cc index 896570a40267..f1476dbee0b7 100644 --- a/shell/browser/api/electron_api_protocol.cc +++ b/shell/browser/api/electron_api_protocol.cc @@ -301,7 +301,7 @@ gin::Handle Protocol::Create( // static gin::Handle Protocol::New(gin_helper::ErrorThrower thrower) { thrower.ThrowError("Protocol cannot be created from JS"); - return gin::Handle(); + return {}; } // static diff --git a/shell/browser/api/electron_api_service_worker_context.cc b/shell/browser/api/electron_api_service_worker_context.cc index 4cfb23895a7b..0994bf6ca3d8 100644 --- a/shell/browser/api/electron_api_service_worker_context.cc +++ b/shell/browser/api/electron_api_service_worker_context.cc @@ -133,7 +133,7 @@ v8::Local ServiceWorkerContext::GetWorkerInfoFromID( auto iter = info_map.find(version_id); if (iter == info_map.end()) { thrower.ThrowError("Could not find service worker with that version_id"); - return v8::Local(); + return {}; } return ServiceWorkerRunningInfoToDict(thrower.isolate(), std::move(iter->second)); diff --git a/shell/browser/api/electron_api_session.cc b/shell/browser/api/electron_api_session.cc index a2169341aa99..381b14080fb8 100644 --- a/shell/browser/api/electron_api_session.cc +++ b/shell/browser/api/electron_api_session.cc @@ -1583,7 +1583,7 @@ std::optional> Session::FromPath( gin::Handle Session::New() { gin_helper::ErrorThrower(JavascriptEnvironment::GetIsolate()) .ThrowError("Session objects cannot be created with 'new'"); - return gin::Handle(); + return {}; } void Session::FillObjectTemplate(v8::Isolate* isolate, diff --git a/shell/browser/api/electron_api_system_preferences_win.cc b/shell/browser/api/electron_api_system_preferences_win.cc index b5097657bb5c..78fb911f6c76 100644 --- a/shell/browser/api/electron_api_system_preferences_win.cc +++ b/shell/browser/api/electron_api_system_preferences_win.cc @@ -154,7 +154,7 @@ std::string SystemPreferences::GetMediaAccessStatus( DeviceAccessStatus::DeviceAccessStatus_Allowed); } else { thrower.ThrowError("Invalid media type"); - return std::string(); + return {}; } } diff --git a/shell/browser/api/electron_api_utility_process.cc b/shell/browser/api/electron_api_utility_process.cc index a40d84ea948d..387b82c92fe6 100644 --- a/shell/browser/api/electron_api_utility_process.cc +++ b/shell/browser/api/electron_api_utility_process.cc @@ -415,7 +415,7 @@ gin::Handle UtilityProcessWrapper::Create( gin_helper::Dictionary dict; if (!args->GetNext(&dict)) { args->ThrowTypeError("Options must be an object."); - return gin::Handle(); + return {}; } std::u16string display_name; @@ -429,19 +429,19 @@ gin::Handle UtilityProcessWrapper::Create( dict.Get("modulePath", ¶ms->script); if (dict.Has("args") && !dict.Get("args", ¶ms->args)) { args->ThrowTypeError("Invalid value for args"); - return gin::Handle(); + return {}; } gin_helper::Dictionary opts; if (dict.Get("options", &opts)) { if (opts.Has("env") && !opts.Get("env", &env_map)) { args->ThrowTypeError("Invalid value for env"); - return gin::Handle(); + return {}; } if (opts.Has("execArgv") && !opts.Get("execArgv", ¶ms->exec_args)) { args->ThrowTypeError("Invalid value for execArgv"); - return gin::Handle(); + return {}; } opts.Get("serviceName", &display_name); diff --git a/shell/browser/api/electron_api_view.cc b/shell/browser/api/electron_api_view.cc index cd9337641996..6382b0d4fdfe 100644 --- a/shell/browser/api/electron_api_view.cc +++ b/shell/browser/api/electron_api_view.cc @@ -429,7 +429,7 @@ gin::Handle View::Create(v8::Isolate* isolate) { if (gin::ConvertFromV8(isolate, obj, &view)) return view; } - return gin::Handle(); + return {}; } // static diff --git a/shell/browser/api/electron_api_web_contents.cc b/shell/browser/api/electron_api_web_contents.cc index bb2ad030161e..338c96324e25 100644 --- a/shell/browser/api/electron_api_web_contents.cc +++ b/shell/browser/api/electron_api_web_contents.cc @@ -1983,7 +1983,7 @@ gin::Handle WebContents::MakeEventWithSender( ReplyChannel::Create(isolate, std::move(callback)) ->SendError("WebContents was destroyed"); } - return gin::Handle(); + return {}; } gin::Handle event = gin_helper::internal::Event::New(isolate); @@ -2541,7 +2541,7 @@ std::vector WebContents::GetHistory() const { // If the history is empty, it contains only one entry and that is // "InitialEntry" if (history_length == 1 && controller.GetEntryAtIndex(0)->IsInitialEntry()) - return std::vector(); + return {}; std::vector history; history.reserve(history_length); diff --git a/shell/browser/api/electron_api_web_contents_view.cc b/shell/browser/api/electron_api_web_contents_view.cc index 639fdecf7701..764bc56daa5a 100644 --- a/shell/browser/api/electron_api_web_contents_view.cc +++ b/shell/browser/api/electron_api_web_contents_view.cc @@ -66,7 +66,7 @@ gin::Handle WebContentsView::GetWebContents(v8::Isolate* isolate) { if (api_web_contents_) return gin::CreateHandle(isolate, api_web_contents_.get()); else - return gin::Handle(); + return {}; } void WebContentsView::SetBackgroundColor(std::optional color) { @@ -152,7 +152,7 @@ gin::Handle WebContentsView::Create( if (gin::ConvertFromV8(isolate, web_contents_view_obj, &web_contents_view)) return web_contents_view; } - return gin::Handle(); + return {}; } // static diff --git a/shell/browser/api/electron_api_web_frame_main.cc b/shell/browser/api/electron_api_web_frame_main.cc index a5cde1af50aa..6415e3019f98 100644 --- a/shell/browser/api/electron_api_web_frame_main.cc +++ b/shell/browser/api/electron_api_web_frame_main.cc @@ -435,14 +435,14 @@ void WebFrameMain::DOMContentLoaded() { // static gin::Handle WebFrameMain::New(v8::Isolate* isolate) { - return gin::Handle(); + return {}; } // static gin::Handle WebFrameMain::From(v8::Isolate* isolate, content::RenderFrameHost* rfh) { if (!rfh) - return gin::Handle(); + return {}; auto* web_frame = FromRenderFrameHost(rfh); if (web_frame) diff --git a/shell/browser/api/electron_api_web_request.cc b/shell/browser/api/electron_api_web_request.cc index e789fc3d3dfa..e71f68f96a5b 100644 --- a/shell/browser/api/electron_api_web_request.cc +++ b/shell/browser/api/electron_api_web_request.cc @@ -723,11 +723,11 @@ gin::Handle WebRequest::From( v8::Isolate* isolate, content::BrowserContext* browser_context) { if (!browser_context) - return gin::Handle(); + return {}; auto* user_data = static_cast(browser_context->GetUserData(kUserDataKey)); if (!user_data) - return gin::Handle(); + return {}; return gin::CreateHandle(isolate, user_data->data.get()); } diff --git a/shell/browser/api/message_port.cc b/shell/browser/api/message_port.cc index 922f776ab2d5..b66b09dc22f4 100644 --- a/shell/browser/api/message_port.cc +++ b/shell/browser/api/message_port.cc @@ -226,7 +226,7 @@ std::vector MessagePort::DisentanglePorts( const std::vector>& ports, bool* threw_exception) { if (ports.empty()) - return std::vector(); + return {}; std::unordered_set visited; @@ -245,7 +245,7 @@ std::vector MessagePort::DisentanglePorts( gin_helper::ErrorThrower(isolate).ThrowError( "Port at index " + base::NumberToString(i) + " is " + type + "."); *threw_exception = true; - return std::vector(); + return {}; } visited.insert(port); } diff --git a/shell/browser/browser_win.cc b/shell/browser/browser_win.cc index 6ab01b4f2547..da035a79099f 100644 --- a/shell/browser/browser_win.cc +++ b/shell/browser/browser_win.cc @@ -97,7 +97,7 @@ bool IsValidCustomProtocol(const std::wstring& scheme) { std::wstring GetAppInfoHelperForProtocol(ASSOCSTR assoc_str, const GURL& url) { const std::wstring url_scheme = base::ASCIIToWide(url.scheme_piece()); if (!IsValidCustomProtocol(url_scheme)) - return std::wstring(); + return {}; wchar_t out_buffer[1024]; DWORD buffer_size = std::size(out_buffer); @@ -106,7 +106,7 @@ std::wstring GetAppInfoHelperForProtocol(ASSOCSTR assoc_str, const GURL& url) { nullptr, out_buffer, &buffer_size); if (FAILED(hr)) { DLOG(WARNING) << "AssocQueryString failed!"; - return std::wstring(); + return {}; } return std::wstring(out_buffer); } @@ -251,7 +251,7 @@ std::unique_ptr FetchFileVersionInfo() { electron::ScopedAllowBlockingForElectron allow_blocking; return FileVersionInfo::CreateFileVersionInfo(path); } - return std::unique_ptr(); + return {}; } } // namespace diff --git a/shell/browser/electron_browser_client.cc b/shell/browser/electron_browser_client.cc index b00ff9721c4c..9e105f55ae54 100644 --- a/shell/browser/electron_browser_client.cc +++ b/shell/browser/electron_browser_client.cc @@ -793,7 +793,7 @@ ElectronBrowserClient::CreateClientCertStore( #elif BUILDFLAG(IS_MAC) return std::make_unique(); #elif defined(USE_OPENSSL) - return std::unique_ptr(); + return (); #endif } @@ -802,7 +802,7 @@ ElectronBrowserClient::OverrideSystemLocationProvider() { #if BUILDFLAG(OVERRIDE_LOCATION_PROVIDER) return std::make_unique(); #else - return nullptr; + return {}; #endif } diff --git a/shell/browser/electron_browser_context.cc b/shell/browser/electron_browser_context.cc index b2396153ce08..652259922c3c 100644 --- a/shell/browser/electron_browser_context.cc +++ b/shell/browser/electron_browser_context.cc @@ -484,7 +484,7 @@ ElectronBrowserContext::CreateZoomLevelDelegate( if (!IsOffTheRecord()) { return std::make_unique(prefs(), partition_path); } - return std::unique_ptr(); + return {}; } content::DownloadManagerDelegate* diff --git a/shell/browser/electron_web_ui_controller_factory.cc b/shell/browser/electron_web_ui_controller_factory.cc index 9d785cad89a2..183a9bb6dad2 100644 --- a/shell/browser/electron_web_ui_controller_factory.cc +++ b/shell/browser/electron_web_ui_controller_factory.cc @@ -54,7 +54,7 @@ ElectronWebUIControllerFactory::CreateWebUIControllerForURL( if (host == chrome::kChromeUIAccessibilityHost) return std::make_unique(web_ui); - return std::unique_ptr(); + return {}; } } // namespace electron diff --git a/shell/browser/extensions/electron_extension_system.cc b/shell/browser/extensions/electron_extension_system.cc index 9d3ac16f3705..6361095193e3 100644 --- a/shell/browser/extensions/electron_extension_system.cc +++ b/shell/browser/extensions/electron_extension_system.cc @@ -98,7 +98,7 @@ std::unique_ptr ParseManifest( if (!manifest.get() || !manifest->is_dict()) { LOG(ERROR) << "Failed to parse extension manifest."; - return std::unique_ptr(); + return {}; } return std::make_unique(std::move(*manifest).TakeDict()); } diff --git a/shell/browser/file_select_helper.cc b/shell/browser/file_select_helper.cc index 45e03035c261..658179a9ea81 100644 --- a/shell/browser/file_select_helper.cc +++ b/shell/browser/file_select_helper.cc @@ -530,7 +530,7 @@ bool FileSelectHelper::IsAcceptTypeValid(const std::string& accept_type) { base::FilePath FileSelectHelper::GetSanitizedFileName( const base::FilePath& suggested_filename) { if (suggested_filename.empty()) - return base::FilePath(); + return {}; return net::GenerateFileName( GURL(), std::string(), std::string(), suggested_filename.AsUTF8Unsafe(), std::string(), l10n_util::GetStringUTF8(IDS_DEFAULT_DOWNLOAD_FILENAME)); diff --git a/shell/browser/osr/osr_render_widget_host_view.cc b/shell/browser/osr/osr_render_widget_host_view.cc index 8f339bdf0d84..dbddfe3e96d8 100644 --- a/shell/browser/osr/osr_render_widget_host_view.cc +++ b/shell/browser/osr/osr_render_widget_host_view.cc @@ -297,12 +297,12 @@ void OffScreenRenderWidgetHostView::SetBounds(const gfx::Rect& new_bounds) { } gfx::NativeView OffScreenRenderWidgetHostView::GetNativeView() { - return gfx::NativeView(); + return {}; } gfx::NativeViewAccessible OffScreenRenderWidgetHostView::GetNativeViewAccessible() { - return gfx::NativeViewAccessible(); + return {}; } ui::TextInputClient* OffScreenRenderWidgetHostView::GetTextInputClient() { diff --git a/shell/browser/osr/osr_web_contents_view.cc b/shell/browser/osr/osr_web_contents_view.cc index 08be98de2993..9a0cfe496fcb 100644 --- a/shell/browser/osr/osr_web_contents_view.cc +++ b/shell/browser/osr/osr_web_contents_view.cc @@ -74,19 +74,19 @@ gfx::Size OffScreenWebContentsView::GetSize() { #if !BUILDFLAG(IS_MAC) gfx::NativeView OffScreenWebContentsView::GetNativeView() const { if (!native_window_) - return gfx::NativeView(); + return {}; return native_window_->GetNativeView(); } gfx::NativeView OffScreenWebContentsView::GetContentNativeView() const { if (!native_window_) - return gfx::NativeView(); + return {}; return native_window_->GetNativeView(); } gfx::NativeWindow OffScreenWebContentsView::GetTopLevelNativeWindow() const { if (!native_window_) - return gfx::NativeWindow(); + return {}; return native_window_->GetNativeWindow(); } #endif diff --git a/shell/browser/ui/devtools_manager_delegate.cc b/shell/browser/ui/devtools_manager_delegate.cc index 2d4547aeca40..f90dc99e8dd2 100644 --- a/shell/browser/ui/devtools_manager_delegate.cc +++ b/shell/browser/ui/devtools_manager_delegate.cc @@ -50,13 +50,13 @@ class TCPServerSocketFactory : public content::DevToolsSocketFactory { auto socket = std::make_unique(nullptr, net::NetLogSource()); if (socket->ListenWithAddressAndPort(address_, port_, 10) != net::OK) - return std::unique_ptr(); + return {}; return socket; } std::unique_ptr CreateForTethering( std::string* name) override { - return std::unique_ptr(); + return {}; } std::string address_; diff --git a/shell/common/api/electron_api_url_loader.cc b/shell/common/api/electron_api_url_loader.cc index 4c13ad08db07..50bb530292db 100644 --- a/shell/common/api/electron_api_url_loader.cc +++ b/shell/common/api/electron_api_url_loader.cc @@ -529,14 +529,14 @@ gin::Handle SimpleURLLoaderWrapper::Create( gin_helper::Dictionary opts; if (!args->GetNext(&opts)) { args->ThrowTypeError("Expected a dictionary"); - return gin::Handle(); + return {}; } auto request = std::make_unique(); opts.Get("method", &request->method); opts.Get("url", &request->url); if (!request->url.is_valid()) { args->ThrowTypeError("Invalid URL"); - return gin::Handle(); + return {}; } request->site_for_cookies = net::SiteForCookies::FromUrl(request->url); opts.Get("referrer", &request->referrer); @@ -604,7 +604,7 @@ gin::Handle SimpleURLLoaderWrapper::Create( if (!net::HttpUtil::IsValidHeaderName(it.first) || !net::HttpUtil::IsValidHeaderValue(it.second)) { args->ThrowTypeError("Invalid header name or value"); - return gin::Handle(); + return {}; } request->headers.SetHeader(it.first, it.second); } diff --git a/shell/common/api/electron_api_v8_util.cc b/shell/common/api/electron_api_v8_util.cc index c02e33489706..4f3d8ec65497 100644 --- a/shell/common/api/electron_api_v8_util.cc +++ b/shell/common/api/electron_api_v8_util.cc @@ -49,10 +49,10 @@ v8::Local GetHiddenValue(v8::Isolate* isolate, v8::Local value; v8::Maybe result = object->HasPrivate(context, privateKey); if (!(result.IsJust() && result.FromJust())) - return v8::Local(); + return {}; if (object->GetPrivate(context, privateKey).ToLocal(&value)) return value; - return v8::Local(); + return {}; } void SetHiddenValue(v8::Isolate* isolate, diff --git a/shell/common/extensions/electron_extensions_api_provider.cc b/shell/common/extensions/electron_extensions_api_provider.cc index 101f789323ff..c284df61d6cc 100644 --- a/shell/common/extensions/electron_extensions_api_provider.cc +++ b/shell/common/extensions/electron_extensions_api_provider.cc @@ -49,7 +49,7 @@ base::span GetPermissionInfos() { return base::make_span(permissions_to_register); } base::span GetPermissionAliases() { - return base::span(); + return {}; } } // namespace diff --git a/shell/common/gin_helper/event_emitter_caller.h b/shell/common/gin_helper/event_emitter_caller.h index abb73758cfee..3859f0235975 100644 --- a/shell/common/gin_helper/event_emitter_caller.h +++ b/shell/common/gin_helper/event_emitter_caller.h @@ -64,7 +64,7 @@ v8::Local CallMethod(v8::Isolate* isolate, return scope.Escape(CustomEmit(isolate, v8_object, method_name, std::forward(args)...)); else - return v8::Local(); + return {}; } template diff --git a/shell/common/gin_helper/trackable_object.h b/shell/common/gin_helper/trackable_object.h index 3ee141e16f73..5fa9d963243e 100644 --- a/shell/common/gin_helper/trackable_object.h +++ b/shell/common/gin_helper/trackable_object.h @@ -102,7 +102,7 @@ class TrackableObject : public TrackableObjectBase, public EventEmitter { if (weak_map_) return weak_map_->Values(isolate); else - return std::vector>(); + return {}; } // Removes this instance from the weak map. diff --git a/shell/common/mac/codesign_util.cc b/shell/common/mac/codesign_util.cc index 455bfa5d02e5..3ad25421e689 100644 --- a/shell/common/mac/codesign_util.cc +++ b/shell/common/mac/codesign_util.cc @@ -25,7 +25,7 @@ std::optional IsUnsignedOrAdHocSigned(SecCodeRef code) { } if (status != errSecSuccess) { OSSTATUS_LOG(ERROR, status) << "SecCodeCopyStaticCode"; - return std::optional(); + return {}; } // Copy the signing info from the SecStaticCodeRef. base::apple::ScopedCFTypeRef signing_info; @@ -34,7 +34,7 @@ std::optional IsUnsignedOrAdHocSigned(SecCodeRef code) { signing_info.InitializeInto()); if (status != errSecSuccess) { OSSTATUS_LOG(ERROR, status) << "SecCodeCopySigningInformation"; - return std::optional(); + return {}; } // Look up the code signing flags. If the flags are absent treat this as // unsigned. This decision is consistent with the StaticCode source: @@ -51,7 +51,7 @@ std::optional IsUnsignedOrAdHocSigned(SecCodeRef code) { long long flags; if (!CFNumberGetValue(signing_info_flags, kCFNumberLongLongType, &flags)) { LOG(ERROR) << "CFNumberGetValue"; - return std::optional(); + return {}; } if (static_cast(flags) & kSecCodeSignatureAdhoc) { return true; diff --git a/shell/common/node_bindings.cc b/shell/common/node_bindings.cc index 1f5944a50cc7..918e51e7b5b6 100644 --- a/shell/common/node_bindings.cc +++ b/shell/common/node_bindings.cc @@ -189,7 +189,7 @@ v8::MaybeLocal HostImportModuleDynamically( v8::Local v8_import_assertions) { if (node::Environment::GetCurrent(context) == nullptr) { if (electron::IsBrowserProcess() || electron::IsUtilityProcess()) - return v8::MaybeLocal(); + return {}; return blink::V8Initializer::HostImportModuleDynamically( context, v8_host_defined_options, v8_referrer_resource_url, v8_specifier, v8_import_assertions); diff --git a/shell/renderer/api/electron_api_context_bridge.cc b/shell/renderer/api/electron_api_context_bridge.cc index 41f1db82799e..dd35c5b7840e 100644 --- a/shell/renderer/api/electron_api_context_bridge.cc +++ b/shell/renderer/api/electron_api_context_bridge.cc @@ -152,7 +152,7 @@ v8::MaybeLocal PassValueToOtherContext( "Electron contextBridge recursion depth exceeded. " "Nested objects " "deeper than 1000 are not supported."))); - return v8::MaybeLocal(); + return {}; } // Certain primitives always use the current contexts prototype and we can @@ -209,7 +209,7 @@ v8::MaybeLocal PassValueToOtherContext( if (!v8::Function::New(destination_context, ProxyFunctionWrapper, state) .ToLocal(&proxy_func)) - return v8::MaybeLocal(); + return {}; SetPrivate(destination_context, proxy_func.As(), context_bridge::kOriginalFunctionPrivateKey, func); object_cache->CacheProxiedObject(value, proxy_func); @@ -372,11 +372,11 @@ v8::MaybeLocal PassValueToOtherContext( arr->Get(source_context, i).ToLocalChecked(), value, object_cache, support_dynamic_properties, recursion_depth + 1, error_target); if (value_for_array.IsEmpty()) - return v8::MaybeLocal(); + return {}; if (!IsTrue(cloned_arr->Set(destination_context, static_cast(i), value_for_array.ToLocalChecked()))) { - return v8::MaybeLocal(); + return {}; } } object_cache->CacheProxiedObject(value, cloned_arr); @@ -408,7 +408,7 @@ v8::MaybeLocal PassValueToOtherContext( object_value, source_context, destination_context, object_cache, support_dynamic_properties, recursion_depth + 1, error_target); if (passed_value.IsEmpty()) - return v8::MaybeLocal(); + return {}; return v8::MaybeLocal(passed_value.ToLocalChecked()); } @@ -421,7 +421,7 @@ v8::MaybeLocal PassValueToOtherContext( v8::Context::Scope error_scope(error_context); // V8 serializer will throw an error if required if (!gin::ConvertFromV8(error_context->GetIsolate(), value, &ret)) { - return v8::MaybeLocal(); + return {}; } } @@ -651,7 +651,7 @@ v8::MaybeLocal CreateProxyForAPI( object_cache, support_dynamic_properties, recursion_depth + 1, error_target); if (passed_value.IsEmpty()) - return v8::MaybeLocal(); + return {}; proxy.Set(key, passed_value.ToLocalChecked()); } diff --git a/shell/renderer/api/electron_api_ipc_renderer.cc b/shell/renderer/api/electron_api_ipc_renderer.cc index a93fa6a3c645..29305a4d53c5 100644 --- a/shell/renderer/api/electron_api_ipc_renderer.cc +++ b/shell/renderer/api/electron_api_ipc_renderer.cc @@ -107,11 +107,11 @@ class IPCRenderer final : public gin::Wrappable, v8::Local arguments) { if (!electron_ipc_remote_) { thrower.ThrowError(kIPCMethodCalledAfterContextReleasedError); - return v8::Local(); + return {}; } blink::CloneableMessage message; if (!electron::SerializeV8Value(isolate, arguments, &message)) { - return v8::Local(); + return {}; } gin_helper::Promise p(isolate); auto handle = p.GetHandle(); @@ -189,11 +189,11 @@ class IPCRenderer final : public gin::Wrappable, v8::Local arguments) { if (!electron_ipc_remote_) { thrower.ThrowError(kIPCMethodCalledAfterContextReleasedError); - return v8::Local(); + return {}; } blink::CloneableMessage message; if (!electron::SerializeV8Value(isolate, arguments, &message)) { - return v8::Local(); + return {}; } blink::CloneableMessage result; diff --git a/shell/renderer/electron_api_service_impl.cc b/shell/renderer/electron_api_service_impl.cc index 1b48c4a9814a..7d66145783c0 100644 --- a/shell/renderer/electron_api_service_impl.cc +++ b/shell/renderer/electron_api_service_impl.cc @@ -44,7 +44,7 @@ v8::Local GetIpcObject(v8::Local context) { global_object->GetPrivate(context, private_binding_key).ToLocalChecked(); if (value.IsEmpty() || !value->IsObject()) { LOG(ERROR) << "Attempted to get the 'ipcNative' object but it was missing"; - return v8::Local(); + return {}; } return value->ToObject(context).ToLocalChecked(); } diff --git a/shell/renderer/electron_sandboxed_renderer_client.cc b/shell/renderer/electron_sandboxed_renderer_client.cc index 4d578f51ed6c..2ef6fff98bca 100644 --- a/shell/renderer/electron_sandboxed_renderer_client.cc +++ b/shell/renderer/electron_sandboxed_renderer_client.cc @@ -86,7 +86,7 @@ v8::Local CreatePreloadScript(v8::Isolate* isolate, auto maybe_script = v8::Script::Compile(context, source); v8::Local script; if (!maybe_script.ToLocal(&script)) - return v8::Local(); + return {}; return script->Run(context).ToLocalChecked(); } diff --git a/shell/renderer/renderer_client_base.cc b/shell/renderer/renderer_client_base.cc index 90fa35621118..87825b82e9c9 100644 --- a/shell/renderer/renderer_client_base.cc +++ b/shell/renderer/renderer_client_base.cc @@ -459,7 +459,7 @@ v8::Local RendererClientBase::GetScriptableObject( if (container_manager) return container_manager->GetScriptableObject(plugin_element, isolate); #endif - return v8::Local(); + return {}; } std::unique_ptr