Commit 7146c8fa authored by Ahmed Mehfooz's avatar Ahmed Mehfooz Committed by Commit Bot

Fix Chrome vox crashes

Initializing the system tray and message center with chrome
vox enabled causes a crash when the tray event filter references
the message center bubble before it's constructor is fully
executed.
This fix ensures this doesn't happen by separating the constructor
from the part of the code which shows the bubble.

Change-Id: I297bf5212fb82a3372081dc418c25473f22d5cd5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1881689
Commit-Queue: Ahmed Mehfooz <amehfooz@chromium.org>
Reviewed-by: default avatarTim Song <tengs@chromium.org>
Cr-Commit-Position: refs/heads/master@{#710585}
parent 17c30a6b
......@@ -88,15 +88,15 @@ UnifiedMessageCenterBubble::UnifiedMessageCenterBubble(UnifiedSystemTray* tray)
message_center_view_->SetCollapsed(false /*animate*/);
message_center_view_->AddObserver(this);
}
void UnifiedMessageCenterBubble::ShowBubble() {
bubble_widget_ = views::BubbleDialogDelegateView::CreateBubble(bubble_view_);
bubble_widget_->AddObserver(this);
TrayBackgroundView::InitializeBubbleAnimations(bubble_widget_);
bubble_view_->InitializeAndShowBubble();
tray->tray_event_filter()->AddBubble(this);
tray->bubble()->unified_view()->AddObserver(this);
tray_->tray_event_filter()->AddBubble(this);
tray_->bubble()->unified_view()->AddObserver(this);
ui::Layer* widget_layer = bubble_widget_->GetLayer();
int radius = kUnifiedTrayCornerRadius;
......@@ -104,6 +104,8 @@ UnifiedMessageCenterBubble::UnifiedMessageCenterBubble(UnifiedSystemTray* tray)
widget_layer->SetIsFastRoundedCorner(true);
widget_layer->Add(border_->layer());
bubble_view_->InitializeAndShowBubble();
UpdatePosition();
}
......@@ -168,7 +170,7 @@ void UnifiedMessageCenterBubble::FocusFirstNotification() {
}
bool UnifiedMessageCenterBubble::IsMessageCenterVisible() {
return message_center_view_->GetVisible();
return !!bubble_widget_ && message_center_view_->GetVisible();
}
TrayBackgroundView* UnifiedMessageCenterBubble::GetTray() const {
......
......@@ -28,6 +28,12 @@ class ASH_EXPORT UnifiedMessageCenterBubble : public TrayBubbleBase,
explicit UnifiedMessageCenterBubble(UnifiedSystemTray* tray);
~UnifiedMessageCenterBubble() override;
// We need the code to show the bubble explicitly separated from the
// contructor. This is to prevent trigerring the TrayEventFilter from within
// the constructor. Doing so can cause a crash when the TrayEventFilter tries
// to reference the message center bubble before it is fully instantiated.
void ShowBubble();
// Calculate the height usable for the bubble.
int CalculateAvailableHeight();
......
......@@ -391,8 +391,11 @@ void UnifiedSystemTray::ShowBubbleInternal(bool show_by_click) {
bubble_ = std::make_unique<UnifiedSystemTrayBubble>(this, show_by_click);
if (features::IsUnifiedMessageCenterRefactorEnabled())
if (features::IsUnifiedMessageCenterRefactorEnabled()) {
message_center_bubble_ = std::make_unique<UnifiedMessageCenterBubble>(this);
message_center_bubble_->ShowBubble();
FocusQuickSettings(false /*reverse*/);
}
SetIsActive(true);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment