fix: crash on window.close() with webContents on blur (#47952)

fix: crash on window.close with WebContentsView on blur

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
This commit is contained in:
trop[bot] 2025-08-04 14:28:35 +02:00 committed by GitHub
commit 4fea51017f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 34 additions and 8 deletions

View file

@ -2747,15 +2747,17 @@ void WebContents::CloseDevTools() {
if (type_ == Type::kRemote)
return;
DCHECK(inspectable_web_contents_);
inspectable_web_contents_->CloseDevTools();
if (inspectable_web_contents_)
inspectable_web_contents_->CloseDevTools();
}
bool WebContents::IsDevToolsOpened() {
if (type_ == Type::kRemote)
return false;
DCHECK(inspectable_web_contents_);
if (!inspectable_web_contents_)
return false;
return inspectable_web_contents_->IsDevToolsViewShowing();
}
@ -2763,19 +2765,24 @@ std::u16string WebContents::GetDevToolsTitle() {
if (type_ == Type::kRemote)
return {};
DCHECK(inspectable_web_contents_);
if (!inspectable_web_contents_)
return {};
return inspectable_web_contents_->GetDevToolsTitle();
}
void WebContents::SetDevToolsTitle(const std::u16string& title) {
inspectable_web_contents_->SetDevToolsTitle(title);
if (inspectable_web_contents_)
inspectable_web_contents_->SetDevToolsTitle(title);
}
bool WebContents::IsDevToolsFocused() {
if (type_ == Type::kRemote)
return false;
DCHECK(inspectable_web_contents_);
if (!inspectable_web_contents_)
return false;
return inspectable_web_contents_->GetView()->IsDevToolsViewFocused();
}
@ -2823,10 +2830,9 @@ void WebContents::InspectElement(int x, int y) {
if (type_ == Type::kRemote)
return;
if (!enable_devtools_)
if (!enable_devtools_ || !inspectable_web_contents_)
return;
DCHECK(inspectable_web_contents_);
if (!inspectable_web_contents_->GetDevToolsWebContents())
OpenDevTools(nullptr);
inspectable_web_contents_->InspectElement(x, y);