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 { ...@@ -87,13 +87,12 @@ public class AutofillAssistantModuleEntryProvider {
ModuleInstallUi ui = new ModuleInstallUi(tab, R.string.autofill_assistant_module_title, ModuleInstallUi ui = new ModuleInstallUi(tab, R.string.autofill_assistant_module_title,
new ModuleInstallUi.FailureUiListener() { new ModuleInstallUi.FailureUiListener() {
@Override @Override
public void onRetry() { public void onFailureUiResponse(boolean retry) {
loadDynamicModuleWithUi(tab, callback); if (retry) {
} loadDynamicModuleWithUi(tab, callback);
} else {
@Override callback.onResult(null);
public void onCancel() { }
callback.onResult(null);
} }
}); });
// Shows toast informing user about install start. // Shows toast informing user about install start.
......
...@@ -128,15 +128,11 @@ public class VrModuleProvider implements ModuleInstallUi.FailureUiListener { ...@@ -128,15 +128,11 @@ public class VrModuleProvider implements ModuleInstallUi.FailureUiListener {
} }
@Override @Override
public void onRetry() { public void onFailureUiResponse(boolean retry) {
if (mNativeVrModuleProvider != 0) { if (mNativeVrModuleProvider == 0) return;
if (retry) {
installModule(mTab); installModule(mTab);
} } else {
}
@Override
public void onCancel() {
if (mNativeVrModuleProvider != 0) {
nativeOnInstalledModule(mNativeVrModuleProvider, false); nativeOnInstalledModule(mNativeVrModuleProvider, false);
} }
} }
......
...@@ -24,14 +24,12 @@ public class ModuleInstallUi { ...@@ -24,14 +24,12 @@ public class ModuleInstallUi {
/** Listener for when the user interacts with the install failure UI. */ /** Listener for when the user interacts with the install failure UI. */
public interface FailureUiListener { 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 * Called when the user makes a decision to handle the failure, either to retry installing
* installing the module. * 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 { ...@@ -89,24 +87,20 @@ public class ModuleInstallUi {
Context context = mTab.getActivity(); Context context = mTab.getActivity();
if (context == null) { if (context == null) {
// Tab is detached. Cancel. // Tab is detached. Cancel.
if (mFailureUiListener != null) mFailureUiListener.onCancel(); if (mFailureUiListener != null) mFailureUiListener.onFailureUiResponse(false);
return; return;
} }
SimpleConfirmInfoBarBuilder.Listener listener = new SimpleConfirmInfoBarBuilder.Listener() { SimpleConfirmInfoBarBuilder.Listener listener = new SimpleConfirmInfoBarBuilder.Listener() {
@Override @Override
public void onInfoBarDismissed() { public void onInfoBarDismissed() {
if (mFailureUiListener != null) mFailureUiListener.onCancel(); if (mFailureUiListener != null) mFailureUiListener.onFailureUiResponse(false);
} }
@Override @Override
public boolean onInfoBarButtonClicked(boolean isPrimary) { public boolean onInfoBarButtonClicked(boolean isPrimary) {
if (mFailureUiListener != null) { if (mFailureUiListener != null) {
if (isPrimary) { mFailureUiListener.onFailureUiResponse(isPrimary);
mFailureUiListener.onRetry();
} else {
mFailureUiListener.onCancel();
}
} }
return false; return false;
} }
......
...@@ -69,16 +69,14 @@ public class ArCoreInstallUtils implements ModuleInstallUi.FailureUiListener { ...@@ -69,16 +69,14 @@ public class ArCoreInstallUtils implements ModuleInstallUi.FailureUiListener {
} }
@Override @Override
public void onRetry() { public void onFailureUiResponse(boolean retry) {
if (mNativeArCoreInstallUtils == 0) return; if (mNativeArCoreInstallUtils == 0) return;
requestInstallArModule(mTab); if (retry) {
} requestInstallArModule(mTab);
} else {
@Override ArCoreInstallUtilsJni.get().onRequestInstallArModuleResult(
public void onCancel() { mNativeArCoreInstallUtils, false);
if (mNativeArCoreInstallUtils == 0) return; }
ArCoreInstallUtilsJni.get().onRequestInstallArModuleResult(
mNativeArCoreInstallUtils, false);
} }
@CalledByNative @CalledByNative
...@@ -124,7 +122,7 @@ public class ArCoreInstallUtils implements ModuleInstallUi.FailureUiListener { ...@@ -124,7 +122,7 @@ public class ArCoreInstallUtils implements ModuleInstallUi.FailureUiListener {
} else { } else {
ui.showInstallFailureUi(); ui.showInstallFailureUi();
// early exit - user will be offered a choice to retry & install flow will // early exit - user will be offered a choice to retry & install flow will
// continue from onRetry / onCancel // continue from onFailureUiResponse().
return; return;
} }
} }
......
...@@ -680,13 +680,12 @@ public static void installModuleWithUi( ...@@ -680,13 +680,12 @@ public static void installModuleWithUi(
R.string.foo_module_title, R.string.foo_module_title,
new ModuleInstallUi.FailureUiListener() { new ModuleInstallUi.FailureUiListener() {
@Override @Override
public void onRetry() { public void onFailureUiResponse(retry) {
installModuleWithUi(tab, onFinishedListener); if (retry) {
} installModuleWithUi(tab, onFinishedListener);
} else {
@Override onFinishedListener.onFinished(false);
public void onCancel() { }
onFinishedListener.onFinished(false);
} }
}); });
// At the time of writing, shows toast informing user about install start. // 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