Commit 46889bc4 authored by Rouslan Solomakhin's avatar Rouslan Solomakhin Committed by Commit Bot

[Payment Request][Android]

Before this patch, the AutofillEnableCompanyName feature controlled
whether the PaymentRequest billing address dropdown showed the
organization name. However, PaymentRequest should always hide the
organization name in the label for the billing address.

This patch adds a boolean to CardEditor.java constructor that allows the
class user to customize whether the billing address dropdown labels
should include the organization name. The boolean is always true for
PaymentRequest, but depends on AutofillEnableCompanyName for the
Autofill Assistant.

After this patch, PaymentRequest always hides the organization name in
the labels of the dropdown for the card billing address.

Bug: 945873
Change-Id: I9273c35b0aaa6349c8d54a1462224738eaf7ca32
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1540090
Commit-Queue: Rouslan Solomakhin <rouslan@chromium.org>
Reviewed-by: default avatarGanggui Tang <gogerald@chromium.org>
Cr-Commit-Position: refs/heads/master@{#644524}
parent 45237b83
......@@ -13,6 +13,7 @@ import android.view.View;
import org.chromium.base.ApiCompatibilityUtils;
import org.chromium.base.Callback;
import org.chromium.chrome.browser.ChromeFeatureList;
import org.chromium.chrome.browser.autofill.PersonalDataManager;
import org.chromium.chrome.browser.autofill.PersonalDataManager.AutofillProfile;
import org.chromium.chrome.browser.payments.AddressEditor;
......@@ -120,7 +121,9 @@ public class AssistantPaymentRequestCoordinator implements AssistantPaymentReque
assert !webContents.isIncognito();
mAddressEditor = new AddressEditor(AddressEditor.Purpose.AUTOFILL_ASSISTANT,
/* saveToDisk= */ !webContents.isIncognito());
mCardEditor = new CardEditor(webContents, mAddressEditor, /* observerForTest= */ null);
mCardEditor = new CardEditor(webContents, mAddressEditor, /* includeOrgLabel= */
ChromeFeatureList.isEnabled(ChromeFeatureList.AUTOFILL_ENABLE_COMPANY_NAME),
/* observerForTest= */ null);
// Only enable 'basic-card' payment method.
PaymentMethodData methodData = new PaymentMethodData();
......
......@@ -12,7 +12,6 @@ import org.chromium.base.VisibleForTesting;
import org.chromium.base.annotations.CalledByNative;
import org.chromium.base.annotations.JNINamespace;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.ChromeFeatureList;
import org.chromium.chrome.browser.ResourceId;
import org.chromium.chrome.browser.preferences.MainPreferences;
import org.chromium.chrome.browser.preferences.Pref;
......@@ -631,12 +630,14 @@ public class PersonalDataManager {
* Gets the profiles to suggest when associating a billing address to a credit card. The
* profiles will have been processed to be more relevant to the user.
*
* @param includeOrganizationInLabel Whether the organization name should be included in the
* label.
*
* @return The list of billing addresses to suggest to the user.
*/
public ArrayList<AutofillProfile> getBillingAddressesToSuggest() {
public ArrayList<AutofillProfile> getBillingAddressesToSuggest(
boolean includeOrganizationInLabel) {
ThreadUtils.assertOnUiThread();
boolean includeOrganizationInLabel =
ChromeFeatureList.isEnabled(ChromeFeatureList.AUTOFILL_ENABLE_COMPANY_NAME);
return getProfilesWithLabels(
nativeGetProfileLabelsToSuggest(mPersonalDataManagerAndroid,
true /* includeNameInLabel */, includeOrganizationInLabel,
......
......@@ -171,9 +171,11 @@ public class CardEditor extends EditorBase<AutofillPaymentInstrument>
* @param webContents The web contents where the web payments API is invoked.
* @param addressEditor Used for verifying billing address completeness and also editing
* billing addresses.
* @param includeOrgLabel Whether the labels in the billing address dropdown should include the
* organization name.
* @param observerForTest Optional observer for test.
*/
public CardEditor(WebContents webContents, AddressEditor addressEditor,
public CardEditor(WebContents webContents, AddressEditor addressEditor, boolean includeOrgLabel,
@Nullable PaymentRequestServiceObserverForTest observerForTest) {
assert webContents != null;
assert addressEditor != null;
......@@ -183,7 +185,7 @@ public class CardEditor extends EditorBase<AutofillPaymentInstrument>
mObserverForTest = observerForTest;
List<AutofillProfile> profiles =
PersonalDataManager.getInstance().getBillingAddressesToSuggest();
PersonalDataManager.getInstance().getBillingAddressesToSuggest(includeOrgLabel);
mProfilesForBillingAddress = new ArrayList<>();
mIncompleteProfilesForBillingAddress = new HashMap<>();
for (int i = 0; i < profiles.size(); i++) {
......
......@@ -368,7 +368,10 @@ public class PaymentRequestImpl
// Do not persist changes on disk in incognito mode.
mAddressEditor = new AddressEditor(
AddressEditor.Purpose.PAYMENT_REQUEST, /*saveToDisk=*/!mIsIncognito);
mCardEditor = new CardEditor(mWebContents, mAddressEditor, sObserverForTest);
// PaymentRequest card editor does not show the organization name in the dropdown with the
// billing address labels.
mCardEditor = new CardEditor(
mWebContents, mAddressEditor, /*includeOrgLabel=*/false, sObserverForTest);
mJourneyLogger = new JourneyLogger(mIsIncognito, mWebContents);
mCurrencyFormatterMap = new HashMap<>();
......
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