Commit 21e48f37 authored by Kurt Horimoto's avatar Kurt Horimoto Committed by Commit Bot

[iOS] Remove coordinator checks from OverlayPresentationContextImpl

After crrev.com/c/1787562, OverlayPresenter will only present upon the
presentation context when its presentation capabilities are sufficient
to support the current request.  Before that CL, OverlayPresenterImpl
simply used the presence of a non-null presentation context  as a signal
for when presentation was possible, and would call ShowOverlayUI() on
that context even if it was not yet provided with a coordinator capable
of showing that request's UI.  OverlayPresentationContextImpl simulated
the presentation flow for requests sent by OverlayPresenter when the
backing coordinator was null.  After crrev.com/c/1787562, these
condition blocks can be replaced with DCHECKs since the overlay UI
presentating/cancelling/hiding functionality will not be called for
unsupported requests.

Bug: none
Change-Id: Ia3bed1ffbf771f1b0deb0d17a81662111fec79c7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2056206
Commit-Queue: Kurt Horimoto <kkhorimoto@chromium.org>
Reviewed-by: default avatarMike Dougherty <michaeldo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#741642}
parent ffe0b51d
...@@ -53,6 +53,7 @@ class OverlayPresentationContext { ...@@ -53,6 +53,7 @@ class OverlayPresentationContext {
// |presentation_callback| must be called when the UI is finished being // |presentation_callback| must be called when the UI is finished being
// presented. |dismissal_callback| must be stored and called whenever the UI // presented. |dismissal_callback| must be stored and called whenever the UI
// is finished being dismissed for user interaction, hiding, or cancellation. // is finished being dismissed for user interaction, hiding, or cancellation.
// Must only be called when CanShowUIForRequest() returns true for |request|.
virtual void ShowOverlayUI(OverlayPresenter* presenter, virtual void ShowOverlayUI(OverlayPresenter* presenter,
OverlayRequest* request, OverlayRequest* request,
OverlayPresentationCallback presentation_callback, OverlayPresentationCallback presentation_callback,
...@@ -63,6 +64,7 @@ class OverlayPresentationContext { ...@@ -63,6 +64,7 @@ class OverlayPresentationContext {
// serialized so that the state can be restored if shown again. When hiding // serialized so that the state can be restored if shown again. When hiding
// an overlay, the presented UI must be dismissed, and the overlay's // an overlay, the presented UI must be dismissed, and the overlay's
// dismissal callback must must be executed upon the dismissal's completion. // dismissal callback must must be executed upon the dismissal's completion.
// Must only be called when |request| is displayed within the context.
virtual void HideOverlayUI(OverlayPresenter* presenter, virtual void HideOverlayUI(OverlayPresenter* presenter,
OverlayRequest* request) = 0; OverlayRequest* request) = 0;
......
...@@ -129,19 +129,14 @@ void OverlayPresentationContextImpl::HideOverlayUI(OverlayPresenter* presenter, ...@@ -129,19 +129,14 @@ void OverlayPresentationContextImpl::HideOverlayUI(OverlayPresenter* presenter,
OverlayRequest* request) { OverlayRequest* request) {
DCHECK_EQ(presenter_, presenter); DCHECK_EQ(presenter_, presenter);
DCHECK_EQ(request_, request); DCHECK_EQ(request_, request);
DCHECK(CanShowUIForRequest(request));
OverlayRequestUIState* state = GetRequestUIState(request_); OverlayRequestUIState* state = GetRequestUIState(request_);
DCHECK(state->has_callback()); DCHECK(state->has_callback());
if (coordinator_) { // Hide the overlay UI. The presented request will be reset when the
// If the request's UI is presented by the coordinator, dismiss it. The // dismissal animation finishes.
// presented request will be reset when the dismissal animation finishes. DismissPresentedUI(OverlayDismissalReason::kHiding);
DismissPresentedUI(OverlayDismissalReason::kHiding);
} else {
// Simulate dismissal if there is no container coordinator.
state->set_dismissal_reason(OverlayDismissalReason::kHiding);
OverlayUIWasDismissed();
}
} }
void OverlayPresentationContextImpl::CancelOverlayUI( void OverlayPresentationContextImpl::CancelOverlayUI(
...@@ -163,15 +158,7 @@ void OverlayPresentationContextImpl::CancelOverlayUI( ...@@ -163,15 +158,7 @@ void OverlayPresentationContextImpl::CancelOverlayUI(
return; return;
} }
// If the current request is being cancelled (e.g. for WebState closures) when DCHECK(CanShowUIForRequest(request));
// there is no coordinator, simulate a dismissal.
if (!coordinator_) {
DCHECK_EQ(request_, request);
state->set_dismissal_reason(OverlayDismissalReason::kCancellation);
state->OverlayUIWasDismissed();
return;
}
DismissPresentedUI(OverlayDismissalReason::kCancellation); DismissPresentedUI(OverlayDismissalReason::kCancellation);
} }
...@@ -199,10 +186,11 @@ void OverlayPresentationContextImpl::SetRequest(OverlayRequest* request) { ...@@ -199,10 +186,11 @@ void OverlayPresentationContextImpl::SetRequest(OverlayRequest* request) {
request_ = request; request_ = request;
// The UI state should be created before resetting the presented request. if (request_) {
DCHECK(!request_ || GetRequestUIState(request_)); // The UI state should be created before resetting the presented request.
DCHECK(GetRequestUIState(request_));
ShowUIForPresentedRequest(); ShowUIForPresentedRequest();
}
} }
OverlayRequestUIState* OverlayPresentationContextImpl::GetRequestUIState( OverlayRequestUIState* OverlayPresentationContextImpl::GetRequestUIState(
...@@ -247,11 +235,11 @@ void OverlayPresentationContextImpl::UpdateForCoordinator( ...@@ -247,11 +235,11 @@ void OverlayPresentationContextImpl::UpdateForCoordinator(
#pragma mark Presentation and Dismissal helpers #pragma mark Presentation and Dismissal helpers
void OverlayPresentationContextImpl::ShowUIForPresentedRequest() { void OverlayPresentationContextImpl::ShowUIForPresentedRequest() {
OverlayRequestUIState* state = GetRequestUIState(request_); DCHECK(request_);
if (!state || !coordinator_) DCHECK(CanShowUIForRequest(request_));
return;
// Create the coordinator if necessary. // Create the coordinator if necessary.
OverlayRequestUIState* state = GetRequestUIState(request_);
UIViewController* container_view_controller = coordinator_.viewController; UIViewController* container_view_controller = coordinator_.viewController;
OverlayRequestCoordinator* overlay_coordinator = state->coordinator(); OverlayRequestCoordinator* overlay_coordinator = state->coordinator();
if (!overlay_coordinator || if (!overlay_coordinator ||
...@@ -280,7 +268,6 @@ void OverlayPresentationContextImpl::DismissPresentedUI( ...@@ -280,7 +268,6 @@ void OverlayPresentationContextImpl::DismissPresentedUI(
OverlayDismissalReason reason) { OverlayDismissalReason reason) {
OverlayRequestUIState* state = GetRequestUIState(request_); OverlayRequestUIState* state = GetRequestUIState(request_);
DCHECK(state); DCHECK(state);
DCHECK(coordinator_);
DCHECK(state->coordinator()); DCHECK(state->coordinator());
state->set_dismissal_reason(reason); state->set_dismissal_reason(reason);
......
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