From 2f59f80f93f5abe094d37fc179dab441b64f0bd5 Mon Sep 17 00:00:00 2001 From: Milan Burda Date: Wed, 8 Sep 2021 04:38:41 +0200 Subject: [PATCH] feat: add isMainFrame argument to 'certificate-error' event --- 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 a017c2e86e12b..14615242893b3 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 040e5746e889d..292266a53c515 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 9516d571f438b..6c94aa0a7caed 100644 --- a/shell/browser/api/electron_api_app.cc +++ b/shell/browser/api/electron_api_app.cc @@ -815,10 +815,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)