Index: chrome/android/java/src/org/chromium/chrome/browser/payments/PaymentRequestImpl.java |
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/payments/PaymentRequestImpl.java b/chrome/android/java/src/org/chromium/chrome/browser/payments/PaymentRequestImpl.java |
index c95cb333cd53b10330986cd01245309e5b0ab2b0..efedc9279891aba2c37ad0754e7035107b21198b 100644 |
--- a/chrome/android/java/src/org/chromium/chrome/browser/payments/PaymentRequestImpl.java |
+++ b/chrome/android/java/src/org/chromium/chrome/browser/payments/PaymentRequestImpl.java |
@@ -12,7 +12,6 @@ |
import org.chromium.base.Callback; |
import org.chromium.base.Log; |
import org.chromium.base.VisibleForTesting; |
-import org.chromium.chrome.R; |
import org.chromium.chrome.browser.autofill.PersonalDataManager; |
import org.chromium.chrome.browser.autofill.PersonalDataManager.AutofillProfile; |
import org.chromium.chrome.browser.favicon.FaviconHelper; |
@@ -23,6 +22,8 @@ |
import org.chromium.chrome.browser.payments.ui.PaymentRequestUI; |
import org.chromium.chrome.browser.payments.ui.SectionInformation; |
import org.chromium.chrome.browser.payments.ui.ShoppingCart; |
+import org.chromium.chrome.browser.preferences.PreferencesLauncher; |
+import org.chromium.chrome.browser.preferences.autofill.AutofillLocalCardEditor; |
import org.chromium.chrome.browser.profiles.Profile; |
import org.chromium.chrome.browser.util.UrlUtilities; |
import org.chromium.components.safejson.JsonSanitizer; |
@@ -68,13 +69,12 @@ |
* Called when an abort request was denied. |
*/ |
void onPaymentRequestServiceUnableToAbort(); |
- |
- /** |
- * Called when the controller is notified of billing address change, but does not alter the |
- * editor UI. |
- */ |
- void onPaymentRequestServiceBillingAddressChangeProcessed(); |
- } |
+ } |
+ |
+ /** |
+ * The size for the favicon in density-independent pixels. |
+ */ |
+ private static final int FAVICON_SIZE_DP = 24; |
private static final String TAG = "cr_PaymentRequest"; |
@@ -126,7 +126,6 @@ |
private SectionInformation mShippingAddressesSection; |
private SectionInformation mContactSection; |
private List<PaymentApp> mPendingApps; |
- private int mFirstCompletePendingInstrument; |
private List<PaymentInstrument> mPendingInstruments; |
private SectionInformation mPaymentMethodsSection; |
private PaymentRequestUI mUI; |
@@ -134,7 +133,6 @@ |
private boolean mMerchantNeedsShippingAddress; |
private boolean mPaymentAppRunning; |
private AddressEditor mAddressEditor; |
- private CardEditor mCardEditor; |
private ContactEditor mContactEditor; |
/** |
@@ -159,9 +157,9 @@ |
mOrigin = UrlUtilities.formatUrlForSecurityDisplay(webContents.getVisibleUrl(), false); |
final FaviconHelper faviconHelper = new FaviconHelper(); |
+ float scale = mContext.getResources().getDisplayMetrics().density; |
faviconHelper.getLocalFaviconImageForURL(Profile.getLastUsedProfile(), |
- webContents.getVisibleUrl(), |
- mContext.getResources().getDimensionPixelSize(R.dimen.payments_favicon_size), |
+ webContents.getVisibleUrl(), (int) (FAVICON_SIZE_DP * scale + 0.5f), |
new FaviconHelper.FaviconImageCallback() { |
@Override |
public void onFaviconAvailable(Bitmap bitmap, String iconUrl) { |
@@ -176,9 +174,6 @@ |
}); |
mApps = PaymentAppFactory.create(webContents); |
- |
- mAddressEditor = new AddressEditor(); |
- mCardEditor = new CardEditor(webContents, mAddressEditor, sObserverForTest); |
} |
/** |
@@ -210,7 +205,7 @@ |
return; |
} |
- mMethodData = getValidatedMethodData(methodData, mCardEditor); |
+ mMethodData = getValidatedMethodData(methodData); |
if (mMethodData == null) { |
disconnectFromClientWithDebugMessage("Invalid payment methods or data"); |
return; |
@@ -247,6 +242,7 @@ |
} |
if (requestShipping) { |
+ mAddressEditor = new AddressEditor(); |
List<AutofillAddress> addresses = new ArrayList<>(); |
for (int i = 0; i < profiles.size(); i++) { |
@@ -321,7 +317,6 @@ |
} |
mPendingApps = new ArrayList<>(mApps); |
- mFirstCompletePendingInstrument = SectionInformation.NO_SELECTION; |
mPendingInstruments = new ArrayList<>(); |
boolean isGettingInstruments = false; |
@@ -347,13 +342,12 @@ |
if (mFavicon != null) mUI.setTitleBitmap(mFavicon); |
mFavicon = null; |
- mAddressEditor.setEditorView(mUI.getEditorView()); |
- mCardEditor.setEditorView(mUI.getCardEditorView()); |
+ if (mAddressEditor != null) mAddressEditor.setEditorView(mUI.getEditorView()); |
if (mContactEditor != null) mContactEditor.setEditorView(mUI.getEditorView()); |
} |
private static HashMap<String, JSONObject> getValidatedMethodData( |
- PaymentMethodData[] methodData, CardEditor paymentMethodsCollector) { |
+ PaymentMethodData[] methodData) { |
// Payment methodData are required. |
if (methodData == null || methodData.length == 0) return null; |
HashMap<String, JSONObject> result = new HashMap<>(); |
@@ -383,8 +377,6 @@ |
if (TextUtils.isEmpty(methods[j])) return null; |
result.put(methods[j], data); |
} |
- |
- paymentMethodsCollector.addAcceptedPaymentMethodsIfRecognized(methods); |
} |
return result; |
} |
@@ -666,15 +658,6 @@ |
} |
} else if (optionType == PaymentRequestUI.TYPE_PAYMENT_METHODS) { |
assert option instanceof PaymentInstrument; |
- if (option instanceof AutofillPaymentInstrument) { |
- AutofillPaymentInstrument card = (AutofillPaymentInstrument) option; |
- |
- if (!card.isComplete()) { |
- editCard(card); |
- return false; |
- } |
- } |
- |
mPaymentMethodsSection.setSelectedItem(option); |
} |
@@ -694,7 +677,8 @@ |
} else if (optionType == PaymentRequestUI.TYPE_CONTACT_DETAILS) { |
editContact(null); |
} else if (optionType == PaymentRequestUI.TYPE_PAYMENT_METHODS) { |
- editCard(null); |
+ PreferencesLauncher.launchSettingsPage( |
+ mContext, AutofillLocalCardEditor.class.getName()); |
} |
return false; |
@@ -740,21 +724,6 @@ |
}); |
} |
- private void editCard(final AutofillPaymentInstrument toEdit) { |
- mCardEditor.edit(toEdit, new Callback<AutofillPaymentInstrument>() { |
- @Override |
- public void onResult(AutofillPaymentInstrument completeCard) { |
- if (completeCard == null) { |
- mPaymentMethodsSection.setSelectedItemIndex(SectionInformation.NO_SELECTION); |
- } else if (toEdit == null) { |
- mPaymentMethodsSection.addAndSelectItem(completeCard); |
- } |
- |
- mUI.updateSection(PaymentRequestUI.TYPE_PAYMENT_METHODS, mPaymentMethodsSection); |
- } |
- }); |
- } |
- |
@Override |
public boolean onPayClicked(PaymentOption selectedShippingAddress, |
PaymentOption selectedShippingOption, PaymentOption selectedPaymentMethod) { |
@@ -828,7 +797,6 @@ |
for (int i = 0; i < instruments.size(); i++) { |
PaymentInstrument instrument = instruments.get(i); |
if (mMethodData.containsKey(instrument.getMethodName())) { |
- checkForCompletePaymentInstrument(instrument, mPendingInstruments.size()); |
mPendingInstruments.add(instrument); |
} else { |
instrument.dismiss(); |
@@ -837,24 +805,11 @@ |
} |
if (mPendingApps.isEmpty()) { |
- mPaymentMethodsSection = new SectionInformation(PaymentRequestUI.TYPE_PAYMENT_METHODS, |
- mFirstCompletePendingInstrument, mPendingInstruments); |
+ mPaymentMethodsSection = new SectionInformation( |
+ PaymentRequestUI.TYPE_PAYMENT_METHODS, 0, mPendingInstruments); |
mPendingInstruments.clear(); |
if (mPaymentInformationCallback != null) providePaymentInformation(); |
- } |
- } |
- |
- private void checkForCompletePaymentInstrument(PaymentInstrument instrument, int index) { |
- boolean isComplete = true; |
- if (instrument instanceof AutofillPaymentInstrument) { |
- AutofillPaymentInstrument autofillInstrument = (AutofillPaymentInstrument) instrument; |
- isComplete = mCardEditor.isCardComplete(autofillInstrument.getCard()); |
- if (isComplete) autofillInstrument.setIsComplete(); |
- } |
- |
- if (isComplete && mFirstCompletePendingInstrument == SectionInformation.NO_SELECTION) { |
- mFirstCompletePendingInstrument = index; |
} |
} |