From 92bff00d4341c0e41ca301f8f1033090a5bad81b Mon Sep 17 00:00:00 2001 From: Milan Burda Date: Tue, 21 Sep 2021 08:49:15 +0200 Subject: [PATCH] feat: add isMainFrame argument to 'certificate-error' event (#30879) --- docs/api/app.md | 1 + docs/api/web-contents.md | 1 + shell/browser/api/electron_api_app.cc | 8 ++++---- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/docs/api/app.md b/docs/api/app.md index a017c2e86e12..14615242893b 100755 --- a/docs/api/app.md +++ b/docs/api/app.md @@ -277,6 +277,7 @@ Returns: * `certificate` [Certificate](structures/certificate.md) * `callback` Function * `isTrusted` Boolean - Whether to consider the certificate as trusted +* `isMainFrame` Boolean Emitted when failed to verify the `certificate` for `url`, to trust the certificate you should prevent the default behavior with diff --git a/docs/api/web-contents.md b/docs/api/web-contents.md index 040e5746e889..292266a53c51 100644 --- a/docs/api/web-contents.md +++ b/docs/api/web-contents.md @@ -530,6 +530,7 @@ Returns: * `certificate` [Certificate](structures/certificate.md) * `callback` Function * `isTrusted` Boolean - Indicates whether the certificate can be considered trusted. +* `isMainFrame` Boolean Emitted when failed to verify the `certificate` for `url`. diff --git a/shell/browser/api/electron_api_app.cc b/shell/browser/api/electron_api_app.cc index 019a99e0f229..515888d71b63 100644 --- a/shell/browser/api/electron_api_app.cc +++ b/shell/browser/api/electron_api_app.cc @@ -817,10 +817,10 @@ void App::AllowCertificateError( v8::Isolate* isolate = JavascriptEnvironment::GetIsolate(); v8::Locker locker(isolate); 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); + 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); // Deny the certificate by default. if (!prevent_default)