| OLD | NEW |
| 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 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 381 personal_data_manager_->UpdateProfile(profile); | 381 personal_data_manager_->UpdateProfile(profile); |
| 382 } | 382 } |
| 383 | 383 |
| 384 return ConvertUTF8ToJavaString(env, profile.guid()); | 384 return ConvertUTF8ToJavaString(env, profile.guid()); |
| 385 } | 385 } |
| 386 | 386 |
| 387 ScopedJavaLocalRef<jobjectArray> | 387 ScopedJavaLocalRef<jobjectArray> |
| 388 PersonalDataManagerAndroid::GetProfileLabelsForSettings( | 388 PersonalDataManagerAndroid::GetProfileLabelsForSettings( |
| 389 JNIEnv* env, | 389 JNIEnv* env, |
| 390 const JavaParamRef<jobject>& unused_obj) { | 390 const JavaParamRef<jobject>& unused_obj) { |
| 391 return GetProfileLabels(env, false, false, | 391 return GetProfileLabels(env, false /* address_only */, |
| 392 false /* include_name_in_label */, |
| 393 true /* include_organization_in_label */, |
| 394 true /* include_country_in_label */, |
| 392 personal_data_manager_->GetProfiles()); | 395 personal_data_manager_->GetProfiles()); |
| 393 } | 396 } |
| 394 | 397 |
| 395 ScopedJavaLocalRef<jobjectArray> | 398 ScopedJavaLocalRef<jobjectArray> |
| 396 PersonalDataManagerAndroid::GetProfileLabelsToSuggest( | 399 PersonalDataManagerAndroid::GetProfileLabelsToSuggest( |
| 397 JNIEnv* env, | 400 JNIEnv* env, |
| 398 const JavaParamRef<jobject>& unused_obj, | 401 const JavaParamRef<jobject>& unused_obj, |
| 399 jboolean include_name_in_label) { | 402 jboolean include_name_in_label, |
| 400 return GetProfileLabels(env, true, include_name_in_label, | 403 jboolean include_organization_in_label, |
| 404 jboolean include_country_in_label) { |
| 405 return GetProfileLabels(env, true /* address_only */, include_name_in_label, |
| 406 include_organization_in_label, |
| 407 include_country_in_label, |
| 401 personal_data_manager_->GetProfilesToSuggest()); | 408 personal_data_manager_->GetProfilesToSuggest()); |
| 402 } | 409 } |
| 403 | 410 |
| 404 base::android::ScopedJavaLocalRef<jstring> | 411 base::android::ScopedJavaLocalRef<jstring> |
| 405 PersonalDataManagerAndroid::GetAddressLabelForPaymentRequest( | 412 PersonalDataManagerAndroid::GetAddressLabelForPaymentRequest( |
| 406 JNIEnv* env, | 413 JNIEnv* env, |
| 407 const base::android::JavaParamRef<jobject>& unused_obj, | 414 const base::android::JavaParamRef<jobject>& unused_obj, |
| 408 const base::android::JavaParamRef<jobject>& jprofile) { | 415 const base::android::JavaParamRef<jobject>& jprofile) { |
| 409 std::vector<ServerFieldType> label_fields; | 416 std::vector<ServerFieldType> label_fields; |
| 410 label_fields.push_back(COMPANY_NAME); | 417 label_fields.push_back(COMPANY_NAME); |
| (...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 763 for (CreditCard* credit_card : credit_cards) | 770 for (CreditCard* credit_card : credit_cards) |
| 764 guids.push_back(base::UTF8ToUTF16(credit_card->guid())); | 771 guids.push_back(base::UTF8ToUTF16(credit_card->guid())); |
| 765 | 772 |
| 766 return base::android::ToJavaArrayOfStrings(env, guids); | 773 return base::android::ToJavaArrayOfStrings(env, guids); |
| 767 } | 774 } |
| 768 | 775 |
| 769 ScopedJavaLocalRef<jobjectArray> PersonalDataManagerAndroid::GetProfileLabels( | 776 ScopedJavaLocalRef<jobjectArray> PersonalDataManagerAndroid::GetProfileLabels( |
| 770 JNIEnv* env, | 777 JNIEnv* env, |
| 771 bool address_only, | 778 bool address_only, |
| 772 bool include_name_in_label, | 779 bool include_name_in_label, |
| 780 bool include_organization_in_label, |
| 781 bool include_country_in_label, |
| 773 std::vector<AutofillProfile*> profiles) { | 782 std::vector<AutofillProfile*> profiles) { |
| 774 std::unique_ptr<std::vector<ServerFieldType>> suggested_fields; | 783 std::unique_ptr<std::vector<ServerFieldType>> suggested_fields; |
| 775 size_t minimal_fields_shown = 2; | 784 size_t minimal_fields_shown = 2; |
| 776 if (address_only) { | 785 if (address_only) { |
| 777 suggested_fields.reset(new std::vector<ServerFieldType>); | 786 suggested_fields.reset(new std::vector<ServerFieldType>); |
| 778 if (include_name_in_label) | 787 if (include_name_in_label) |
| 779 suggested_fields->push_back(NAME_FULL); | 788 suggested_fields->push_back(NAME_FULL); |
| 780 suggested_fields->push_back(COMPANY_NAME); | 789 if (include_organization_in_label) |
| 790 suggested_fields->push_back(COMPANY_NAME); |
| 781 suggested_fields->push_back(ADDRESS_HOME_LINE1); | 791 suggested_fields->push_back(ADDRESS_HOME_LINE1); |
| 782 suggested_fields->push_back(ADDRESS_HOME_LINE2); | 792 suggested_fields->push_back(ADDRESS_HOME_LINE2); |
| 783 suggested_fields->push_back(ADDRESS_HOME_DEPENDENT_LOCALITY); | 793 suggested_fields->push_back(ADDRESS_HOME_DEPENDENT_LOCALITY); |
| 784 suggested_fields->push_back(ADDRESS_HOME_CITY); | 794 suggested_fields->push_back(ADDRESS_HOME_CITY); |
| 785 suggested_fields->push_back(ADDRESS_HOME_STATE); | 795 suggested_fields->push_back(ADDRESS_HOME_STATE); |
| 786 suggested_fields->push_back(ADDRESS_HOME_ZIP); | 796 suggested_fields->push_back(ADDRESS_HOME_ZIP); |
| 787 suggested_fields->push_back(ADDRESS_HOME_SORTING_CODE); | 797 suggested_fields->push_back(ADDRESS_HOME_SORTING_CODE); |
| 788 suggested_fields->push_back(ADDRESS_HOME_COUNTRY); | 798 if (include_country_in_label) |
| 799 suggested_fields->push_back(ADDRESS_HOME_COUNTRY); |
| 789 minimal_fields_shown = suggested_fields->size(); | 800 minimal_fields_shown = suggested_fields->size(); |
| 790 } | 801 } |
| 791 | 802 |
| 792 ServerFieldType excluded_field = | 803 ServerFieldType excluded_field = |
| 793 include_name_in_label ? UNKNOWN_TYPE : NAME_FULL; | 804 include_name_in_label ? UNKNOWN_TYPE : NAME_FULL; |
| 794 | 805 |
| 795 std::vector<base::string16> labels; | 806 std::vector<base::string16> labels; |
| 796 AutofillProfile::CreateInferredLabels( | 807 AutofillProfile::CreateInferredLabels( |
| 797 profiles, suggested_fields.get(), excluded_field, minimal_fields_shown, | 808 profiles, suggested_fields.get(), excluded_field, minimal_fields_shown, |
| 798 g_browser_process->GetApplicationLocale(), &labels); | 809 g_browser_process->GetApplicationLocale(), &labels); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 849 base::android::ConvertJavaStringToUTF16(env, jcountry_name))); | 860 base::android::ConvertJavaStringToUTF16(env, jcountry_name))); |
| 850 } | 861 } |
| 851 | 862 |
| 852 static jlong Init(JNIEnv* env, const JavaParamRef<jobject>& obj) { | 863 static jlong Init(JNIEnv* env, const JavaParamRef<jobject>& obj) { |
| 853 PersonalDataManagerAndroid* personal_data_manager_android = | 864 PersonalDataManagerAndroid* personal_data_manager_android = |
| 854 new PersonalDataManagerAndroid(env, obj); | 865 new PersonalDataManagerAndroid(env, obj); |
| 855 return reinterpret_cast<intptr_t>(personal_data_manager_android); | 866 return reinterpret_cast<intptr_t>(personal_data_manager_android); |
| 856 } | 867 } |
| 857 | 868 |
| 858 } // namespace autofill | 869 } // namespace autofill |
| OLD | NEW |