Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(122)

Side by Side Diff: chrome/android/java/src/org/chromium/chrome/browser/payments/PaymentRequestImpl.java

Issue 2368073002: PaymentRequest: Add payer name field to payer info editor. (android) (Closed)
Patch Set: PaymentRequest: Add payer name field to payer info editor. (android) Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.chrome.browser.payments; 5 package org.chromium.chrome.browser.payments;
6 6
7 import android.app.Activity; 7 import android.app.Activity;
8 import android.graphics.Bitmap; 8 import android.graphics.Bitmap;
9 import android.os.Handler; 9 import android.os.Handler;
10 import android.text.TextUtils; 10 import android.text.TextUtils;
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 recordAbortReasonHistogram( 264 recordAbortReasonHistogram(
265 PaymentRequestMetrics.ABORT_REASON_INVALID_DATA_FROM_RENDERE R); 265 PaymentRequestMetrics.ABORT_REASON_INVALID_DATA_FROM_RENDERE R);
266 return; 266 return;
267 } 267 }
268 268
269 if (!parseAndValidateDetailsOrDisconnectFromClient(details)) return; 269 if (!parseAndValidateDetailsOrDisconnectFromClient(details)) return;
270 270
271 getMatchingPaymentInstruments(); 271 getMatchingPaymentInstruments();
272 272
273 boolean requestShipping = options != null && options.requestShipping; 273 boolean requestShipping = options != null && options.requestShipping;
274 boolean requestPayerName = options != null && options.requestPayerName;
274 boolean requestPayerPhone = options != null && options.requestPayerPhone ; 275 boolean requestPayerPhone = options != null && options.requestPayerPhone ;
275 boolean requestPayerEmail = options != null && options.requestPayerEmail ; 276 boolean requestPayerEmail = options != null && options.requestPayerEmail ;
276 277
277 List<AutofillProfile> profiles = null; 278 List<AutofillProfile> profiles = null;
278 if (requestShipping || requestPayerPhone || requestPayerEmail) { 279 if (requestShipping || requestPayerName || requestPayerPhone || requestP ayerEmail) {
279 profiles = PersonalDataManager.getInstance().getProfilesToSuggest( 280 profiles = PersonalDataManager.getInstance().getProfilesToSuggest(
280 false /* includeNameInLabel */); 281 false /* includeNameInLabel */);
281 } 282 }
282 283
283 if (requestShipping) { 284 if (requestShipping) {
284 List<AutofillAddress> addresses = new ArrayList<>(); 285 List<AutofillAddress> addresses = new ArrayList<>();
285 286
286 for (int i = 0; i < profiles.size(); i++) { 287 for (int i = 0; i < profiles.size(); i++) {
287 AutofillProfile profile = profiles.get(i); 288 AutofillProfile profile = profiles.get(i);
288 mAddressEditor.addPhoneNumberIfValid(profile.getPhoneNumber()); 289 mAddressEditor.addPhoneNumberIfValid(profile.getPhoneNumber());
(...skipping 28 matching lines...) Expand all
317 if (mUiShippingOptions.getSelectedItem() != null && !addresses.isEmp ty() 318 if (mUiShippingOptions.getSelectedItem() != null && !addresses.isEmp ty()
318 && addresses.get(0).isComplete()) { 319 && addresses.get(0).isComplete()) {
319 firstCompleteAddressIndex = 0; 320 firstCompleteAddressIndex = 0;
320 } 321 }
321 322
322 mShippingAddressesSection = 323 mShippingAddressesSection =
323 new SectionInformation(PaymentRequestUI.TYPE_SHIPPING_ADDRES SES, 324 new SectionInformation(PaymentRequestUI.TYPE_SHIPPING_ADDRES SES,
324 firstCompleteAddressIndex, addresses); 325 firstCompleteAddressIndex, addresses);
325 } 326 }
326 327
327 if (requestPayerPhone || requestPayerEmail) { 328 if (requestPayerName || requestPayerPhone || requestPayerEmail) {
328 Set<String> uniqueContactInfos = new HashSet<>(); 329 Set<String> uniqueContactInfos = new HashSet<>();
329 mContactEditor = new ContactEditor(requestPayerPhone, requestPayerEm ail); 330 mContactEditor = new ContactEditor(
331 requestPayerName, requestPayerPhone, requestPayerEmail);
330 List<AutofillContact> contacts = new ArrayList<>(); 332 List<AutofillContact> contacts = new ArrayList<>();
331 333
332 for (int i = 0; i < profiles.size(); i++) { 334 for (int i = 0; i < profiles.size(); i++) {
333 AutofillProfile profile = profiles.get(i); 335 AutofillProfile profile = profiles.get(i);
336 String name = requestPayerName && !TextUtils.isEmpty(profile.get FullName())
337 ? profile.getFullName() : null;
334 String phone = requestPayerPhone && !TextUtils.isEmpty(profile.g etPhoneNumber()) 338 String phone = requestPayerPhone && !TextUtils.isEmpty(profile.g etPhoneNumber())
335 ? profile.getPhoneNumber() : null; 339 ? profile.getPhoneNumber() : null;
336 String email = requestPayerEmail && !TextUtils.isEmpty(profile.g etEmailAddress()) 340 String email = requestPayerEmail && !TextUtils.isEmpty(profile.g etEmailAddress())
337 ? profile.getEmailAddress() : null; 341 ? profile.getEmailAddress() : null;
342 mContactEditor.addPayerNameIfValid(name);
338 mContactEditor.addPhoneNumberIfValid(phone); 343 mContactEditor.addPhoneNumberIfValid(phone);
339 mContactEditor.addEmailAddressIfValid(email); 344 mContactEditor.addEmailAddressIfValid(email);
340 345
341 if (phone != null || email != null) { 346 if (name != null || phone != null || email != null) {
342 // Different profiles can have identical contact info. Do no t add the same 347 // Different profiles can have identical contact info. Do no t add the same
343 // contact info to the list twice. 348 // contact info to the list twice.
344 String uniqueContactInfo = phone + email; 349 String uniqueContactInfo = name + phone + email;
345 if (!uniqueContactInfos.contains(uniqueContactInfo)) { 350 if (!uniqueContactInfos.contains(uniqueContactInfo)) {
346 uniqueContactInfos.add(uniqueContactInfo); 351 uniqueContactInfos.add(uniqueContactInfo);
347 352
348 boolean isComplete = 353 boolean isComplete =
349 mContactEditor.isContactInformationComplete(phon e, email); 354 mContactEditor.isContactInformationComplete(name , phone, email);
350 contacts.add(new AutofillContact(profile, phone, email, isComplete)); 355 contacts.add(new AutofillContact(profile, name, phone, e mail, isComplete));
351 } 356 }
352 } 357 }
353 } 358 }
354 359
355 // Suggest complete contact infos first. 360 // Suggest complete contact infos first.
356 Collections.sort(contacts, COMPLETENESS_COMPARATOR); 361 Collections.sort(contacts, COMPLETENESS_COMPARATOR);
357 362
358 // Limit the number of suggestions. 363 // Limit the number of suggestions.
359 contacts = contacts.subList(0, Math.min(contacts.size(), SUGGESTIONS _LIMIT)); 364 contacts = contacts.subList(0, Math.min(contacts.size(), SUGGESTIONS _LIMIT));
360 365
361 // Log the number of suggested contact infos. 366 // Log the number of suggested contact infos.
362 mJourneyLogger.setNumberOfSuggestionsShown( 367 mJourneyLogger.setNumberOfSuggestionsShown(
363 PaymentRequestJourneyLogger.SECTION_CONTACT_INFO, contacts.s ize()); 368 PaymentRequestJourneyLogger.SECTION_CONTACT_INFO, contacts.s ize());
364 369
365 // Automatically select the first address if it is complete. 370 // Automatically select the first address if it is complete.
366 int firstCompleteContactIndex = SectionInformation.NO_SELECTION; 371 int firstCompleteContactIndex = SectionInformation.NO_SELECTION;
367 if (!contacts.isEmpty() && contacts.get(0).isComplete()) { 372 if (!contacts.isEmpty() && contacts.get(0).isComplete()) {
368 firstCompleteContactIndex = 0; 373 firstCompleteContactIndex = 0;
369 } 374 }
370 375
371 mContactSection = new SectionInformation( 376 mContactSection = new SectionInformation(
372 PaymentRequestUI.TYPE_CONTACT_DETAILS, firstCompleteContactI ndex, contacts); 377 PaymentRequestUI.TYPE_CONTACT_DETAILS, firstCompleteContactI ndex, contacts);
373 } 378 }
374 379
375 mUI = new PaymentRequestUI(mContext, this, requestShipping, 380 mUI = new PaymentRequestUI(mContext, this, requestShipping,
376 requestPayerPhone || requestPayerEmail, mMerchantSupportsAutofil lPaymentInstruments, 381 requestPayerName || requestPayerPhone || requestPayerEmail,
377 mMerchantName, mOrigin); 382 mMerchantSupportsAutofillPaymentInstruments, mMerchantName, mOri gin);
378 383
379 if (mFavicon != null) mUI.setTitleBitmap(mFavicon); 384 if (mFavicon != null) mUI.setTitleBitmap(mFavicon);
380 mFavicon = null; 385 mFavicon = null;
381 386
382 mAddressEditor.setEditorView(mUI.getEditorView()); 387 mAddressEditor.setEditorView(mUI.getEditorView());
383 mCardEditor.setEditorView(mUI.getCardEditorView()); 388 mCardEditor.setEditorView(mUI.getCardEditorView());
384 if (mContactEditor != null) mContactEditor.setEditorView(mUI.getEditorVi ew()); 389 if (mContactEditor != null) mContactEditor.setEditorView(mUI.getEditorVi ew());
385 390
386 PaymentRequestMetrics.recordRequestedInformationHistogram(requestPayerEm ail, 391 PaymentRequestMetrics.recordRequestedInformationHistogram(requestPayerEm ail,
387 requestPayerPhone, requestShipping); 392 requestPayerPhone, requestShipping);
(...skipping 675 matching lines...) Expand 10 before | Expand all | Expand 10 after
1063 1068
1064 PaymentResponse response = new PaymentResponse(); 1069 PaymentResponse response = new PaymentResponse();
1065 response.methodName = methodName; 1070 response.methodName = methodName;
1066 response.stringifiedDetails = stringifiedDetails; 1071 response.stringifiedDetails = stringifiedDetails;
1067 1072
1068 if (mContactSection != null) { 1073 if (mContactSection != null) {
1069 PaymentOption selectedContact = mContactSection.getSelectedItem(); 1074 PaymentOption selectedContact = mContactSection.getSelectedItem();
1070 if (selectedContact != null) { 1075 if (selectedContact != null) {
1071 // Contacts are created in show(). These should all be instances of AutofillContact. 1076 // Contacts are created in show(). These should all be instances of AutofillContact.
1072 assert selectedContact instanceof AutofillContact; 1077 assert selectedContact instanceof AutofillContact;
1078 response.payerName = ((AutofillContact) selectedContact).getPaye rName();
1073 response.payerPhone = ((AutofillContact) selectedContact).getPay erPhone(); 1079 response.payerPhone = ((AutofillContact) selectedContact).getPay erPhone();
1074 response.payerEmail = ((AutofillContact) selectedContact).getPay erEmail(); 1080 response.payerEmail = ((AutofillContact) selectedContact).getPay erEmail();
1075 } 1081 }
1076 } 1082 }
1077 1083
1078 if (mUiShippingOptions != null) { 1084 if (mUiShippingOptions != null) {
1079 PaymentOption selectedShippingOption = mUiShippingOptions.getSelecte dItem(); 1085 PaymentOption selectedShippingOption = mUiShippingOptions.getSelecte dItem();
1080 if (selectedShippingOption != null && selectedShippingOption.getIden tifier() != null) { 1086 if (selectedShippingOption != null && selectedShippingOption.getIden tifier() != null) {
1081 response.shippingOption = selectedShippingOption.getIdentifier() ; 1087 response.shippingOption = selectedShippingOption.getIdentifier() ;
1082 } 1088 }
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
1262 "PaymentRequest.CheckoutFunnel.Aborted", abortReason, 1268 "PaymentRequest.CheckoutFunnel.Aborted", abortReason,
1263 PaymentRequestMetrics.ABORT_REASON_MAX); 1269 PaymentRequestMetrics.ABORT_REASON_MAX);
1264 1270
1265 if (abortReason == PaymentRequestMetrics.ABORT_REASON_ABORTED_BY_USER) { 1271 if (abortReason == PaymentRequestMetrics.ABORT_REASON_ABORTED_BY_USER) {
1266 mJourneyLogger.recordJourneyStatsHistograms("UserAborted"); 1272 mJourneyLogger.recordJourneyStatsHistograms("UserAborted");
1267 } else { 1273 } else {
1268 mJourneyLogger.recordJourneyStatsHistograms("OtherAborted"); 1274 mJourneyLogger.recordJourneyStatsHistograms("OtherAborted");
1269 } 1275 }
1270 } 1276 }
1271 } 1277 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698