Browse Source

feat: add isMainFrame argument to 'certificate-error' event (#30879)

Milan Burda 3 years ago
parent
commit
92bff00d43
3 changed files with 6 additions and 4 deletions
  1. 1 0
      docs/api/app.md
  2. 1 0
      docs/api/web-contents.md
  3. 4 4
      shell/browser/api/electron_api_app.cc

+ 1 - 0
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

+ 1 - 0
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`.
 

+ 4 - 4
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)