Compare commits

...

3 Commits

6 changed files with 30 additions and 13 deletions

View File

@@ -586,6 +586,7 @@ filenames = {
"shell/common/electron_command_line.h",
"shell/common/electron_constants.h",
"shell/common/electron_paths.h",
"shell/common/gin_adapters.h",
"shell/common/gin_converters/accelerator_converter.cc",
"shell/common/gin_converters/accelerator_converter.h",
"shell/common/gin_converters/base_converter.h",

View File

@@ -728,17 +728,16 @@ void App::AllowCertificateError(
bool is_main_frame_request,
bool strict_enforcement,
base::OnceCallback<void(content::CertificateRequestResultType)> callback) {
auto adapted_callback = base::AdaptCallbackForRepeating(std::move(callback));
v8::Isolate* isolate = JavascriptEnvironment::GetIsolate();
v8::HandleScope handle_scope(isolate);
bool prevent_default = Emit(
"certificate-error", WebContents::FromOrCreate(isolate, web_contents),
request_url, net::ErrorToString(cert_error), ssl_info.cert,
adapted_callback, is_main_frame_request);
std::move(callback), is_main_frame_request);
// Deny the certificate by default.
if (!prevent_default)
adapted_callback.Run(content::CERTIFICATE_REQUEST_RESULT_TYPE_DENY);
std::move(callback).Run(content::CERTIFICATE_REQUEST_RESULT_TYPE_DENY);
}
base::OnceClosure App::SelectClientCertificate(

View File

@@ -438,7 +438,7 @@ void SimpleURLLoaderWrapper::OnAuthRequired(
net::AuthCredentials(username_str, password_str));
},
std::move(auth_responder));
Emit("login", auth_info, base::AdaptCallbackForRepeating(std::move(cb)));
Emit("login", auth_info, std::move(cb));
}
void SimpleURLLoaderWrapper::OnSSLCertificateError(
@@ -716,8 +716,7 @@ void SimpleURLLoaderWrapper::OnDataReceived(std::string_view string_view,
v8::HandleScope handle_scope(isolate);
auto array_buffer = v8::ArrayBuffer::New(isolate, string_view.size());
memcpy(array_buffer->Data(), string_view.data(), string_view.size());
Emit("data", array_buffer,
base::AdaptCallbackForRepeating(std::move(resume)));
Emit("data", array_buffer, std::move(resume));
}
void SimpleURLLoaderWrapper::OnComplete(bool success) {

View File

@@ -0,0 +1,23 @@
// Copyright (c) 2025 Microsoft, Inc.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#ifndef ELECTRON_SHELL_COMMON_GIN_ADAPTERS_H_
#define ELECTRON_SHELL_COMMON_GIN_ADAPTERS_H_
#include <utility>
#include "gin/converter.h"
namespace gin {
// Make it possible to convert move-only types.
template <typename T>
v8::Local<v8::Value> ConvertToV8(v8::Isolate* isolate, T&& input) {
return Converter<typename std::remove_reference<T>::type>::ToV8(
isolate, std::forward<T>(input));
}
} // namespace gin
#endif // ELECTRON_SHELL_COMMON_GIN_ADAPTERS_H_

View File

@@ -13,6 +13,7 @@
#include <utility>
#include "gin/converter.h"
#include "shell/common/gin_adapters.h"
#include "base/strings/string_util.h"
#if BUILDFLAG(IS_WIN)
@@ -21,13 +22,6 @@
namespace gin {
// Make it possible to convert move-only types.
template <typename T>
v8::Local<v8::Value> ConvertToV8(v8::Isolate* isolate, T&& input) {
return Converter<typename std::remove_reference<T>::type>::ToV8(
isolate, std::forward<T>(input));
}
#if !BUILDFLAG(IS_LINUX)
template <>
struct Converter<unsigned long> { // NOLINT(runtime/int)

View File

@@ -11,6 +11,7 @@
#include "base/containers/span.h"
#include "gin/converter.h"
#include "gin/wrappable.h"
#include "shell/common/gin_adapters.h"
namespace gin_helper {