osr: linux: Fix crash with default JS modal dialogs (fixes #3921)

This commit is contained in:
Marshall Greenblatt
2025-05-07 16:00:42 -04:00
parent ad4fa9cf24
commit 9051920b44
2 changed files with 22 additions and 2 deletions

View File

@ -57,10 +57,27 @@ index 8c06a19a64e5d..2b9429f7b2bab 100644
}
diff --git chrome/browser/ui/views/javascript_tab_modal_dialog_view_views.cc chrome/browser/ui/views/javascript_tab_modal_dialog_view_views.cc
index e0c7c6df6f415..171f042d712e4 100644
index e0c7c6df6f415..106cf8d8b998a 100644
--- chrome/browser/ui/views/javascript_tab_modal_dialog_view_views.cc
+++ chrome/browser/ui/views/javascript_tab_modal_dialog_view_views.cc
@@ -79,10 +79,13 @@ JavaScriptTabModalDialogViewViews::JavaScriptTabModalDialogViewViews(
@@ -49,9 +49,13 @@ views::View* JavaScriptTabModalDialogViewViews::GetInitiallyFocusedView() {
}
void JavaScriptTabModalDialogViewViews::AddedToWidget() {
- auto* bubble_frame_view = static_cast<views::BubbleFrameView*>(
- GetWidget()->non_client_view()->frame_view());
- bubble_frame_view->SetTitleView(CreateTitleOriginLabel(GetWindowTitle()));
+ auto* frame_view = GetWidget()->non_client_view()->frame_view();
+ // With CEF OSR this may be a NativeFrameView, in which case HasWindowTitle()
+ // will return false.
+ if (frame_view->HasWindowTitle()) {
+ auto* bubble_frame_view = static_cast<views::BubbleFrameView*>(frame_view);
+ bubble_frame_view->SetTitleView(CreateTitleOriginLabel(GetWindowTitle()));
+ }
if (!message_text_.empty()) {
GetWidget()->GetRootView()->GetViewAccessibility().SetDescription(
message_text_);
@@ -79,10 +83,13 @@ JavaScriptTabModalDialogViewViews::JavaScriptTabModalDialogViewViews(
default_prompt_text_(default_prompt_text),
dialog_callback_(std::move(dialog_callback)),
dialog_force_closed_callback_(std::move(dialog_force_closed_callback)) {