Commit d81f46e7 authored by Kurt Horimoto's avatar Kurt Horimoto Committed by Commit Bot

[iOS] Fix OverlayPresentationContext::IsShowingOverlayUI()

The previous implementation returned whether or not the active request
was set to a non-null value.  However, this is not always correct
because there is a brief period between the overlay UI's dismissal
and the resetting of OverlayPresentationContextImpl state during which
the request is non-null, but its overlay UI is dismissed.

This caused breakage for queued OverlayRequests, as OverlayPresenterImpl
only attempted to present UI for a subsequent request if the context
returned false from this function.  Since the context reported that it
was still showing overlay UI, the next request was not presented and
the context cleaned its state up by resetting its presentation
capabilities to kNone.  If the prior request required UIViewController
presentation, this resulted in the dismissal of the presentation
context view controller.  When the OverlayPresenterImpl is notified of
the updated kNone presentation capabilities, it then attempted to
present the next request.  If the next request also required
UIViewController presentation, this attempted to re-present the
presentation context view controller and this presentation would no-
op since the previous view controller was not finished being dismissed.

This CL updates IsShowingOverlayUI() to return false if the dismissal
callback for the active request has already been executed, which
prevents the early return in OverlayPresenterImpl's
PresentOverlayForActiveRequest().

As an implementation detail, this CL updates GetRequestUIState() to
use const std::map APIs so that it can be called from
IsShowingOverlayUI(), which is also const.

Bug: none
Change-Id: Id3b519f6129838f78d3fdcf0d65436ee4bf74cc9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2159689Reviewed-by: default avatarChris Lu <thegreenfrog@chromium.org>
Commit-Queue: Chris Lu <thegreenfrog@chromium.org>
Auto-Submit: Kurt Horimoto <kkhorimoto@chromium.org>
Cr-Commit-Position: refs/heads/master@{#761129}
parent 4ea80191
......@@ -116,7 +116,7 @@ class OverlayPresentationContextImpl : public OverlayPresentationContext {
UIViewController* GetBaseViewController(OverlayRequest* request) const;
// Returns the UI state for |request|.
OverlayRequestUIState* GetRequestUIState(OverlayRequest* request);
OverlayRequestUIState* GetRequestUIState(OverlayRequest* request) const;
// Returns the presentation capabilities required to show |request|.
UIPresentationCapabilities GetRequiredPresentationCapabilities(
......
......@@ -158,7 +158,10 @@ bool OverlayPresentationContextImpl::CanShowUIForRequest(
}
bool OverlayPresentationContextImpl::IsShowingOverlayUI() const {
return !!request_;
// The UI for the active request is visible until its dismissal callback has
// been executed.
OverlayRequestUIState* state = GetRequestUIState(request_);
return state && state->has_callback();
}
void OverlayPresentationContextImpl::PrepareToShowOverlayUI(
......@@ -270,8 +273,10 @@ UIViewController* OverlayPresentationContextImpl::GetBaseViewController(
}
OverlayRequestUIState* OverlayPresentationContextImpl::GetRequestUIState(
OverlayRequest* request) {
return request ? states_[request].get() : nullptr;
OverlayRequest* request) const {
if (!request || states_.find(request) == states_.end())
return nullptr;
return states_.at(request).get();
}
OverlayPresentationContext::UIPresentationCapabilities
......
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