Commit 26864c19 authored by Luca Hunkeler's avatar Luca Hunkeler Committed by Chromium LUCI CQ

[Autofill Assistant] Check "get help" switch before triggering JITT

JITT should only trigger when both the "get help" and "proactive help"
swtiches are turned on.

Bug: b/176071036
Change-Id: I978d49c1c288fc422343ccf49eea0573ac51d215
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2613046
Commit-Queue: Luca Hunkeler <hluca@google.com>
Reviewed-by: default avatarMarian Fechete <marianfe@google.com>
Cr-Commit-Position: refs/heads/master@{#840976}
parent 45dcca11
......@@ -51,7 +51,7 @@ public class AutofillAssistantModuleEntryImpl implements AutofillAssistantModule
@NonNull String initialUrl, Map<String, String> parameters, String experimentIds,
@Nullable String callerAccount, @Nullable String userName) {
if (shouldStartTriggerScript(parameters)) {
if (!AutofillAssistantPreferencesUtil.isProactiveHelpSwitchOn()) {
if (!AutofillAssistantPreferencesUtil.isProactiveHelpOn()) {
// Opt-out users who have disabled the proactive help Chrome setting.
AutofillAssistantMetrics.recordLiteScriptStarted(
webContents, LiteScriptStarted.LITE_SCRIPT_PROACTIVE_TRIGGERING_DISABLED);
......
......@@ -172,7 +172,7 @@ public class AssistantTriggerScriptBridge {
@CalledByNative
private static boolean isProactiveHelpEnabled() {
return AutofillAssistantPreferencesUtil.isProactiveHelpSwitchOn();
return AutofillAssistantPreferencesUtil.isProactiveHelpOn();
}
@CalledByNative
......
......@@ -253,7 +253,7 @@ public class AutofillAssistantTriggerScriptIntegrationTest {
setupTriggerScripts(triggerScripts);
startAutofillAssistantOnTab(TEST_PAGE_A);
Assert.assertTrue(AutofillAssistantPreferencesUtil.isProactiveHelpSwitchOn());
Assert.assertTrue(AutofillAssistantPreferencesUtil.isProactiveHelpOn());
waitUntilViewMatchesCondition(
withContentDescription(R.string.autofill_assistant_overflow_options),
isCompletelyDisplayed());
......@@ -263,7 +263,7 @@ public class AutofillAssistantTriggerScriptIntegrationTest {
onView(withText("Never show again")).perform(click());
waitUntilViewAssertionTrue(
withText("Hello world"), doesNotExist(), DEFAULT_MAX_TIME_TO_POLL);
Assert.assertFalse(AutofillAssistantPreferencesUtil.isProactiveHelpSwitchOn());
Assert.assertFalse(AutofillAssistantPreferencesUtil.isProactiveHelpOn());
}
@Test
......@@ -572,4 +572,28 @@ public class AutofillAssistantTriggerScriptIntegrationTest {
Espresso.pressBack();
waitUntilViewMatchesCondition(withText("Hello world"), isCompletelyDisplayed());
}
@Test
@MediumTest
@Features.EnableFeatures(ChromeFeatureList.AUTOFILL_ASSISTANT_PROACTIVE_HELP)
public void proactiveHelpConditions() {
Assert.assertTrue(AutofillAssistantPreferencesUtil.isProactiveHelpOn());
SharedPreferencesManager.getInstance().writeBoolean(
ChromePreferenceKeys.AUTOFILL_ASSISTANT_ENABLED, false);
Assert.assertFalse(AutofillAssistantPreferencesUtil.isProactiveHelpOn());
SharedPreferencesManager.getInstance().writeBoolean(
ChromePreferenceKeys.AUTOFILL_ASSISTANT_ENABLED, true);
SharedPreferencesManager.getInstance().writeBoolean(
ChromePreferenceKeys.AUTOFILL_ASSISTANT_PROACTIVE_HELP, false);
Assert.assertFalse(AutofillAssistantPreferencesUtil.isProactiveHelpOn());
SharedPreferencesManager.getInstance().writeBoolean(
ChromePreferenceKeys.AUTOFILL_ASSISTANT_PROACTIVE_HELP, true);
Assert.assertTrue(AutofillAssistantPreferencesUtil.isProactiveHelpOn());
}
}
......@@ -123,8 +123,7 @@ public class AutofillAssistantFacade {
// regular autofill assistant Chrome setting. Since M-88, they also respect the new
// proactive help setting.
if (arguments.containsTriggerScript()
&& (!AutofillAssistantPreferencesUtil.isAutofillAssistantSwitchOn()
|| !AutofillAssistantPreferencesUtil.isProactiveHelpSwitchOn())) {
&& (!AutofillAssistantPreferencesUtil.isProactiveHelpOn())) {
if (AutofillAssistantPreferencesUtil
.isAutofillAssistantLiteScriptCancelThresholdReached()) {
AutofillAssistantMetrics.recordLiteScriptStarted(tab.getWebContents(),
......
......@@ -26,8 +26,13 @@ public class AutofillAssistantPreferencesUtil {
ChromePreferenceKeys.AUTOFILL_ASSISTANT_ENABLED, true);
}
/** Checks whether proactive help is enabled. */
public static boolean isProactiveHelpOn() {
return isProactiveHelpSwitchOn() && isAutofillAssistantSwitchOn();
}
/** Checks whether the proactive help switch preference in settings is on. */
public static boolean isProactiveHelpSwitchOn() {
private static boolean isProactiveHelpSwitchOn() {
if (!ChromeFeatureList.isEnabled(ChromeFeatureList.AUTOFILL_ASSISTANT_PROACTIVE_HELP)) {
return false;
}
......
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