refactor: unfilter unresponsive events (#44629)
* feat: internal -unresponsive event
* Reland "refactor: JSify BrowserWindow unresponsive handling"
This reverts commit ef7ae78ed4
.
* fix: emit unresponsive if close not prevented
---------
Co-authored-by: Keeley Hammond <vertedinde@electronjs.org>
This commit is contained in:
parent
946ab5f1d7
commit
41b5d7e312
7 changed files with 103 additions and 60 deletions
|
@ -43,6 +43,7 @@
|
|||
#include "content/browser/renderer_host/render_frame_host_manager.h" // nogncheck
|
||||
#include "content/browser/renderer_host/render_widget_host_impl.h" // nogncheck
|
||||
#include "content/browser/renderer_host/render_widget_host_view_base.h" // nogncheck
|
||||
#include "content/browser/web_contents/web_contents_impl.h" // nogncheck
|
||||
#include "content/public/browser/child_process_security_policy.h"
|
||||
#include "content/public/browser/context_menu_params.h"
|
||||
#include "content/public/browser/desktop_media_id.h"
|
||||
|
@ -62,6 +63,7 @@
|
|||
#include "content/public/browser/service_worker_context.h"
|
||||
#include "content/public/browser/site_instance.h"
|
||||
#include "content/public/browser/storage_partition.h"
|
||||
#include "content/public/browser/visibility.h"
|
||||
#include "content/public/browser/web_contents.h"
|
||||
#include "content/public/common/referrer_type_converters.h"
|
||||
#include "content/public/common/result_codes.h"
|
||||
|
@ -1436,7 +1438,25 @@ void WebContents::RendererUnresponsive(
|
|||
content::WebContents* source,
|
||||
content::RenderWidgetHost* render_widget_host,
|
||||
base::RepeatingClosure hang_monitor_restarter) {
|
||||
Emit("unresponsive");
|
||||
v8::Isolate* isolate = JavascriptEnvironment::GetIsolate();
|
||||
v8::HandleScope handle_scope(isolate);
|
||||
gin::Handle<gin_helper::internal::Event> event =
|
||||
gin_helper::internal::Event::New(isolate);
|
||||
v8::Local<v8::Object> event_object = event.ToV8().As<v8::Object>();
|
||||
gin::Dictionary dict(isolate, event_object);
|
||||
|
||||
auto* web_contents_impl = static_cast<content::WebContentsImpl*>(source);
|
||||
bool should_ignore = web_contents_impl->ShouldIgnoreUnresponsiveRenderer();
|
||||
dict.Set("shouldIgnore", should_ignore);
|
||||
|
||||
bool visible = source->GetVisibility() == content::Visibility::VISIBLE;
|
||||
dict.Set("visible", visible);
|
||||
|
||||
auto* rwh_impl =
|
||||
static_cast<content::RenderWidgetHostImpl*>(render_widget_host);
|
||||
dict.Set("rendererInitialized", rwh_impl->renderer_initialized());
|
||||
|
||||
EmitWithoutEvent("-unresponsive", event);
|
||||
}
|
||||
|
||||
void WebContents::RendererResponsive(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue