Commit acd5d8f0 authored by Clemens Arbesser's avatar Clemens Arbesser Committed by Chromium LUCI CQ

[Autofill Assistant] Early-load DFM for trigger scripts without UI.

Bug: b/176890422
Change-Id: I229923bf68af34376917a0def846cec0adff9183
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2627424
Commit-Queue: Clemens Arbesser <arbesser@google.com>
Reviewed-by: default avatarMarian Fechete <marianfe@google.com>
Reviewed-by: default avatarMathias Carlen <mcarlen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#844026}
parent 36842bb4
......@@ -110,12 +110,13 @@ class TestingAutofillAssistantModuleEntryProvider extends AutofillAssistantModul
}
@Override
public void getModuleEntry(Tab tab, Callback<AutofillAssistantModuleEntry> callback) {
public void getModuleEntry(
Tab tab, Callback<AutofillAssistantModuleEntry> callback, boolean showUi) {
if (mCannotInstall) {
callback.onResult(null);
return;
}
mNotInstalled = false;
super.getModuleEntry(tab, callback);
super.getModuleEntry(tab, callback, showUi);
}
}
......@@ -216,7 +216,7 @@ public class AutofillAssistantDirectActionHandler implements DirectActionHandler
mModuleEntryProvider.getModuleEntry(tab, (entry) -> {
mDelegate = createDelegate(entry);
callback.onResult(mDelegate);
});
}, /* showUi = */ true);
}
/** Creates a delegate from the given {@link AutofillAssistantModuleEntry}, if possible. */
......
......@@ -133,36 +133,45 @@ public class AutofillAssistantFacade {
}
if (AutofillAssistantModuleEntryProvider.INSTANCE.getModuleEntryIfInstalled()
== null) {
// Opt-out users who don't have DFM installed.
AutofillAssistantMetrics.recordLiteScriptStarted(
tab.getWebContents(), LiteScriptStarted.LITE_SCRIPT_DFM_UNAVAILABLE);
== null
&& arguments.containsTriggerScript()
&& !ChromeFeatureList.isEnabled(
ChromeFeatureList
.AUTOFILL_ASSISTANT_LOAD_DFM_FOR_TRIGGER_SCRIPTS)) {
return;
}
}
AutofillAssistantModuleEntryProvider.INSTANCE.getModuleEntry(
tab, (moduleEntry) -> {
if (moduleEntry == null || activity.isActivityFinishingOrDestroyed()) {
AutofillAssistantMetrics.recordDropOut(
DropOutReason.DFM_INSTALL_FAILED);
return;
if (AutofillAssistantModuleEntryProvider.INSTANCE.getModuleEntryIfInstalled() == null) {
AutofillAssistantModuleEntryProvider.INSTANCE.getModuleEntry(tab, (moduleEntry) -> {
if (moduleEntry == null || activity.isActivityFinishingOrDestroyed()) {
AutofillAssistantMetrics.recordDropOut(DropOutReason.DFM_INSTALL_FAILED);
if (arguments.containsTriggerScript()) {
AutofillAssistantMetrics.recordLiteScriptFinished(tab.getWebContents(),
LiteScriptStarted.LITE_SCRIPT_DFM_UNAVAILABLE);
}
moduleEntry.start(
BottomSheetControllerProvider.from(activity.getWindowAndroid()),
activity.getBrowserControlsManager(),
activity.getCompositorViewHolder(), activity, tab.getWebContents(),
activity.getWindowAndroid().getKeyboardDelegate(),
activity.getWindowAndroid().getApplicationBottomInsetProvider(),
activity.getActivityTabProvider(),
activity instanceof CustomTabActivity, arguments.getInitialUrl(),
arguments.getParameters(), arguments.getExperimentIds(),
arguments.getCallerAccount(), arguments.getUserName());
});
return;
}
start(activity, arguments, moduleEntry);
}, /* showUi = */ !arguments.containsTriggerScript());
} else {
start(activity, arguments,
AutofillAssistantModuleEntryProvider.INSTANCE.getModuleEntryIfInstalled());
}
});
}
private static void start(ChromeActivity activity, AutofillAssistantArguments arguments,
AutofillAssistantModuleEntry module) {
module.start(BottomSheetControllerProvider.from(activity.getWindowAndroid()),
activity.getBrowserControlsManager(), activity.getCompositorViewHolder(), activity,
activity.getCurrentWebContents(), activity.getWindowAndroid().getKeyboardDelegate(),
activity.getWindowAndroid().getApplicationBottomInsetProvider(),
activity.getActivityTabProvider(), activity instanceof CustomTabActivity,
arguments.getInitialUrl(), arguments.getParameters(), arguments.getExperimentIds(),
arguments.getCallerAccount(), arguments.getUserName());
}
/**
* Checks whether direct actions provided by Autofill Assistant should be available - assuming
* that direct actions are available at all.
......
......@@ -42,7 +42,7 @@ public class AutofillAssistantModuleEntryProvider {
/** Gets the AA module entry, installing it if necessary. */
/* package */
void getModuleEntry(Tab tab, Callback<AutofillAssistantModuleEntry> callback) {
void getModuleEntry(Tab tab, Callback<AutofillAssistantModuleEntry> callback, boolean showUi) {
AutofillAssistantModuleEntry entry = getModuleEntryIfInstalled();
if (entry != null) {
AutofillAssistantMetrics.recordFeatureModuleInstallation(
......@@ -50,7 +50,7 @@ public class AutofillAssistantModuleEntryProvider {
callback.onResult(entry);
return;
}
loadDynamicModuleWithUi(tab, callback);
loadDynamicModule(tab, callback, showUi);
}
/**
......@@ -83,14 +83,14 @@ public class AutofillAssistantModuleEntryProvider {
AutofillAssistantModule.installDeferred();
}
private static void loadDynamicModuleWithUi(
Tab tab, Callback<AutofillAssistantModuleEntry> callback) {
private static void loadDynamicModule(
Tab tab, Callback<AutofillAssistantModuleEntry> callback, boolean showUi) {
ModuleInstallUi ui = new ModuleInstallUi(tab, R.string.autofill_assistant_module_title,
new ModuleInstallUi.FailureUiListener() {
@Override
public void onFailureUiResponse(boolean retry) {
if (retry) {
loadDynamicModuleWithUi(tab, callback);
loadDynamicModule(tab, callback, showUi);
} else {
AutofillAssistantMetrics.recordFeatureModuleInstallation(
FeatureModuleInstallation.DFM_FOREGROUND_INSTALLATION_FAILED);
......@@ -98,8 +98,11 @@ public class AutofillAssistantModuleEntryProvider {
}
}
});
// Shows toast informing user about install start.
ui.showInstallStartUi();
if (showUi) {
// Shows toast informing user about install start.
ui.showInstallStartUi();
}
AutofillAssistantModule.install((success) -> {
if (success) {
// Don't show success UI from DFM, transition to Autofill Assistant UI directly.
......@@ -107,9 +110,12 @@ public class AutofillAssistantModuleEntryProvider {
FeatureModuleInstallation.DFM_FOREGROUND_INSTALLATION_SUCCEEDED);
callback.onResult(AutofillAssistantModule.getImpl());
return;
} else if (showUi) {
// Show inforbar to ask user if they want to retry or cancel.
ui.showInstallFailureUi();
} else {
callback.onResult(null);
}
// Show inforbar to ask user if they want to retry or cancel.
ui.showInstallFailureUi();
});
}
}
......@@ -84,6 +84,7 @@ const base::Feature* kFeaturesExposedToJava[] = {
&autofill_assistant::features::kAutofillAssistantChromeEntry,
&autofill_assistant::features::kAutofillAssistantDirectActions,
&autofill_assistant::features::kAutofillAssistantDisableOnboardingFlow,
&autofill_assistant::features::kAutofillAssistantLoadDFMForTriggerScripts,
&autofill_assistant::features::kAutofillAssistantProactiveHelp,
&autofill_assistant::features::
kAutofillAssistantDisableProactiveHelpTiedToMSBB,
......
......@@ -225,6 +225,8 @@ public abstract class ChromeFeatureList {
public static final String AUTOFILL_ASSISTANT_DIRECT_ACTIONS = "AutofillAssistantDirectActions";
public static final String AUTOFILL_ASSISTANT_DISABLE_ONBOARDING_FLOW =
"AutofillAssistantDisableOnboardingFlow";
public static final String AUTOFILL_ASSISTANT_LOAD_DFM_FOR_TRIGGER_SCRIPTS =
"AutofillAssistantLoadDFMForTriggerScripts";
public static final String AUTOFILL_ASSISTANT_PROACTIVE_HELP = "AutofillAssistantProactiveHelp";
public static final String AUTOFILL_ASSISTANT_DISABLE_PROACTIVE_HELP_TIED_TO_MSBB =
"AutofillAssistantDisableProactiveHelpTiedToMSBB";
......
......@@ -24,14 +24,6 @@ const base::Feature kAutofillAssistantDisableOnboardingFlow{
"AutofillAssistantDisableOnboardingFlow",
base::FEATURE_DISABLED_BY_DEFAULT};
const base::Feature kAutofillAssistantProactiveHelp{
"AutofillAssistantProactiveHelp", base::FEATURE_DISABLED_BY_DEFAULT};
// Use Chrome's TabHelper system to deal with the life cycle of WebContent's
// depending Autofill Assistant objects.
const base::Feature kAutofillAssistantWithTabHelper{
"AutofillAssistantWithTabHelper", base::FEATURE_DISABLED_BY_DEFAULT};
// By default, proactive help is only offered if MSBB is turned on. This feature
// flag allows disabling the link. Proactive help can still be offered to users
// so long as no communication to a remote backend is required. Specifically,
......@@ -40,5 +32,20 @@ const base::Feature kAutofillAssistantDisableProactiveHelpTiedToMSBB{
"AutofillAssistantDisableProactiveHelpTiedToMSBB",
base::FEATURE_DISABLED_BY_DEFAULT};
// Whether autofill assistant should load the DFM for trigger scripts when
// necessary. Without this feature, trigger scripts will exit if the DFM is not
// available.
const base::Feature kAutofillAssistantLoadDFMForTriggerScripts{
"AutofillAssistantLoadDFMForTriggerScripts",
base::FEATURE_DISABLED_BY_DEFAULT};
const base::Feature kAutofillAssistantProactiveHelp{
"AutofillAssistantProactiveHelp", base::FEATURE_DISABLED_BY_DEFAULT};
// Use Chrome's TabHelper system to deal with the life cycle of WebContent's
// depending Autofill Assistant objects.
const base::Feature kAutofillAssistantWithTabHelper{
"AutofillAssistantWithTabHelper", base::FEATURE_DISABLED_BY_DEFAULT};
} // namespace features
} // namespace autofill_assistant
......@@ -17,9 +17,10 @@ extern const base::Feature kAutofillAssistant;
extern const base::Feature kAutofillAssistantChromeEntry;
extern const base::Feature kAutofillAssistantDirectActions;
extern const base::Feature kAutofillAssistantDisableOnboardingFlow;
extern const base::Feature kAutofillAssistantDisableProactiveHelpTiedToMSBB;
extern const base::Feature kAutofillAssistantLoadDFMForTriggerScripts;
extern const base::Feature kAutofillAssistantProactiveHelp;
extern const base::Feature kAutofillAssistantWithTabHelper;
extern const base::Feature kAutofillAssistantDisableProactiveHelpTiedToMSBB;
} // namespace features
} // namespace autofill_assistant
......
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