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 ...@@ -110,12 +110,13 @@ class TestingAutofillAssistantModuleEntryProvider extends AutofillAssistantModul
} }
@Override @Override
public void getModuleEntry(Tab tab, Callback<AutofillAssistantModuleEntry> callback) { public void getModuleEntry(
Tab tab, Callback<AutofillAssistantModuleEntry> callback, boolean showUi) {
if (mCannotInstall) { if (mCannotInstall) {
callback.onResult(null); callback.onResult(null);
return; return;
} }
mNotInstalled = false; mNotInstalled = false;
super.getModuleEntry(tab, callback); super.getModuleEntry(tab, callback, showUi);
} }
} }
...@@ -216,7 +216,7 @@ public class AutofillAssistantDirectActionHandler implements DirectActionHandler ...@@ -216,7 +216,7 @@ public class AutofillAssistantDirectActionHandler implements DirectActionHandler
mModuleEntryProvider.getModuleEntry(tab, (entry) -> { mModuleEntryProvider.getModuleEntry(tab, (entry) -> {
mDelegate = createDelegate(entry); mDelegate = createDelegate(entry);
callback.onResult(mDelegate); callback.onResult(mDelegate);
}); }, /* showUi = */ true);
} }
/** Creates a delegate from the given {@link AutofillAssistantModuleEntry}, if possible. */ /** Creates a delegate from the given {@link AutofillAssistantModuleEntry}, if possible. */
......
...@@ -133,36 +133,45 @@ public class AutofillAssistantFacade { ...@@ -133,36 +133,45 @@ public class AutofillAssistantFacade {
} }
if (AutofillAssistantModuleEntryProvider.INSTANCE.getModuleEntryIfInstalled() if (AutofillAssistantModuleEntryProvider.INSTANCE.getModuleEntryIfInstalled()
== null) { == null
// Opt-out users who don't have DFM installed. && arguments.containsTriggerScript()
AutofillAssistantMetrics.recordLiteScriptStarted( && !ChromeFeatureList.isEnabled(
tab.getWebContents(), LiteScriptStarted.LITE_SCRIPT_DFM_UNAVAILABLE); ChromeFeatureList
.AUTOFILL_ASSISTANT_LOAD_DFM_FOR_TRIGGER_SCRIPTS)) {
return; return;
} }
} }
AutofillAssistantModuleEntryProvider.INSTANCE.getModuleEntry( if (AutofillAssistantModuleEntryProvider.INSTANCE.getModuleEntryIfInstalled() == null) {
tab, (moduleEntry) -> { AutofillAssistantModuleEntryProvider.INSTANCE.getModuleEntry(tab, (moduleEntry) -> {
if (moduleEntry == null || activity.isActivityFinishingOrDestroyed()) { if (moduleEntry == null || activity.isActivityFinishingOrDestroyed()) {
AutofillAssistantMetrics.recordDropOut( AutofillAssistantMetrics.recordDropOut(DropOutReason.DFM_INSTALL_FAILED);
DropOutReason.DFM_INSTALL_FAILED); if (arguments.containsTriggerScript()) {
return; AutofillAssistantMetrics.recordLiteScriptFinished(tab.getWebContents(),
LiteScriptStarted.LITE_SCRIPT_DFM_UNAVAILABLE);
} }
return;
moduleEntry.start( }
BottomSheetControllerProvider.from(activity.getWindowAndroid()), start(activity, arguments, moduleEntry);
activity.getBrowserControlsManager(), }, /* showUi = */ !arguments.containsTriggerScript());
activity.getCompositorViewHolder(), activity, tab.getWebContents(), } else {
activity.getWindowAndroid().getKeyboardDelegate(), start(activity, arguments,
activity.getWindowAndroid().getApplicationBottomInsetProvider(), AutofillAssistantModuleEntryProvider.INSTANCE.getModuleEntryIfInstalled());
activity.getActivityTabProvider(), }
activity instanceof CustomTabActivity, arguments.getInitialUrl(),
arguments.getParameters(), arguments.getExperimentIds(),
arguments.getCallerAccount(), arguments.getUserName());
});
}); });
} }
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 * Checks whether direct actions provided by Autofill Assistant should be available - assuming
* that direct actions are available at all. * that direct actions are available at all.
......
...@@ -42,7 +42,7 @@ public class AutofillAssistantModuleEntryProvider { ...@@ -42,7 +42,7 @@ public class AutofillAssistantModuleEntryProvider {
/** Gets the AA module entry, installing it if necessary. */ /** Gets the AA module entry, installing it if necessary. */
/* package */ /* package */
void getModuleEntry(Tab tab, Callback<AutofillAssistantModuleEntry> callback) { void getModuleEntry(Tab tab, Callback<AutofillAssistantModuleEntry> callback, boolean showUi) {
AutofillAssistantModuleEntry entry = getModuleEntryIfInstalled(); AutofillAssistantModuleEntry entry = getModuleEntryIfInstalled();
if (entry != null) { if (entry != null) {
AutofillAssistantMetrics.recordFeatureModuleInstallation( AutofillAssistantMetrics.recordFeatureModuleInstallation(
...@@ -50,7 +50,7 @@ public class AutofillAssistantModuleEntryProvider { ...@@ -50,7 +50,7 @@ public class AutofillAssistantModuleEntryProvider {
callback.onResult(entry); callback.onResult(entry);
return; return;
} }
loadDynamicModuleWithUi(tab, callback); loadDynamicModule(tab, callback, showUi);
} }
/** /**
...@@ -83,14 +83,14 @@ public class AutofillAssistantModuleEntryProvider { ...@@ -83,14 +83,14 @@ public class AutofillAssistantModuleEntryProvider {
AutofillAssistantModule.installDeferred(); AutofillAssistantModule.installDeferred();
} }
private static void loadDynamicModuleWithUi( private static void loadDynamicModule(
Tab tab, Callback<AutofillAssistantModuleEntry> callback) { Tab tab, Callback<AutofillAssistantModuleEntry> callback, boolean showUi) {
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 onFailureUiResponse(boolean retry) { public void onFailureUiResponse(boolean retry) {
if (retry) { if (retry) {
loadDynamicModuleWithUi(tab, callback); loadDynamicModule(tab, callback, showUi);
} else { } else {
AutofillAssistantMetrics.recordFeatureModuleInstallation( AutofillAssistantMetrics.recordFeatureModuleInstallation(
FeatureModuleInstallation.DFM_FOREGROUND_INSTALLATION_FAILED); FeatureModuleInstallation.DFM_FOREGROUND_INSTALLATION_FAILED);
...@@ -98,8 +98,11 @@ public class AutofillAssistantModuleEntryProvider { ...@@ -98,8 +98,11 @@ public class AutofillAssistantModuleEntryProvider {
} }
} }
}); });
// Shows toast informing user about install start. if (showUi) {
ui.showInstallStartUi(); // Shows toast informing user about install start.
ui.showInstallStartUi();
}
AutofillAssistantModule.install((success) -> { AutofillAssistantModule.install((success) -> {
if (success) { if (success) {
// Don't show success UI from DFM, transition to Autofill Assistant UI directly. // Don't show success UI from DFM, transition to Autofill Assistant UI directly.
...@@ -107,9 +110,12 @@ public class AutofillAssistantModuleEntryProvider { ...@@ -107,9 +110,12 @@ public class AutofillAssistantModuleEntryProvider {
FeatureModuleInstallation.DFM_FOREGROUND_INSTALLATION_SUCCEEDED); FeatureModuleInstallation.DFM_FOREGROUND_INSTALLATION_SUCCEEDED);
callback.onResult(AutofillAssistantModule.getImpl()); callback.onResult(AutofillAssistantModule.getImpl());
return; 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[] = { ...@@ -84,6 +84,7 @@ const base::Feature* kFeaturesExposedToJava[] = {
&autofill_assistant::features::kAutofillAssistantChromeEntry, &autofill_assistant::features::kAutofillAssistantChromeEntry,
&autofill_assistant::features::kAutofillAssistantDirectActions, &autofill_assistant::features::kAutofillAssistantDirectActions,
&autofill_assistant::features::kAutofillAssistantDisableOnboardingFlow, &autofill_assistant::features::kAutofillAssistantDisableOnboardingFlow,
&autofill_assistant::features::kAutofillAssistantLoadDFMForTriggerScripts,
&autofill_assistant::features::kAutofillAssistantProactiveHelp, &autofill_assistant::features::kAutofillAssistantProactiveHelp,
&autofill_assistant::features:: &autofill_assistant::features::
kAutofillAssistantDisableProactiveHelpTiedToMSBB, kAutofillAssistantDisableProactiveHelpTiedToMSBB,
......
...@@ -225,6 +225,8 @@ public abstract class ChromeFeatureList { ...@@ -225,6 +225,8 @@ public abstract class ChromeFeatureList {
public static final String AUTOFILL_ASSISTANT_DIRECT_ACTIONS = "AutofillAssistantDirectActions"; public static final String AUTOFILL_ASSISTANT_DIRECT_ACTIONS = "AutofillAssistantDirectActions";
public static final String AUTOFILL_ASSISTANT_DISABLE_ONBOARDING_FLOW = public static final String AUTOFILL_ASSISTANT_DISABLE_ONBOARDING_FLOW =
"AutofillAssistantDisableOnboardingFlow"; "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_PROACTIVE_HELP = "AutofillAssistantProactiveHelp";
public static final String AUTOFILL_ASSISTANT_DISABLE_PROACTIVE_HELP_TIED_TO_MSBB = public static final String AUTOFILL_ASSISTANT_DISABLE_PROACTIVE_HELP_TIED_TO_MSBB =
"AutofillAssistantDisableProactiveHelpTiedToMSBB"; "AutofillAssistantDisableProactiveHelpTiedToMSBB";
......
...@@ -24,14 +24,6 @@ const base::Feature kAutofillAssistantDisableOnboardingFlow{ ...@@ -24,14 +24,6 @@ const base::Feature kAutofillAssistantDisableOnboardingFlow{
"AutofillAssistantDisableOnboardingFlow", "AutofillAssistantDisableOnboardingFlow",
base::FEATURE_DISABLED_BY_DEFAULT}; 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 // 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 // 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, // so long as no communication to a remote backend is required. Specifically,
...@@ -40,5 +32,20 @@ const base::Feature kAutofillAssistantDisableProactiveHelpTiedToMSBB{ ...@@ -40,5 +32,20 @@ const base::Feature kAutofillAssistantDisableProactiveHelpTiedToMSBB{
"AutofillAssistantDisableProactiveHelpTiedToMSBB", "AutofillAssistantDisableProactiveHelpTiedToMSBB",
base::FEATURE_DISABLED_BY_DEFAULT}; 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 features
} // namespace autofill_assistant } // namespace autofill_assistant
...@@ -17,9 +17,10 @@ extern const base::Feature kAutofillAssistant; ...@@ -17,9 +17,10 @@ extern const base::Feature kAutofillAssistant;
extern const base::Feature kAutofillAssistantChromeEntry; extern const base::Feature kAutofillAssistantChromeEntry;
extern const base::Feature kAutofillAssistantDirectActions; extern const base::Feature kAutofillAssistantDirectActions;
extern const base::Feature kAutofillAssistantDisableOnboardingFlow; extern const base::Feature kAutofillAssistantDisableOnboardingFlow;
extern const base::Feature kAutofillAssistantDisableProactiveHelpTiedToMSBB;
extern const base::Feature kAutofillAssistantLoadDFMForTriggerScripts;
extern const base::Feature kAutofillAssistantProactiveHelp; extern const base::Feature kAutofillAssistantProactiveHelp;
extern const base::Feature kAutofillAssistantWithTabHelper; extern const base::Feature kAutofillAssistantWithTabHelper;
extern const base::Feature kAutofillAssistantDisableProactiveHelpTiedToMSBB;
} // namespace features } // namespace features
} // namespace autofill_assistant } // 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