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

Side by Side Diff: chrome/browser/autofill/android/personal_data_manager_android.cc

Issue 2515853002: [Payments] Fix new billing address label. (Closed)
Patch Set: Updated test and code added in the Rebase Created 4 years, 1 month 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
« no previous file with comments | « chrome/browser/autofill/android/personal_data_manager_android.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 #include "chrome/browser/autofill/android/personal_data_manager_android.h" 5 #include "chrome/browser/autofill/android/personal_data_manager_android.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <algorithm> 8 #include <algorithm>
9 #include <memory> 9 #include <memory>
10 #include <utility> 10 #include <utility>
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 jboolean include_name_in_label, 423 jboolean include_name_in_label,
424 jboolean include_organization_in_label, 424 jboolean include_organization_in_label,
425 jboolean include_country_in_label) { 425 jboolean include_country_in_label) {
426 return GetProfileLabels(env, true /* address_only */, include_name_in_label, 426 return GetProfileLabels(env, true /* address_only */, include_name_in_label,
427 include_organization_in_label, 427 include_organization_in_label,
428 include_country_in_label, 428 include_country_in_label,
429 personal_data_manager_->GetProfilesToSuggest()); 429 personal_data_manager_->GetProfilesToSuggest());
430 } 430 }
431 431
432 base::android::ScopedJavaLocalRef<jstring> 432 base::android::ScopedJavaLocalRef<jstring>
433 PersonalDataManagerAndroid::GetAddressLabelForPaymentRequest( 433 PersonalDataManagerAndroid::GetShippingAddressLabelForPaymentRequest(
434 JNIEnv* env, 434 JNIEnv* env,
435 const base::android::JavaParamRef<jobject>& unused_obj, 435 const base::android::JavaParamRef<jobject>& unused_obj,
436 const base::android::JavaParamRef<jobject>& jprofile) { 436 const base::android::JavaParamRef<jobject>& jprofile) {
437 // The full name is not included in the label for shipping address. It is
438 // added separately instead.
437 std::vector<ServerFieldType> label_fields; 439 std::vector<ServerFieldType> label_fields;
438 label_fields.push_back(COMPANY_NAME); 440 label_fields.push_back(COMPANY_NAME);
439 label_fields.push_back(ADDRESS_HOME_LINE1); 441 label_fields.push_back(ADDRESS_HOME_LINE1);
440 label_fields.push_back(ADDRESS_HOME_LINE2); 442 label_fields.push_back(ADDRESS_HOME_LINE2);
441 label_fields.push_back(ADDRESS_HOME_DEPENDENT_LOCALITY); 443 label_fields.push_back(ADDRESS_HOME_DEPENDENT_LOCALITY);
442 label_fields.push_back(ADDRESS_HOME_CITY); 444 label_fields.push_back(ADDRESS_HOME_CITY);
443 label_fields.push_back(ADDRESS_HOME_STATE); 445 label_fields.push_back(ADDRESS_HOME_STATE);
444 label_fields.push_back(ADDRESS_HOME_ZIP); 446 label_fields.push_back(ADDRESS_HOME_ZIP);
445 label_fields.push_back(ADDRESS_HOME_SORTING_CODE); 447 label_fields.push_back(ADDRESS_HOME_SORTING_CODE);
446 label_fields.push_back(ADDRESS_HOME_COUNTRY); 448 label_fields.push_back(ADDRESS_HOME_COUNTRY);
447 449
448 AutofillProfile profile; 450 AutofillProfile profile;
449 PopulateNativeProfileFromJava(jprofile, env, &profile); 451 PopulateNativeProfileFromJava(jprofile, env, &profile);
450 452
451 return ConvertUTF16ToJavaString( 453 return ConvertUTF16ToJavaString(
452 env, profile.ConstructInferredLabel( 454 env, profile.ConstructInferredLabel(
453 label_fields, label_fields.size(), 455 label_fields, label_fields.size(),
454 g_browser_process->GetApplicationLocale())); 456 g_browser_process->GetApplicationLocale()));
455 } 457 }
456 458
459 base::android::ScopedJavaLocalRef<jstring>
460 PersonalDataManagerAndroid::GetBillingAddressLabelForPaymentRequest(
461 JNIEnv* env,
462 const base::android::JavaParamRef<jobject>& unused_obj,
463 const base::android::JavaParamRef<jobject>& jprofile) {
464 // The company name and country are not included in the billing address label.
465 std::vector<ServerFieldType> label_fields;
466 label_fields.push_back(NAME_FULL);
467 label_fields.push_back(ADDRESS_HOME_LINE1);
468 label_fields.push_back(ADDRESS_HOME_LINE2);
469 label_fields.push_back(ADDRESS_HOME_DEPENDENT_LOCALITY);
470 label_fields.push_back(ADDRESS_HOME_CITY);
471 label_fields.push_back(ADDRESS_HOME_STATE);
472 label_fields.push_back(ADDRESS_HOME_ZIP);
473 label_fields.push_back(ADDRESS_HOME_SORTING_CODE);
474
475 AutofillProfile profile;
476 PopulateNativeProfileFromJava(jprofile, env, &profile);
477
478 return ConvertUTF16ToJavaString(
479 env, profile.ConstructInferredLabel(
480 label_fields, label_fields.size(),
481 g_browser_process->GetApplicationLocale()));
482 }
483
457 base::android::ScopedJavaLocalRef<jobjectArray> 484 base::android::ScopedJavaLocalRef<jobjectArray>
458 PersonalDataManagerAndroid::GetCreditCardGUIDsForSettings( 485 PersonalDataManagerAndroid::GetCreditCardGUIDsForSettings(
459 JNIEnv* env, 486 JNIEnv* env,
460 const base::android::JavaParamRef<jobject>& unused_obj) { 487 const base::android::JavaParamRef<jobject>& unused_obj) {
461 return GetCreditCardGUIDs(env, personal_data_manager_->GetCreditCards()); 488 return GetCreditCardGUIDs(env, personal_data_manager_->GetCreditCards());
462 } 489 }
463 490
464 base::android::ScopedJavaLocalRef<jobjectArray> 491 base::android::ScopedJavaLocalRef<jobjectArray>
465 PersonalDataManagerAndroid::GetCreditCardGUIDsToSuggest( 492 PersonalDataManagerAndroid::GetCreditCardGUIDsToSuggest(
466 JNIEnv* env, 493 JNIEnv* env,
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after
881 base::android::ConvertJavaStringToUTF16(env, jcountry_name))); 908 base::android::ConvertJavaStringToUTF16(env, jcountry_name)));
882 } 909 }
883 910
884 static jlong Init(JNIEnv* env, const JavaParamRef<jobject>& obj) { 911 static jlong Init(JNIEnv* env, const JavaParamRef<jobject>& obj) {
885 PersonalDataManagerAndroid* personal_data_manager_android = 912 PersonalDataManagerAndroid* personal_data_manager_android =
886 new PersonalDataManagerAndroid(env, obj); 913 new PersonalDataManagerAndroid(env, obj);
887 return reinterpret_cast<intptr_t>(personal_data_manager_android); 914 return reinterpret_cast<intptr_t>(personal_data_manager_android);
888 } 915 }
889 916
890 } // namespace autofill 917 } // namespace autofill
OLDNEW
« no previous file with comments | « chrome/browser/autofill/android/personal_data_manager_android.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698