Commit febcccd5 authored by Samuel Huang's avatar Samuel Huang Committed by Commit Bot

[Bundles] Streamline interface ModuleInstallUi.FailureUiListener.

Previously interface ModuleInstallUi.FailureUiListener has two
callbacks: {onRetry(), onCancel()}. This CL merges the callbacks to
onFailureResponse(), which takes a |retry| param to distinguish the two
cases. This results in a slight savings in method counts (4 right now).

Bug: 927131
Change-Id: I2965906f033fc05920657ea4cb1cd7424bc8a86c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1763640Reviewed-by: default avatarMichael Thiessen <mthiesse@chromium.org>
Reviewed-by: default avatarTibor Goldschwendt <tiborg@chromium.org>
Commit-Queue: Samuel Huang <huangs@chromium.org>
Cr-Commit-Position: refs/heads/master@{#689153}
parent f6e78d1e
......@@ -87,13 +87,12 @@ public class AutofillAssistantModuleEntryProvider {
ModuleInstallUi ui = new ModuleInstallUi(tab, R.string.autofill_assistant_module_title,
new ModuleInstallUi.FailureUiListener() {
@Override
public void onRetry() {
loadDynamicModuleWithUi(tab, callback);
}
@Override
public void onCancel() {
callback.onResult(null);
public void onFailureUiResponse(boolean retry) {
if (retry) {
loadDynamicModuleWithUi(tab, callback);
} else {
callback.onResult(null);
}
}
});
// Shows toast informing user about install start.
......
......@@ -128,15 +128,11 @@ public class VrModuleProvider implements ModuleInstallUi.FailureUiListener {
}
@Override
public void onRetry() {
if (mNativeVrModuleProvider != 0) {
public void onFailureUiResponse(boolean retry) {
if (mNativeVrModuleProvider == 0) return;
if (retry) {
installModule(mTab);
}
}
@Override
public void onCancel() {
if (mNativeVrModuleProvider != 0) {
} else {
nativeOnInstalledModule(mNativeVrModuleProvider, false);
}
}
......
......@@ -24,14 +24,12 @@ public class ModuleInstallUi {
/** Listener for when the user interacts with the install failure UI. */
public interface FailureUiListener {
/** Called if the user wishes to retry installing the module. */
void onRetry();
/**
* Called if the failure UI has been dismissed and the user does not want to retry
* installing the module.
* Called when the user makes a decision to handle the failure, either to retry installing
* the module or to cancel installing the module by dismissing the UI.
* @param retry Whether user decides to retry installing the module.
*/
void onCancel();
void onFailureUiResponse(boolean retry);
}
/*
......@@ -89,24 +87,20 @@ public class ModuleInstallUi {
Context context = mTab.getActivity();
if (context == null) {
// Tab is detached. Cancel.
if (mFailureUiListener != null) mFailureUiListener.onCancel();
if (mFailureUiListener != null) mFailureUiListener.onFailureUiResponse(false);
return;
}
SimpleConfirmInfoBarBuilder.Listener listener = new SimpleConfirmInfoBarBuilder.Listener() {
@Override
public void onInfoBarDismissed() {
if (mFailureUiListener != null) mFailureUiListener.onCancel();
if (mFailureUiListener != null) mFailureUiListener.onFailureUiResponse(false);
}
@Override
public boolean onInfoBarButtonClicked(boolean isPrimary) {
if (mFailureUiListener != null) {
if (isPrimary) {
mFailureUiListener.onRetry();
} else {
mFailureUiListener.onCancel();
}
mFailureUiListener.onFailureUiResponse(isPrimary);
}
return false;
}
......
......@@ -69,16 +69,14 @@ public class ArCoreInstallUtils implements ModuleInstallUi.FailureUiListener {
}
@Override
public void onRetry() {
public void onFailureUiResponse(boolean retry) {
if (mNativeArCoreInstallUtils == 0) return;
requestInstallArModule(mTab);
}
@Override
public void onCancel() {
if (mNativeArCoreInstallUtils == 0) return;
ArCoreInstallUtilsJni.get().onRequestInstallArModuleResult(
mNativeArCoreInstallUtils, false);
if (retry) {
requestInstallArModule(mTab);
} else {
ArCoreInstallUtilsJni.get().onRequestInstallArModuleResult(
mNativeArCoreInstallUtils, false);
}
}
@CalledByNative
......@@ -124,7 +122,7 @@ public class ArCoreInstallUtils implements ModuleInstallUi.FailureUiListener {
} else {
ui.showInstallFailureUi();
// early exit - user will be offered a choice to retry & install flow will
// continue from onRetry / onCancel
// continue from onFailureUiResponse().
return;
}
}
......
......@@ -680,13 +680,12 @@ public static void installModuleWithUi(
R.string.foo_module_title,
new ModuleInstallUi.FailureUiListener() {
@Override
public void onRetry() {
installModuleWithUi(tab, onFinishedListener);
}
@Override
public void onCancel() {
onFinishedListener.onFinished(false);
public void onFailureUiResponse(retry) {
if (retry) {
installModuleWithUi(tab, onFinishedListener);
} else {
onFinishedListener.onFinished(false);
}
}
});
// At the time of writing, shows toast informing user about install start.
......
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