feat: expose audio-state-changed on webContents (#37366)

feat: expose audio-state-changed on webContents
This commit is contained in:
Shelley Vohr 2023-03-06 17:00:24 +01:00 committed by GitHub
parent c8f715f9a1
commit 512e56baf7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 3 deletions

View file

@ -1507,7 +1507,14 @@ content::JavaScriptDialogManager* WebContents::GetJavaScriptDialogManager(
}
void WebContents::OnAudioStateChanged(bool audible) {
Emit("-audio-state-changed", audible);
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);
dict.Set("audible", audible);
EmitWithoutEvent("audio-state-changed", event);
}
void WebContents::BeforeUnloadFired(bool proceed,