Commit 5919cc41 authored by Kurt Horimoto's avatar Kurt Horimoto Committed by Commit Bot

[iOS] Early return when cancelling UI that hasn't been presented.

OverlayPresentationContext::CancelOverlayUI() has no guarantees that the
UI being cancelled has been requested yet.  For example, the referenced
crash occurs when cancelling a queued request whose UI has never been
shown.  The previous code assumed that CancelOverlayUI() was only ever
called for OverlayRequests for which ShowOverlayUI() has been called
previously.  This CL updates the logic to early return if it's called
for requests that haven't been passed to ShowOverlayUI().

Bug: 991614
Change-Id: I63532e13a32c10498901ae9b70082ded1b348c16
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1762354
Commit-Queue: Kurt Horimoto <kkhorimoto@chromium.org>
Auto-Submit: Kurt Horimoto <kkhorimoto@chromium.org>
Reviewed-by: default avatarSergio Collazos <sczs@chromium.org>
Cr-Commit-Position: refs/heads/master@{#688671}
parent c203649b
...@@ -133,10 +133,16 @@ void OverlayPresentationContextImpl::CancelOverlayUI( ...@@ -133,10 +133,16 @@ void OverlayPresentationContextImpl::CancelOverlayUI(
OverlayPresenter* presenter, OverlayPresenter* presenter,
OverlayRequest* request) { OverlayRequest* request) {
DCHECK_EQ(presenter_, presenter); DCHECK_EQ(presenter_, presenter);
// No cleanup required if there is no UI state for |request|. This can
// occur when cancelling an OverlayRequest whose UI has never been
// presented.
OverlayRequestUIState* state = GetRequestUIState(request);
if (!state)
return;
// If the coordinator is not presenting the overlay UI for |state|, it can // If the coordinator is not presenting the overlay UI for |state|, it can
// be deleted immediately. // be deleted immediately.
OverlayRequestUIState* state = GetRequestUIState(request);
DCHECK(state);
if (!state->has_callback()) { if (!state->has_callback()) {
states_.erase(request); states_.erase(request);
return; return;
......
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