Chromium Code Reviews| Index: ash/system/tray/system_tray_bubble.cc |
| diff --git a/ash/system/tray/system_tray_bubble.cc b/ash/system/tray/system_tray_bubble.cc |
| index bf94470ed85f0c75f6784d3d8513fc6c2e1cc0de..1ce36dda600627862e86224a982f58a53fcee498 100644 |
| --- a/ash/system/tray/system_tray_bubble.cc |
| +++ b/ash/system/tray/system_tray_bubble.cc |
| @@ -68,6 +68,26 @@ class AnimationObserverDeleteLayer : public ui::ImplicitAnimationObserver { |
| } // namespace |
| +// CloseBubbleObserver is used to delay closing the system tray bubble until the |
| +// animation completes. |
|
tdanderson
2017/06/19 16:19:38
When I build and try out this CL locally, I run in
minch1
2017/06/20 16:45:34
This is because tap elsewhere will dismiss the men
tdanderson
2017/06/20 22:42:20
Thanks, I do not see this crash locally with Patch
|
| +class CloseBubbleObserver : public ui::ImplicitAnimationObserver { |
| + public: |
| + explicit CloseBubbleObserver(SystemTrayBubble* system_tray_bubble) |
| + : system_tray_bubble_(system_tray_bubble) {} |
| + |
| + ~CloseBubbleObserver() override {} |
| + |
| + void OnImplicitAnimationsCompleted() override { |
| + system_tray_bubble_->Close(); |
| + delete this; |
| + } |
| + |
| + private: |
| + SystemTrayBubble* system_tray_bubble_ = nullptr; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(CloseBubbleObserver); |
| +}; |
| + |
| // SystemTrayBubble |
| SystemTrayBubble::SystemTrayBubble( |
| @@ -85,6 +105,8 @@ SystemTrayBubble::~SystemTrayBubble() { |
| // Reset the host pointer in bubble_view_ in case its destruction is deferred. |
| if (bubble_view_) |
| bubble_view_->reset_delegate(); |
| + if (clipping_window_) |
|
tdanderson
2017/06/19 16:19:38
Have you considered making |clipping_window_| a un
minch1
2017/06/20 16:45:34
Done.
|
| + delete clipping_window_; |
| } |
| void SystemTrayBubble::UpdateView( |
| @@ -197,8 +219,24 @@ void SystemTrayBubble::InitView(views::View* anchor, |
| } |
| init_params->delegate = tray_; |
| - // Place the bubble on same display as this system tray. |
| - init_params->parent_window = tray_->GetBubbleWindowContainer(); |
| + // Place the bubble on same display as this system tray if it is not on |
| + // maximize mode. Otherwise, create an clipping window to hold the system |
| + // bubble. And place the clipping window on the same display as the system |
| + // tray. |
| + if (tray_->in_maximize_mode()) { |
| + if (!clipping_window_) { |
| + clipping_window_ = new aura::Window(nullptr); |
| + clipping_window_->Init(ui::LAYER_NOT_DRAWN); |
| + clipping_window_->layer()->SetMasksToBounds(true); |
| + tray_->GetBubbleWindowContainer()->AddChild(clipping_window_); |
| + clipping_window_->Show(); |
| + } |
| + clipping_window_->SetBounds(tray_->GetWorkAreaBoundsInScreen()); |
| + init_params->parent_window = clipping_window_; |
| + } else { |
| + init_params->parent_window = tray_->GetBubbleWindowContainer(); |
| + } |
| + |
| init_params->anchor_view = anchor; |
| bubble_view_ = new TrayBubbleView(*init_params); |
| UpdateBottomPadding(); |
| @@ -298,6 +336,22 @@ void SystemTrayBubble::RecordVisibleRowMetrics() { |
| } |
| } |
| +void SystemTrayBubble::UpdateBounds(const gfx::Rect& target_bounds, |
| + bool close_bubble) { |
| + const int kAnimationDurationMS = 200; |
| + |
| + ui::ScopedLayerAnimationSettings settings( |
| + bubble_view()->GetWidget()->GetNativeView()->layer()->GetAnimator()); |
| + settings.SetTransitionDuration( |
| + base::TimeDelta::FromMilliseconds(kAnimationDurationMS)); |
| + settings.SetTweenType(gfx::Tween::EASE_OUT); |
| + settings.SetPreemptionStrategy( |
| + ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); |
| + if (close_bubble) |
| + settings.AddObserver(new CloseBubbleObserver(this)); |
| + bubble_view()->GetWidget()->SetBounds(target_bounds); |
| +} |
| + |
| void SystemTrayBubble::UpdateBottomPadding() { |
| if (bubble_type_ == BUBBLE_TYPE_DEFAULT) |
| bubble_view_->SetBottomPadding(kDefaultViewBottomPadding); |