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

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

Issue 2526943003: [Payments] Remove country from shipping label in bottom and fullsheet. (Closed)
Patch Set: Moved assertion Created 4 years 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::GetShippingAddressLabelForPaymentRequest( 433 PersonalDataManagerAndroid::GetShippingAddressLabelWithCountryForPaymentRequest(
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 437 return GetShippingAddressLabelForPaymentRequest(
438 // added separately instead. 438 env, jprofile, true /* include_country_in_label */);
439 std::vector<ServerFieldType> label_fields; 439 }
440 label_fields.push_back(COMPANY_NAME);
441 label_fields.push_back(ADDRESS_HOME_LINE1);
442 label_fields.push_back(ADDRESS_HOME_LINE2);
443 label_fields.push_back(ADDRESS_HOME_DEPENDENT_LOCALITY);
444 label_fields.push_back(ADDRESS_HOME_CITY);
445 label_fields.push_back(ADDRESS_HOME_STATE);
446 label_fields.push_back(ADDRESS_HOME_ZIP);
447 label_fields.push_back(ADDRESS_HOME_SORTING_CODE);
448 label_fields.push_back(ADDRESS_HOME_COUNTRY);
449 440
450 AutofillProfile profile; 441 base::android::ScopedJavaLocalRef<jstring> PersonalDataManagerAndroid::
451 PopulateNativeProfileFromJava(jprofile, env, &profile); 442 GetShippingAddressLabelWithoutCountryForPaymentRequest(
452 443 JNIEnv* env,
453 return ConvertUTF16ToJavaString( 444 const base::android::JavaParamRef<jobject>& unused_obj,
454 env, profile.ConstructInferredLabel( 445 const base::android::JavaParamRef<jobject>& jprofile) {
455 label_fields, label_fields.size(), 446 return GetShippingAddressLabelForPaymentRequest(
456 g_browser_process->GetApplicationLocale())); 447 env, jprofile, false /* include_country_in_label */);
457 } 448 }
458 449
459 base::android::ScopedJavaLocalRef<jstring> 450 base::android::ScopedJavaLocalRef<jstring>
460 PersonalDataManagerAndroid::GetBillingAddressLabelForPaymentRequest( 451 PersonalDataManagerAndroid::GetBillingAddressLabelForPaymentRequest(
461 JNIEnv* env, 452 JNIEnv* env,
462 const base::android::JavaParamRef<jobject>& unused_obj, 453 const base::android::JavaParamRef<jobject>& unused_obj,
463 const base::android::JavaParamRef<jobject>& jprofile) { 454 const base::android::JavaParamRef<jobject>& jprofile) {
464 // The company name and country are not included in the billing address label. 455 // The company name and country are not included in the billing address label.
465 std::vector<ServerFieldType> label_fields; 456 std::vector<ServerFieldType> label_fields;
466 label_fields.push_back(NAME_FULL); 457 label_fields.push_back(NAME_FULL);
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after
814 ScopedJavaLocalRef<jobjectArray> PersonalDataManagerAndroid::GetCreditCardGUIDs( 805 ScopedJavaLocalRef<jobjectArray> PersonalDataManagerAndroid::GetCreditCardGUIDs(
815 JNIEnv* env, 806 JNIEnv* env,
816 const std::vector<CreditCard*>& credit_cards) { 807 const std::vector<CreditCard*>& credit_cards) {
817 std::vector<base::string16> guids; 808 std::vector<base::string16> guids;
818 for (CreditCard* credit_card : credit_cards) 809 for (CreditCard* credit_card : credit_cards)
819 guids.push_back(base::UTF8ToUTF16(credit_card->guid())); 810 guids.push_back(base::UTF8ToUTF16(credit_card->guid()));
820 811
821 return base::android::ToJavaArrayOfStrings(env, guids); 812 return base::android::ToJavaArrayOfStrings(env, guids);
822 } 813 }
823 814
815 bool PersonalDataManagerAndroid::AreRulesLoadedForRegion(
816 const std::string& region_code) {
817 return address_validator_.AreRulesLoadedForRegion(region_code);
818 }
819
824 ScopedJavaLocalRef<jobjectArray> PersonalDataManagerAndroid::GetProfileLabels( 820 ScopedJavaLocalRef<jobjectArray> PersonalDataManagerAndroid::GetProfileLabels(
825 JNIEnv* env, 821 JNIEnv* env,
826 bool address_only, 822 bool address_only,
827 bool include_name_in_label, 823 bool include_name_in_label,
828 bool include_organization_in_label, 824 bool include_organization_in_label,
829 bool include_country_in_label, 825 bool include_country_in_label,
830 std::vector<AutofillProfile*> profiles) { 826 std::vector<AutofillProfile*> profiles) {
831 std::unique_ptr<std::vector<ServerFieldType>> suggested_fields; 827 std::unique_ptr<std::vector<ServerFieldType>> suggested_fields;
832 size_t minimal_fields_shown = 2; 828 size_t minimal_fields_shown = 2;
833 if (address_only) { 829 if (address_only) {
(...skipping 18 matching lines...) Expand all
852 include_name_in_label ? UNKNOWN_TYPE : NAME_FULL; 848 include_name_in_label ? UNKNOWN_TYPE : NAME_FULL;
853 849
854 std::vector<base::string16> labels; 850 std::vector<base::string16> labels;
855 AutofillProfile::CreateInferredLabels( 851 AutofillProfile::CreateInferredLabels(
856 profiles, suggested_fields.get(), excluded_field, minimal_fields_shown, 852 profiles, suggested_fields.get(), excluded_field, minimal_fields_shown,
857 g_browser_process->GetApplicationLocale(), &labels); 853 g_browser_process->GetApplicationLocale(), &labels);
858 854
859 return base::android::ToJavaArrayOfStrings(env, labels); 855 return base::android::ToJavaArrayOfStrings(env, labels);
860 } 856 }
861 857
862 bool PersonalDataManagerAndroid::AreRulesLoadedForRegion( 858 base::android::ScopedJavaLocalRef<jstring>
863 const std::string& region_code) { 859 PersonalDataManagerAndroid::GetShippingAddressLabelForPaymentRequest(
864 return address_validator_.AreRulesLoadedForRegion(region_code); 860 JNIEnv* env,
861 const base::android::JavaParamRef<jobject>& jprofile,
862 bool include_country_in_label) {
863 // The full name is not included in the label for shipping address. It is
864 // added separately instead.
865 std::vector<ServerFieldType> label_fields;
866 label_fields.push_back(COMPANY_NAME);
867 label_fields.push_back(ADDRESS_HOME_LINE1);
868 label_fields.push_back(ADDRESS_HOME_LINE2);
869 label_fields.push_back(ADDRESS_HOME_DEPENDENT_LOCALITY);
870 label_fields.push_back(ADDRESS_HOME_CITY);
871 label_fields.push_back(ADDRESS_HOME_STATE);
872 label_fields.push_back(ADDRESS_HOME_ZIP);
873 label_fields.push_back(ADDRESS_HOME_SORTING_CODE);
874 if (include_country_in_label)
875 label_fields.push_back(ADDRESS_HOME_COUNTRY);
876
877 AutofillProfile profile;
878 PopulateNativeProfileFromJava(jprofile, env, &profile);
879
880 return ConvertUTF16ToJavaString(
881 env, profile.ConstructInferredLabel(
882 label_fields, label_fields.size(),
883 g_browser_process->GetApplicationLocale()));
865 } 884 }
866 885
867 // Returns whether the Autofill feature is enabled. 886 // Returns whether the Autofill feature is enabled.
868 static jboolean IsAutofillEnabled(JNIEnv* env, 887 static jboolean IsAutofillEnabled(JNIEnv* env,
869 const JavaParamRef<jclass>& clazz) { 888 const JavaParamRef<jclass>& clazz) {
870 return GetPrefs()->GetBoolean(autofill::prefs::kAutofillEnabled); 889 return GetPrefs()->GetBoolean(autofill::prefs::kAutofillEnabled);
871 } 890 }
872 891
873 // Enables or disables the Autofill feature. 892 // Enables or disables the Autofill feature.
874 static void SetAutofillEnabled(JNIEnv* env, 893 static void SetAutofillEnabled(JNIEnv* env,
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
908 base::android::ConvertJavaStringToUTF16(env, jcountry_name))); 927 base::android::ConvertJavaStringToUTF16(env, jcountry_name)));
909 } 928 }
910 929
911 static jlong Init(JNIEnv* env, const JavaParamRef<jobject>& obj) { 930 static jlong Init(JNIEnv* env, const JavaParamRef<jobject>& obj) {
912 PersonalDataManagerAndroid* personal_data_manager_android = 931 PersonalDataManagerAndroid* personal_data_manager_android =
913 new PersonalDataManagerAndroid(env, obj); 932 new PersonalDataManagerAndroid(env, obj);
914 return reinterpret_cast<intptr_t>(personal_data_manager_android); 933 return reinterpret_cast<intptr_t>(personal_data_manager_android);
915 } 934 }
916 935
917 } // namespace autofill 936 } // 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