Commit ebf0b895 authored by Lloyd Pique's avatar Lloyd Pique Committed by Chromium LUCI CQ

ARC Overlays: Ensure overlay is closed

The overlay window should be closed if the host window is closed, or if
the controller is destroyed.

BUG=crbug:1156540
TEST=Close Test app while overlay is displayed

Change-Id: I7d0dadc697535694952bc9be02c88d4c7a28977a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2582816
Commit-Queue: Lloyd Pique <lpique@chromium.org>
Reviewed-by: default avatarMitsuru Oshima <oshima@chromium.org>
Cr-Commit-Position: refs/heads/master@{#835791}
parent 80e97405
...@@ -29,7 +29,9 @@ ArcOverlayControllerImpl::ArcOverlayControllerImpl(aura::Window* host_window) ...@@ -29,7 +29,9 @@ ArcOverlayControllerImpl::ArcOverlayControllerImpl(aura::Window* host_window)
widget->GetContentsView()->AddChildView(overlay_container_); widget->GetContentsView()->AddChildView(overlay_container_);
} }
ArcOverlayControllerImpl::~ArcOverlayControllerImpl() = default; ArcOverlayControllerImpl::~ArcOverlayControllerImpl() {
EnsureOverlayWindowClosed();
}
void ArcOverlayControllerImpl::AttachOverlay(aura::Window* overlay_window) { void ArcOverlayControllerImpl::AttachOverlay(aura::Window* overlay_window) {
if (!overlay_container_ || !host_window_) if (!overlay_container_ || !host_window_)
...@@ -56,6 +58,8 @@ void ArcOverlayControllerImpl::OnWindowDestroying(aura::Window* window) { ...@@ -56,6 +58,8 @@ void ArcOverlayControllerImpl::OnWindowDestroying(aura::Window* window) {
if (host_window_observer_.IsObservingSource(window)) { if (host_window_observer_.IsObservingSource(window)) {
host_window_ = nullptr; host_window_ = nullptr;
host_window_observer_.Reset(); host_window_observer_.Reset();
EnsureOverlayWindowClosed();
} }
if (overlay_window_observer_.IsObservingSource(window)) { if (overlay_window_observer_.IsObservingSource(window)) {
overlay_window_ = nullptr; overlay_window_ = nullptr;
...@@ -101,4 +105,14 @@ void ArcOverlayControllerImpl::ConvertPointFromWindow(aura::Window* window, ...@@ -101,4 +105,14 @@ void ArcOverlayControllerImpl::ConvertPointFromWindow(aura::Window* window,
views::View::ConvertPointFromWidget(widget->GetContentsView(), point); views::View::ConvertPointFromWidget(widget->GetContentsView(), point);
} }
void ArcOverlayControllerImpl::EnsureOverlayWindowClosed() {
// Ensure the overlay window is closed.
if (overlay_window_observer_.IsObserving()) {
VLOG(1) << "Forcing-closing overlay " << overlay_window_->GetName();
auto* const widget =
views::Widget::GetWidgetForNativeWindow(overlay_window_);
widget->CloseWithReason(views::Widget::ClosedReason::kUnspecified);
}
}
} // namespace ash } // namespace ash
...@@ -51,6 +51,7 @@ class ASH_PUBLIC_EXPORT ArcOverlayControllerImpl : public ArcOverlayController, ...@@ -51,6 +51,7 @@ class ASH_PUBLIC_EXPORT ArcOverlayControllerImpl : public ArcOverlayController,
private: private:
void UpdateHostBounds(); void UpdateHostBounds();
void ConvertPointFromWindow(aura::Window* window, gfx::Point* point); void ConvertPointFromWindow(aura::Window* window, gfx::Point* point);
void EnsureOverlayWindowClosed();
aura::Window* host_window_ = nullptr; aura::Window* host_window_ = nullptr;
base::ScopedObservation<aura::Window, aura::WindowObserver> base::ScopedObservation<aura::Window, aura::WindowObserver>
......
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