Commit b09d0d68 authored by sandromaggi's avatar sandromaggi Committed by Commit Bot

[Autofill Assistant] Adding two new message strings to be set from backend:

* terms requires review
* thirdparty privacy notice

Previously these texts were set from Android resource strings that had
a parameter for the domain. To avoid discrepancies in displaying said
domain, we aim to set it from the backend instead of evaluating
and formatting it on the frontend.

Add UI tests for texts newly being set by model changes (i.e.
from the backend).

Bug: b/142621971
Change-Id: Iffa48f200eeaa26c0c4b47ade4f2ea0dc330da19
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1862685
Commit-Queue: Sandro Maggi <sandromaggi@google.com>
Reviewed-by: default avatarClemens Arbesser <arbesser@google.com>
Cr-Commit-Position: refs/heads/master@{#707734}
parent 59dca747
...@@ -31,6 +31,5 @@ ...@@ -31,6 +31,5 @@
android:layout_marginEnd="@dimen/autofill_assistant_bottombar_horizontal_spacing" android:layout_marginEnd="@dimen/autofill_assistant_bottombar_horizontal_spacing"
android:background="@drawable/autofill_assistant_lightblue_rect_bg" android:background="@drawable/autofill_assistant_lightblue_rect_bg"
android:padding="8dp" android:padding="8dp"
android:text="@string/autofill_assistant_3rd_party_privacy_notice"
android:textAppearance="@style/TextAppearance.AssistantBlackCaption"/> android:textAppearance="@style/TextAppearance.AssistantBlackCaption"/>
</LinearLayout> </LinearLayout>
\ No newline at end of file
...@@ -18,6 +18,7 @@ public class AssistantTagsForTesting { ...@@ -18,6 +18,7 @@ public class AssistantTagsForTesting {
public static final String COLLECT_USER_DATA_SHIPPING_ADDRESS_SECTION_TAG = "shipping"; public static final String COLLECT_USER_DATA_SHIPPING_ADDRESS_SECTION_TAG = "shipping";
public static final String COLLECT_USER_DATA_DATE_RANGE_START_TAG = "date_start"; public static final String COLLECT_USER_DATA_DATE_RANGE_START_TAG = "date_start";
public static final String COLLECT_USER_DATA_DATE_RANGE_END_TAG = "date_end"; public static final String COLLECT_USER_DATA_DATE_RANGE_END_TAG = "date_end";
public static final String COLLECT_USER_DATA_TERMS_SECTION_TAG = "terms";
public static final String COLLECT_USER_DATA_TERMS_REQUIRE_REVIEW = "require_review"; public static final String COLLECT_USER_DATA_TERMS_REQUIRE_REVIEW = "require_review";
public static final String VERTICAL_EXPANDER_CHEVRON = "chevron"; public static final String VERTICAL_EXPANDER_CHEVRON = "chevron";
public static final String COLLECT_USER_DATA_CHOICE_LIST = "choicelist"; public static final String COLLECT_USER_DATA_CHOICE_LIST = "choicelist";
......
...@@ -19,7 +19,6 @@ import org.chromium.chrome.browser.payments.CardEditor; ...@@ -19,7 +19,6 @@ import org.chromium.chrome.browser.payments.CardEditor;
import org.chromium.chrome.browser.payments.ContactEditor; import org.chromium.chrome.browser.payments.ContactEditor;
import org.chromium.chrome.browser.payments.PaymentInstrument; import org.chromium.chrome.browser.payments.PaymentInstrument;
import org.chromium.chrome.browser.widget.prefeditor.EditorDialog; import org.chromium.chrome.browser.widget.prefeditor.EditorDialog;
import org.chromium.components.url_formatter.UrlFormatter;
import org.chromium.content_public.browser.WebContents; import org.chromium.content_public.browser.WebContents;
import org.chromium.payments.mojom.PaymentMethodData; import org.chromium.payments.mojom.PaymentMethodData;
import org.chromium.ui.modelutil.PropertyKey; import org.chromium.ui.modelutil.PropertyKey;
...@@ -329,6 +328,24 @@ class AssistantCollectUserDataBinder ...@@ -329,6 +328,24 @@ class AssistantCollectUserDataBinder
view.mAppendedSections.setSections( view.mAppendedSections.setSections(
model.get(AssistantCollectUserDataModel.APPENDED_SECTIONS)); model.get(AssistantCollectUserDataModel.APPENDED_SECTIONS));
return true; return true;
} else if (propertyKey == AssistantCollectUserDataModel.ACCEPT_TERMS_AND_CONDITIONS_TEXT) {
view.mTermsSection.setAcceptTermsAndConditionsText(
model.get(AssistantCollectUserDataModel.ACCEPT_TERMS_AND_CONDITIONS_TEXT));
view.mTermsAsCheckboxSection.setAcceptTermsAndConditionsText(
model.get(AssistantCollectUserDataModel.ACCEPT_TERMS_AND_CONDITIONS_TEXT));
return true;
} else if (propertyKey == AssistantCollectUserDataModel.TERMS_REQUIRE_REVIEW_TEXT) {
view.mTermsSection.setTermsRequireReviewText(
model.get(AssistantCollectUserDataModel.TERMS_REQUIRE_REVIEW_TEXT));
view.mTermsAsCheckboxSection.setTermsRequireReviewText(
model.get(AssistantCollectUserDataModel.TERMS_REQUIRE_REVIEW_TEXT));
return true;
} else if (propertyKey == AssistantCollectUserDataModel.THIRDPARTY_PRIVACY_NOTICE_TEXT) {
view.mTermsSection.setThirdPartyPrivacyNoticeText(
model.get(AssistantCollectUserDataModel.THIRDPARTY_PRIVACY_NOTICE_TEXT));
view.mTermsAsCheckboxSection.setThirdPartyPrivacyNoticeText(
model.get(AssistantCollectUserDataModel.THIRDPARTY_PRIVACY_NOTICE_TEXT));
return true;
} }
return false; return false;
...@@ -353,12 +370,6 @@ class AssistantCollectUserDataBinder ...@@ -353,12 +370,6 @@ class AssistantCollectUserDataBinder
view.mPaymentMethodSection.setVisible( view.mPaymentMethodSection.setVisible(
(model.get(AssistantCollectUserDataModel.REQUEST_PAYMENT))); (model.get(AssistantCollectUserDataModel.REQUEST_PAYMENT)));
return true; return true;
} else if (propertyKey == AssistantCollectUserDataModel.ACCEPT_TERMS_AND_CONDITIONS_TEXT) {
view.mTermsSection.setAcceptTermsAndConditionsText(
model.get(AssistantCollectUserDataModel.ACCEPT_TERMS_AND_CONDITIONS_TEXT));
view.mTermsAsCheckboxSection.setAcceptTermsAndConditionsText(
model.get(AssistantCollectUserDataModel.ACCEPT_TERMS_AND_CONDITIONS_TEXT));
return true;
} else if (propertyKey == AssistantCollectUserDataModel.SHOW_TERMS_AS_CHECKBOX) { } else if (propertyKey == AssistantCollectUserDataModel.SHOW_TERMS_AS_CHECKBOX) {
if (model.get(AssistantCollectUserDataModel.SHOW_TERMS_AS_CHECKBOX)) { if (model.get(AssistantCollectUserDataModel.SHOW_TERMS_AS_CHECKBOX)) {
view.mTermsSection.getView().setVisibility(View.GONE); view.mTermsSection.getView().setVisibility(View.GONE);
...@@ -397,13 +408,7 @@ class AssistantCollectUserDataBinder ...@@ -397,13 +408,7 @@ class AssistantCollectUserDataBinder
// Update available profiles and credit cards before PR is made visible. // Update available profiles and credit cards before PR is made visible.
updateAvailableProfiles(model, view); updateAvailableProfiles(model, view);
updateAvailablePaymentMethods(model); updateAvailablePaymentMethods(model);
WebContents webContents = model.get(AssistantCollectUserDataModel.WEB_CONTENTS);
if (webContents != null) {
String origin = UrlFormatter.formatUrlForSecurityDisplayOmitScheme(
webContents.getLastCommittedUrl());
view.mTermsSection.setOrigin(origin);
view.mTermsAsCheckboxSection.setOrigin(origin);
}
view.startListenToPersonalDataManager(() -> { view.startListenToPersonalDataManager(() -> {
AssistantCollectUserDataBinder.this.updateAvailableProfiles(model, view); AssistantCollectUserDataBinder.this.updateAvailableProfiles(model, view);
AssistantCollectUserDataBinder.this.updateAvailablePaymentMethods(model); AssistantCollectUserDataBinder.this.updateAvailablePaymentMethods(model);
......
...@@ -119,6 +119,7 @@ public class AssistantCollectUserDataCoordinator { ...@@ -119,6 +119,7 @@ public class AssistantCollectUserDataCoordinator {
AssistantTagsForTesting.COLLECT_USER_DATA_PAYMENT_METHOD_SECTION_TAG); AssistantTagsForTesting.COLLECT_USER_DATA_PAYMENT_METHOD_SECTION_TAG);
shippingAddressSection.getView().setTag( shippingAddressSection.getView().setTag(
AssistantTagsForTesting.COLLECT_USER_DATA_SHIPPING_ADDRESS_SECTION_TAG); AssistantTagsForTesting.COLLECT_USER_DATA_SHIPPING_ADDRESS_SECTION_TAG);
termsSection.getView().setTag(AssistantTagsForTesting.COLLECT_USER_DATA_TERMS_SECTION_TAG);
// Bind view and mediator through the model. // Bind view and mediator through the model.
mViewHolder = new AssistantCollectUserDataBinder.ViewHolder(mPaymentRequestUI, mViewHolder = new AssistantCollectUserDataBinder.ViewHolder(mPaymentRequestUI,
......
...@@ -130,6 +130,12 @@ public class AssistantCollectUserDataModel extends PropertyModel { ...@@ -130,6 +130,12 @@ public class AssistantCollectUserDataModel extends PropertyModel {
public static final WritableObjectPropertyKey<List<AssistantAdditionalSectionFactory>> public static final WritableObjectPropertyKey<List<AssistantAdditionalSectionFactory>>
APPENDED_SECTIONS = new WritableObjectPropertyKey<>(); APPENDED_SECTIONS = new WritableObjectPropertyKey<>();
public static final WritableObjectPropertyKey<String> TERMS_REQUIRE_REVIEW_TEXT =
new WritableObjectPropertyKey<>();
public static final WritableObjectPropertyKey<String> THIRDPARTY_PRIVACY_NOTICE_TEXT =
new WritableObjectPropertyKey<>();
public AssistantCollectUserDataModel() { public AssistantCollectUserDataModel() {
super(DELEGATE, WEB_CONTENTS, VISIBLE, SHIPPING_ADDRESS, PAYMENT_METHOD, CONTACT_DETAILS, super(DELEGATE, WEB_CONTENTS, VISIBLE, SHIPPING_ADDRESS, PAYMENT_METHOD, CONTACT_DETAILS,
LOGIN_SECTION_TITLE, SELECTED_LOGIN, TERMS_STATUS, DEFAULT_EMAIL, REQUEST_NAME, LOGIN_SECTION_TITLE, SELECTED_LOGIN, TERMS_STATUS, DEFAULT_EMAIL, REQUEST_NAME,
...@@ -139,7 +145,8 @@ public class AssistantCollectUserDataModel extends PropertyModel { ...@@ -139,7 +145,8 @@ public class AssistantCollectUserDataModel extends PropertyModel {
SUPPORTED_BASIC_CARD_NETWORKS, SUPPORTED_PAYMENT_METHODS, AVAILABLE_LOGINS, SUPPORTED_BASIC_CARD_NETWORKS, SUPPORTED_PAYMENT_METHODS, AVAILABLE_LOGINS,
EXPANDED_SECTION, REQUIRE_BILLING_POSTAL_CODE, BILLING_POSTAL_CODE_MISSING_TEXT, EXPANDED_SECTION, REQUIRE_BILLING_POSTAL_CODE, BILLING_POSTAL_CODE_MISSING_TEXT,
REQUEST_DATE_RANGE, DATE_RANGE_START, DATE_RANGE_START_LABEL, DATE_RANGE_END, REQUEST_DATE_RANGE, DATE_RANGE_START, DATE_RANGE_START_LABEL, DATE_RANGE_END,
DATE_RANGE_END_LABEL, PREPENDED_SECTIONS, APPENDED_SECTIONS); DATE_RANGE_END_LABEL, PREPENDED_SECTIONS, APPENDED_SECTIONS,
TERMS_REQUIRE_REVIEW_TEXT, THIRDPARTY_PRIVACY_NOTICE_TEXT);
/** /**
* Set initial state for basic type properties (others are implicitly null). * Set initial state for basic type properties (others are implicitly null).
...@@ -339,4 +346,14 @@ public class AssistantCollectUserDataModel extends PropertyModel { ...@@ -339,4 +346,14 @@ public class AssistantCollectUserDataModel extends PropertyModel {
private void setAppendedSections(List<AssistantAdditionalSectionFactory> sections) { private void setAppendedSections(List<AssistantAdditionalSectionFactory> sections) {
set(APPENDED_SECTIONS, sections); set(APPENDED_SECTIONS, sections);
} }
@CalledByNative
private void setTermsRequireReviewText(String text) {
set(TERMS_REQUIRE_REVIEW_TEXT, text);
}
@CalledByNative
private void setThirdPartyPrivacyNoticeText(String text) {
set(THIRDPARTY_PRIVACY_NOTICE_TEXT, text);
}
} }
...@@ -33,14 +33,11 @@ public class AssistantTermsSection { ...@@ -33,14 +33,11 @@ public class AssistantTermsSection {
private final AssistantChoiceList mTermsList; private final AssistantChoiceList mTermsList;
private final TextView mTermsAgree; private final TextView mTermsAgree;
@Nullable @Nullable
private final TextView mTermsRequiresReview; private final TextView mTermsRequireReview;
private final TextView mThirdPartyPrivacyNotice; private final TextView mThirdPartyPrivacyNotice;
@Nullable @Nullable
private Delegate mDelegate; private Delegate mDelegate;
private String mOrigin = "";
private String mAcceptTermsText = "";
AssistantTermsSection(Context context, ViewGroup parent, boolean showAsSingleCheckbox) { AssistantTermsSection(Context context, ViewGroup parent, boolean showAsSingleCheckbox) {
mView = LayoutInflater.from(context).inflate( mView = LayoutInflater.from(context).inflate(
R.layout.autofill_assistant_payment_request_terms_and_conditions, parent, false); R.layout.autofill_assistant_payment_request_terms_and_conditions, parent, false);
...@@ -55,7 +52,7 @@ public class AssistantTermsSection { ...@@ -55,7 +52,7 @@ public class AssistantTermsSection {
mTermsAgree = new TextView(context); mTermsAgree = new TextView(context);
ApiCompatibilityUtils.setTextAppearance(mTermsAgree, R.style.TextAppearance_BlackCaption); ApiCompatibilityUtils.setTextAppearance(mTermsAgree, R.style.TextAppearance_BlackCaption);
mTermsAgree.setGravity(Gravity.CENTER_VERTICAL); mTermsAgree.setGravity(Gravity.CENTER_VERTICAL);
mTermsList.addItem(mTermsAgree, /*hasEditButton=*/false, selected -> { mTermsList.addItem(mTermsAgree, /* hasEditButton= */ false, selected -> {
if (selected) { if (selected) {
if (mDelegate != null) { if (mDelegate != null) {
mDelegate.onStateChanged(AssistantTermsAndConditionsState.ACCEPTED); mDelegate.onStateChanged(AssistantTermsAndConditionsState.ACCEPTED);
...@@ -63,48 +60,28 @@ public class AssistantTermsSection { ...@@ -63,48 +60,28 @@ public class AssistantTermsSection {
} else if (showAsSingleCheckbox && mDelegate != null) { } else if (showAsSingleCheckbox && mDelegate != null) {
mDelegate.onStateChanged(AssistantTermsAndConditionsState.NOT_SELECTED); mDelegate.onStateChanged(AssistantTermsAndConditionsState.NOT_SELECTED);
} }
}, /* itemEditedListener=*/null); }, /* itemEditedListener= */ null);
if (showAsSingleCheckbox) { if (showAsSingleCheckbox) {
mTermsRequiresReview = null; mTermsRequireReview = null;
} else { } else {
mTermsRequiresReview = new TextView(context); mTermsRequireReview = new TextView(context);
ApiCompatibilityUtils.setTextAppearance( ApiCompatibilityUtils.setTextAppearance(
mTermsRequiresReview, R.style.TextAppearance_BlackCaption); mTermsRequireReview, R.style.TextAppearance_BlackCaption);
mTermsRequiresReview.setGravity(Gravity.CENTER_VERTICAL); mTermsRequireReview.setGravity(Gravity.CENTER_VERTICAL);
mTermsRequiresReview.setTag( mTermsRequireReview.setTag(
AssistantTagsForTesting.COLLECT_USER_DATA_TERMS_REQUIRE_REVIEW); AssistantTagsForTesting.COLLECT_USER_DATA_TERMS_REQUIRE_REVIEW);
mTermsList.addItem(mTermsRequiresReview, /*hasEditButton=*/false, selected -> { mTermsList.addItem(mTermsRequireReview, /* hasEditButton= */ false, selected -> {
if (selected && mDelegate != null) { if (selected && mDelegate != null) {
mDelegate.onStateChanged(AssistantTermsAndConditionsState.REQUIRES_REVIEW); mDelegate.onStateChanged(AssistantTermsAndConditionsState.REQUIRES_REVIEW);
} }
}, /* itemEditedListener=*/null); }, /* itemEditedListener= */ null);
} }
mThirdPartyPrivacyNotice = mThirdPartyPrivacyNotice =
mView.findViewById(R.id.payment_request_3rd_party_privacy_notice); mView.findViewById(R.id.payment_request_3rd_party_privacy_notice);
} }
public void setOrigin(String origin) {
mOrigin = origin;
setAcceptTermsText();
Context context = mView.getContext();
if (mTermsRequiresReview != null) {
AssistantTextUtils.applyVisualAppearanceTags(mTermsRequiresReview,
context.getString(R.string.autofill_assistant_3rd_party_terms_review, origin),
/* linkCallback= */ null);
}
AssistantTextUtils.applyVisualAppearanceTags(mThirdPartyPrivacyNotice,
context.getString(R.string.autofill_assistant_3rd_party_privacy_notice, origin),
/* linkCallback= */ null);
}
private void setAcceptTermsText() {
AssistantTextUtils.applyVisualAppearanceTags(mTermsAgree,
String.format(mAcceptTermsText, mOrigin), this::onTermsAndConditionsLinkClicked);
}
private void onTermsAndConditionsLinkClicked(int link) { private void onTermsAndConditionsLinkClicked(int link) {
if (mDelegate != null) { if (mDelegate != null) {
mDelegate.onLinkClicked(link); mDelegate.onLinkClicked(link);
...@@ -120,8 +97,8 @@ public class AssistantTermsSection { ...@@ -120,8 +97,8 @@ public class AssistantTermsSection {
mTermsList.setCheckedItem(mTermsAgree); mTermsList.setCheckedItem(mTermsAgree);
break; break;
case AssistantTermsAndConditionsState.REQUIRES_REVIEW: case AssistantTermsAndConditionsState.REQUIRES_REVIEW:
if (mTermsRequiresReview != null) { if (mTermsRequireReview != null) {
mTermsList.setCheckedItem(mTermsRequiresReview); mTermsList.setCheckedItem(mTermsRequireReview);
} }
break; break;
} }
...@@ -141,11 +118,23 @@ public class AssistantTermsSection { ...@@ -141,11 +118,23 @@ public class AssistantTermsSection {
mTermsList.setVisibility(View.GONE); mTermsList.setVisibility(View.GONE);
} else { } else {
mTermsList.setVisibility(View.VISIBLE); mTermsList.setVisibility(View.VISIBLE);
mAcceptTermsText = text; AssistantTextUtils.applyVisualAppearanceTags(
setAcceptTermsText(); mTermsAgree, text, this::onTermsAndConditionsLinkClicked);
}
}
void setTermsRequireReviewText(String text) {
if (mTermsRequireReview != null) {
AssistantTextUtils.applyVisualAppearanceTags(
mTermsRequireReview, text, /* linkCallback= */ null);
} }
} }
void setThirdPartyPrivacyNoticeText(String text) {
AssistantTextUtils.applyVisualAppearanceTags(
mThirdPartyPrivacyNotice, text, /* linkCallback= */ null);
}
View getView() { View getView() {
return mView; return mView;
} }
......
...@@ -124,12 +124,6 @@ ...@@ -124,12 +124,6 @@
<message name="IDS_AUTOFILL_ASSISTANT_GOOGLE_TERMS_URL" desc="URL for Google Autofill Assistant Terms of Service" translateable="false"> <message name="IDS_AUTOFILL_ASSISTANT_GOOGLE_TERMS_URL" desc="URL for Google Autofill Assistant Terms of Service" translateable="false">
http://support.google.com/assistant?p=fast_checkout http://support.google.com/assistant?p=fast_checkout
</message> </message>
<message name="IDS_AUTOFILL_ASSISTANT_3RD_PARTY_TERMS_REVIEW" desc="Message that indicates that the user wants to review the terms and conditions of a 3rd party's domain, e.g., 'odeon.co.uk'.">
Read and agree to the terms &amp; conditions on <ph name="BEGIN_BOLD">&lt;b&gt;</ph><ph name="DOMAIN">%1$s<ex>google.com</ex></ph><ph name="END_BOLD">&lt;/b&gt;</ph> later
</message>
<message name="IDS_AUTOFILL_ASSISTANT_3RD_PARTY_PRIVACY_NOTICE" desc="Privacy notice telling users that autofill assistant will send personal data to a third party’s website.">
Chrome will send personal data you selected to <ph name="BEGIN_BOLD">&lt;b&gt;</ph><ph name="DOMAIN">%1$s<ex>google.com</ex></ph><ph name="END_BOLD">&lt;/b&gt;</ph>
</message>
<message name="IDS_AUTOFILL_ASSISTANT_GIVE_UP" <message name="IDS_AUTOFILL_ASSISTANT_GIVE_UP"
desc="Text label that is shown when autofill assistant cannot help anymore, because of a user action." desc="Text label that is shown when autofill assistant cannot help anymore, because of a user action."
internal_comment="TODO(wnwen): Remove duplication in components/autofill_assistant_strings.grdp"> internal_comment="TODO(wnwen): Remove duplication in components/autofill_assistant_strings.grdp">
......
...@@ -9,6 +9,7 @@ import static org.chromium.chrome.browser.autofill_assistant.AutofillAssistantUi ...@@ -9,6 +9,7 @@ import static org.chromium.chrome.browser.autofill_assistant.AutofillAssistantUi
import static org.chromium.chrome.browser.autofill_assistant.user_data.AssistantCollectUserDataCoordinator.DIVIDER_TAG; import static org.chromium.chrome.browser.autofill_assistant.user_data.AssistantCollectUserDataCoordinator.DIVIDER_TAG;
import android.view.View; import android.view.View;
import android.widget.LinearLayout;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
...@@ -51,6 +52,7 @@ public class AutofillAssistantCollectUserDataTestHelper { ...@@ -51,6 +52,7 @@ public class AutofillAssistantCollectUserDataTestHelper {
final AssistantVerticalExpander mLoginsSection; final AssistantVerticalExpander mLoginsSection;
final AssistantVerticalExpander mDateRangeStartSection; final AssistantVerticalExpander mDateRangeStartSection;
final AssistantVerticalExpander mDateRangeEndSection; final AssistantVerticalExpander mDateRangeEndSection;
final LinearLayout mTermsSection;
final AssistantChoiceList mContactList; final AssistantChoiceList mContactList;
final AssistantChoiceList mPaymentMethodList; final AssistantChoiceList mPaymentMethodList;
final AssistantChoiceList mShippingAddressList; final AssistantChoiceList mShippingAddressList;
...@@ -72,6 +74,8 @@ public class AutofillAssistantCollectUserDataTestHelper { ...@@ -72,6 +74,8 @@ public class AutofillAssistantCollectUserDataTestHelper {
AssistantTagsForTesting.COLLECT_USER_DATA_DATE_RANGE_START_TAG); AssistantTagsForTesting.COLLECT_USER_DATA_DATE_RANGE_START_TAG);
mDateRangeEndSection = coordinator.getView().findViewWithTag( mDateRangeEndSection = coordinator.getView().findViewWithTag(
AssistantTagsForTesting.COLLECT_USER_DATA_DATE_RANGE_END_TAG); AssistantTagsForTesting.COLLECT_USER_DATA_DATE_RANGE_END_TAG);
mTermsSection = coordinator.getView().findViewWithTag(
AssistantTagsForTesting.COLLECT_USER_DATA_TERMS_SECTION_TAG);
mDividers = findViewsWithTag(coordinator.getView(), DIVIDER_TAG); mDividers = findViewsWithTag(coordinator.getView(), DIVIDER_TAG);
mContactList = (AssistantChoiceList) (findViewsWithTag( mContactList = (AssistantChoiceList) (findViewsWithTag(
mContactSection, COLLECT_USER_DATA_CHOICE_LIST) mContactSection, COLLECT_USER_DATA_CHOICE_LIST)
......
...@@ -35,6 +35,7 @@ import static org.chromium.chrome.browser.autofill_assistant.AssistantTagsForTes ...@@ -35,6 +35,7 @@ import static org.chromium.chrome.browser.autofill_assistant.AssistantTagsForTes
import android.support.test.filters.MediumTest; import android.support.test.filters.MediumTest;
import android.view.View; import android.view.View;
import android.widget.TextView;
import org.hamcrest.Matcher; import org.hamcrest.Matcher;
import org.junit.Before; import org.junit.Before;
...@@ -636,9 +637,6 @@ public class AutofillAssistantCollectUserDataUiTest { ...@@ -636,9 +637,6 @@ public class AutofillAssistantCollectUserDataUiTest {
acceptTermsText); acceptTermsText);
model.set(AssistantCollectUserDataModel.SHOW_TERMS_AS_CHECKBOX, false); model.set(AssistantCollectUserDataModel.SHOW_TERMS_AS_CHECKBOX, false);
model.set(AssistantCollectUserDataModel.DELEGATE, delegate); model.set(AssistantCollectUserDataModel.DELEGATE, delegate);
// Setting web contents will set the origin and the decline terms text.
model.set(AssistantCollectUserDataModel.WEB_CONTENTS, mTestRule.getWebContents());
model.set(AssistantCollectUserDataModel.VISIBLE, true); model.set(AssistantCollectUserDataModel.VISIBLE, true);
}); });
...@@ -688,6 +686,46 @@ public class AutofillAssistantCollectUserDataUiTest { ...@@ -688,6 +686,46 @@ public class AutofillAssistantCollectUserDataUiTest {
assertThat(delegate.mLastLinkClicked, is(42)); assertThat(delegate.mLastLinkClicked, is(42));
} }
@Test
@MediumTest
public void testTermsRequireReview() throws Exception {
AssistantCollectUserDataModel model = new AssistantCollectUserDataModel();
createCollectUserDataCoordinator(model);
// Setting a text from "backend".
TestThreadUtils.runOnUiThreadBlocking(() -> {
model.set(AssistantCollectUserDataModel.TERMS_REQUIRE_REVIEW_TEXT, "Check terms");
model.set(AssistantCollectUserDataModel.SHOW_TERMS_AS_CHECKBOX, false);
model.set(AssistantCollectUserDataModel.VISIBLE, true);
});
onView(withTagValue(is(COLLECT_USER_DATA_TERMS_REQUIRE_REVIEW)))
.check(matches(allOf(withText("Check terms"), isDisplayed())));
}
@Test
@MediumTest
public void testThirdpartyPrivacyNotice() throws Exception {
AssistantCollectUserDataModel model = new AssistantCollectUserDataModel();
AssistantCollectUserDataCoordinator coordinator = createCollectUserDataCoordinator(model);
AutofillAssistantCollectUserDataTestHelper
.ViewHolder viewHolder = TestThreadUtils.runOnUiThreadBlocking(
() -> new AutofillAssistantCollectUserDataTestHelper.ViewHolder(coordinator));
TextView privacyNotice = viewHolder.mTermsSection.findViewById(
R.id.payment_request_3rd_party_privacy_notice);
// Setting a text from "backend".
TestThreadUtils.runOnUiThreadBlocking(() -> {
model.set(AssistantCollectUserDataModel.THIRDPARTY_PRIVACY_NOTICE_TEXT,
"Thirdparty privacy notice");
model.set(AssistantCollectUserDataModel.VISIBLE, true);
});
onView(is(privacyNotice))
.check(matches(allOf(withText("Thirdparty privacy notice"), isDisplayed())));
}
/** /**
* Test that if the billing address does not have a postal code and the postal code is required, * Test that if the billing address does not have a postal code and the postal code is required,
* an error message is displayed. * an error message is displayed.
......
...@@ -881,6 +881,14 @@ void UiControllerAndroid::OnCollectUserDataOptionsChanged( ...@@ -881,6 +881,14 @@ void UiControllerAndroid::OnCollectUserDataOptionsChanged(
base::android::ConvertUTF8ToJavaString( base::android::ConvertUTF8ToJavaString(
env, collect_user_data_options->date_time_range.end_label())); env, collect_user_data_options->date_time_range.end_label()));
} }
Java_AssistantCollectUserDataModel_setTermsRequireReviewText(
env, jmodel,
base::android::ConvertUTF8ToJavaString(
env, collect_user_data_options->terms_require_review_text));
Java_AssistantCollectUserDataModel_setThirdPartyPrivacyNoticeText(
env, jmodel,
base::android::ConvertUTF8ToJavaString(
env, collect_user_data_options->thirdparty_privacy_notice_text));
Java_AssistantCollectUserDataModel_setPrependedSections( Java_AssistantCollectUserDataModel_setPrependedSections(
env, jmodel, env, jmodel,
......
...@@ -650,14 +650,26 @@ CollectUserDataAction::CreateOptionsFromProto() { ...@@ -650,14 +650,26 @@ CollectUserDataAction::CreateOptionsFromProto() {
if (collect_user_data.request_terms_and_conditions()) { if (collect_user_data.request_terms_and_conditions()) {
collect_user_data_options->show_terms_as_checkbox = collect_user_data_options->show_terms_as_checkbox =
collect_user_data.show_terms_as_checkbox(); collect_user_data.show_terms_as_checkbox();
if (collect_user_data.accept_terms_and_conditions_text().empty()) {
return nullptr;
}
collect_user_data_options->accept_terms_and_conditions_text = collect_user_data_options->accept_terms_and_conditions_text =
collect_user_data.accept_terms_and_conditions_text(); collect_user_data.accept_terms_and_conditions_text();
if (collect_user_data_options->accept_terms_and_conditions_text.empty()) {
collect_user_data_options->accept_terms_and_conditions_text = if (!collect_user_data.show_terms_as_checkbox() &&
l10n_util::GetStringUTF8( collect_user_data.terms_require_review_text().empty()) {
IDS_AUTOFILL_ASSISTANT_3RD_PARTY_TERMS_ACCEPT); return nullptr;
} }
collect_user_data_options->terms_require_review_text =
collect_user_data.terms_require_review_text();
}
if (collect_user_data.thirdparty_privacy_notice_text().empty()) {
return nullptr;
} }
collect_user_data_options->thirdparty_privacy_notice_text =
collect_user_data.thirdparty_privacy_notice_text();
collect_user_data_options->default_email = collect_user_data_options->default_email =
delegate_->GetAccountEmailAddress(); delegate_->GetAccountEmailAddress();
......
...@@ -1252,6 +1252,7 @@ message UserFormSectionProto { ...@@ -1252,6 +1252,7 @@ message UserFormSectionProto {
// Asks to provide the data used by UseAddressAction and // Asks to provide the data used by UseAddressAction and
// UseCreditCardAction. // UseCreditCardAction.
// Next: 22
message CollectUserDataProto { message CollectUserDataProto {
enum TermsAndConditionsState { enum TermsAndConditionsState {
// No choice has been made yet. // No choice has been made yet.
...@@ -1294,6 +1295,12 @@ message CollectUserDataProto { ...@@ -1294,6 +1295,12 @@ message CollectUserDataProto {
// that will finish this action and return the clicked link in the action // that will finish this action and return the clicked link in the action
// result. // result.
optional string accept_terms_and_conditions_text = 13; optional string accept_terms_and_conditions_text = 13;
// Message that indicates that the user wants to review the terms and
// conditions of a 3rd party's domain, e.g., 'example.com'.
optional string terms_require_review_text = 20;
// Privacy notice telling users that autofill assistant will send personal
// data to a third party’s website.
optional string thirdparty_privacy_notice_text = 21;
// Optionally allows confiriming through the given direct actions. // Optionally allows confiriming through the given direct actions.
optional DirectActionProto confirm_direct_action = 10; optional DirectActionProto confirm_direct_action = 10;
// Additional actions available to the user. This can be used for instance to // Additional actions available to the user. This can be used for instance to
......
...@@ -86,6 +86,8 @@ struct CollectUserDataOptions { ...@@ -86,6 +86,8 @@ struct CollectUserDataOptions {
// If empty, terms and conditions should not be shown. // If empty, terms and conditions should not be shown.
std::string accept_terms_and_conditions_text; std::string accept_terms_and_conditions_text;
std::string terms_require_review_text;
std::string thirdparty_privacy_notice_text;
bool show_terms_as_checkbox = false; bool show_terms_as_checkbox = false;
std::vector<std::string> supported_basic_card_networks; std::vector<std::string> supported_basic_card_networks;
......
...@@ -27,8 +27,5 @@ ...@@ -27,8 +27,5 @@
<message name="IDS_AUTOFILL_ASSISTANT_STOPPED" desc="Text label that is shown when stopping the Autofill Assistant."> <message name="IDS_AUTOFILL_ASSISTANT_STOPPED" desc="Text label that is shown when stopping the Autofill Assistant.">
Google Assistant in Chrome stopping Google Assistant in Chrome stopping
</message> </message>
<message name="IDS_AUTOFILL_ASSISTANT_3RD_PARTY_TERMS_ACCEPT" desc="Message that indicates that the user agrees to the terms and conditions of a 3rd party's domain, e.g., 'odeon.co.uk'.">
I agree to the terms &amp; conditions, privacy policy, and right of withdrawal of <ph name="BEGIN_BOLD">&lt;b&gt;</ph><ph name="DOMAIN">%1$s<ex>google.com</ex></ph><ph name="END_BOLD">&lt;/b&gt;</ph>
</message>
</if> </if>
</grit-part> </grit-part>
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