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

[Autofill Assistant] Allow disabling proactive help <-> MSBB link.

By default, proactive help is only offered if MSBB is turned on. This CL
adds a new feature flag that allows disabling the link. Proactive help
can still be offered to users so long as no communication to a remote
backend is required. Specifically, base64-injected trigger scripts can
be shown even in the absence of MSBB.

Actual communication with a remote endpoint remains gated by MSBB, the
feature flag merely changes the appearance of the settings.

Bug: b/174125596
Change-Id: I9f5f1cfc801d9ae12340a1c4a43c42a2accc8484
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2562665
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@{#832371}
parent 27feae33
...@@ -50,11 +50,21 @@ public class AutofillAssistantModuleEntryImpl implements AutofillAssistantModule ...@@ -50,11 +50,21 @@ public class AutofillAssistantModuleEntryImpl implements AutofillAssistantModule
@NonNull String initialUrl, Map<String, String> parameters, String experimentIds, @NonNull String initialUrl, Map<String, String> parameters, String experimentIds,
@Nullable String callerAccount, @Nullable String userName) { @Nullable String callerAccount, @Nullable String userName) {
if (shouldStartTriggerScript(parameters)) { if (shouldStartTriggerScript(parameters)) {
if (TextUtils.isEmpty(parameters.get(PARAMETER_TRIGGER_SCRIPTS_BASE64)) if (!AutofillAssistantPreferencesUtil.isProactiveHelpSwitchOn()) {
// Opt-out users who have disabled the proactive help Chrome setting.
AutofillAssistantMetrics.recordLiteScriptStarted(
webContents, LiteScriptStarted.LITE_SCRIPT_PROACTIVE_TRIGGERING_DISABLED);
return;
}
if ((!TextUtils.isEmpty(parameters.get(PARAMETER_TRIGGER_FIRST_TIME_USER))
|| !TextUtils.isEmpty(parameters.get(PARAMETER_REQUEST_TRIGGER_SCRIPT)))
&& !UnifiedConsentServiceBridge.isUrlKeyedAnonymizedDataCollectionEnabled( && !UnifiedConsentServiceBridge.isUrlKeyedAnonymizedDataCollectionEnabled(
AutofillAssistantUiController.getProfile())) { AutofillAssistantUiController.getProfile())) {
// Opt-out users who have disabled anonymous data collection, unless the trigger // Proactive help that requires communicating with a remote endpoint is tied to the
// scripts are directly specified in base64 format. // MSBB flag. Even though proactive help is toggled on, we need to stop if MSBB is
// off. The proactive help setting will appear disabled to the user.
AutofillAssistantMetrics.recordLiteScriptStarted(
webContents, LiteScriptStarted.LITE_SCRIPT_PROACTIVE_TRIGGERING_DISABLED);
return; return;
} }
......
...@@ -119,20 +119,12 @@ public class AutofillAssistantFacade { ...@@ -119,20 +119,12 @@ public class AutofillAssistantFacade {
AutofillAssistantMetrics.recordLiteScriptStarted( AutofillAssistantMetrics.recordLiteScriptStarted(
tab.getWebContents(), LiteScriptStarted.LITE_SCRIPT_INTENT_RECEIVED); tab.getWebContents(), LiteScriptStarted.LITE_SCRIPT_INTENT_RECEIVED);
// For trigger scripts since M-88, there is a dedicated Chrome setting that can be
// used to forever opt-out.
if (arguments.requestsTriggerScript()
&& !AutofillAssistantPreferencesUtil.isProactiveHelpSwitchOn()) {
// Opt out users who have disabled the proactive help Chrome setting.
AutofillAssistantMetrics.recordLiteScriptStarted(tab.getWebContents(),
LiteScriptStarted.LITE_SCRIPT_PROACTIVE_TRIGGERING_DISABLED);
return;
}
// Legacy, remove as soon as possible. Trigger scripts before M-88 were tied to the // Legacy, remove as soon as possible. Trigger scripts before M-88 were tied to the
// regular autofill assistant Chrome setting. // regular autofill assistant Chrome setting. Since M-88, they also respect the new
// proactive help setting.
if (arguments.containsTriggerScript() if (arguments.containsTriggerScript()
&& !AutofillAssistantPreferencesUtil.isAutofillAssistantSwitchOn()) { && (!AutofillAssistantPreferencesUtil.isAutofillAssistantSwitchOn()
|| !AutofillAssistantPreferencesUtil.isProactiveHelpSwitchOn())) {
if (AutofillAssistantPreferencesUtil if (AutofillAssistantPreferencesUtil
.isAutofillAssistantLiteScriptCancelThresholdReached()) { .isAutofillAssistantLiteScriptCancelThresholdReached()) {
AutofillAssistantMetrics.recordLiteScriptStarted(tab.getWebContents(), AutofillAssistantMetrics.recordLiteScriptStarted(tab.getWebContents(),
......
...@@ -157,15 +157,21 @@ public class AutofillAssistantPreferenceFragment extends PreferenceFragmentCompa ...@@ -157,15 +157,21 @@ public class AutofillAssistantPreferenceFragment extends PreferenceFragmentCompa
UnifiedConsentServiceBridge.isUrlKeyedAnonymizedDataCollectionEnabled( UnifiedConsentServiceBridge.isUrlKeyedAnonymizedDataCollectionEnabled(
Profile.getLastUsedRegularProfile()); Profile.getLastUsedRegularProfile());
boolean proactive_toggle_enabled =
url_keyed_anonymized_data_collection_enabled && assistant_switch_on_or_missing;
boolean proactive_help_on = SharedPreferencesManager.getInstance().readBoolean( boolean proactive_help_on = SharedPreferencesManager.getInstance().readBoolean(
ChromePreferenceKeys.AUTOFILL_ASSISTANT_PROACTIVE_HELP, true); ChromePreferenceKeys.AUTOFILL_ASSISTANT_PROACTIVE_HELP, true);
boolean proactive_toggle_enabled;
boolean show_disclaimer;
if (ChromeFeatureList.isEnabled(
ChromeFeatureList.AUTOFILL_ASSISTANT_DISABLE_PROACTIVE_HELP_TIED_TO_MSBB)) {
proactive_toggle_enabled = assistant_switch_on_or_missing;
show_disclaimer = false;
} else {
proactive_toggle_enabled =
url_keyed_anonymized_data_collection_enabled && assistant_switch_on_or_missing;
show_disclaimer = !proactive_toggle_enabled && assistant_switch_on_or_missing;
}
mProactiveHelpPreference.setEnabled(proactive_toggle_enabled); mProactiveHelpPreference.setEnabled(proactive_toggle_enabled);
mProactiveHelpPreference.setChecked(proactive_toggle_enabled && proactive_help_on); mProactiveHelpPreference.setChecked(proactive_toggle_enabled && proactive_help_on);
boolean show_disclaimer =
!url_keyed_anonymized_data_collection_enabled && assistant_switch_on_or_missing;
mGoogleServicesSettingsLink.setVisible(show_disclaimer); mGoogleServicesSettingsLink.setVisible(show_disclaimer);
mAssistantVoiceSearchEnabledPref.setChecked(mSharedPreferencesManager.readBoolean( mAssistantVoiceSearchEnabledPref.setChecked(mSharedPreferencesManager.readBoolean(
......
...@@ -143,6 +143,31 @@ public class AutofillAssistantPreferenceFragmentTest { ...@@ -143,6 +143,31 @@ public class AutofillAssistantPreferenceFragmentTest {
Preference syncAndServicesLink = prefs.findPreference( Preference syncAndServicesLink = prefs.findPreference(
AutofillAssistantPreferenceFragment.PREF_GOOGLE_SERVICES_SETTINGS_LINK); AutofillAssistantPreferenceFragment.PREF_GOOGLE_SERVICES_SETTINGS_LINK);
assertNotNull(syncAndServicesLink); assertNotNull(syncAndServicesLink);
assertTrue(syncAndServicesLink.isVisible());
});
}
@Test
@LargeTest
@Feature({"Sync"})
@EnableFeatures({ChromeFeatureList.AUTOFILL_ASSISTANT,
ChromeFeatureList.AUTOFILL_ASSISTANT_DISABLE_PROACTIVE_HELP_TIED_TO_MSBB})
public void
testProactiveHelpNotLinkedToMsbbIfLinkDisabled() {
final AutofillAssistantPreferenceFragment prefs =
startAutofillAssistantPreferenceFragment();
TestThreadUtils.runOnUiThreadBlocking(() -> {
ChromeSwitchPreference proactiveHelpSwitch =
(ChromeSwitchPreference) prefs.findPreference(
AutofillAssistantPreferenceFragment
.PREF_ASSISTANT_PROACTIVE_HELP_SWITCH);
assertTrue(proactiveHelpSwitch.isEnabled());
Preference syncAndServicesLink = prefs.findPreference(
AutofillAssistantPreferenceFragment.PREF_GOOGLE_SERVICES_SETTINGS_LINK);
assertNotNull(syncAndServicesLink);
assertFalse(syncAndServicesLink.isVisible());
}); });
} }
......
...@@ -80,6 +80,8 @@ const base::Feature* kFeaturesExposedToJava[] = { ...@@ -80,6 +80,8 @@ const base::Feature* kFeaturesExposedToJava[] = {
&autofill_assistant::features::kAutofillAssistantChromeEntry, &autofill_assistant::features::kAutofillAssistantChromeEntry,
&autofill_assistant::features::kAutofillAssistantDirectActions, &autofill_assistant::features::kAutofillAssistantDirectActions,
&autofill_assistant::features::kAutofillAssistantProactiveHelp, &autofill_assistant::features::kAutofillAssistantProactiveHelp,
&autofill_assistant::features::
kAutofillAssistantDisableProactiveHelpTiedToMSBB,
&device::kWebAuthPhoneSupport, &device::kWebAuthPhoneSupport,
&download::features::kDownloadAutoResumptionNative, &download::features::kDownloadAutoResumptionNative,
&download::features::kDownloadLater, &download::features::kDownloadLater,
......
...@@ -220,6 +220,8 @@ public abstract class ChromeFeatureList { ...@@ -220,6 +220,8 @@ public abstract class ChromeFeatureList {
public static final String AUTOFILL_ASSISTANT_CHROME_ENTRY = "AutofillAssistantChromeEntry"; public static final String AUTOFILL_ASSISTANT_CHROME_ENTRY = "AutofillAssistantChromeEntry";
public static final String AUTOFILL_ASSISTANT_DIRECT_ACTIONS = "AutofillAssistantDirectActions"; public static final String AUTOFILL_ASSISTANT_DIRECT_ACTIONS = "AutofillAssistantDirectActions";
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 =
"AutofillAssistantDisableProactiveHelpTiedToMSBB";
public static final String AUTOFILL_MANUAL_FALLBACK_ANDROID = "AutofillManualFallbackAndroid"; public static final String AUTOFILL_MANUAL_FALLBACK_ANDROID = "AutofillManualFallbackAndroid";
public static final String AUTOFILL_REFRESH_STYLE_ANDROID = "AutofillRefreshStyleAndroid"; public static final String AUTOFILL_REFRESH_STYLE_ANDROID = "AutofillRefreshStyleAndroid";
public static final String AUTOFILL_KEYBOARD_ACCESSORY = "AutofillKeyboardAccessory"; public static final String AUTOFILL_KEYBOARD_ACCESSORY = "AutofillKeyboardAccessory";
......
...@@ -27,5 +27,13 @@ const base::Feature kAutofillAssistantProactiveHelp{ ...@@ -27,5 +27,13 @@ const base::Feature kAutofillAssistantProactiveHelp{
const base::Feature kAutofillAssistantWithTabHelper{ const base::Feature kAutofillAssistantWithTabHelper{
"AutofillAssistantWithTabHelper", base::FEATURE_DISABLED_BY_DEFAULT}; "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,
// base64-injected trigger scripts can be shown even in the absence of MSBB.
const base::Feature kAutofillAssistantDisableProactiveHelpTiedToMSBB{
"AutofillAssistantDisableProactiveHelpTiedToMSBB",
base::FEATURE_DISABLED_BY_DEFAULT};
} // namespace features } // namespace features
} // namespace autofill_assistant } // namespace autofill_assistant
...@@ -18,6 +18,7 @@ extern const base::Feature kAutofillAssistantChromeEntry; ...@@ -18,6 +18,7 @@ extern const base::Feature kAutofillAssistantChromeEntry;
extern const base::Feature kAutofillAssistantDirectActions; extern const base::Feature kAutofillAssistantDirectActions;
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