Chromium Code Reviews| 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 "base/android/jni_string.h" | 7 #include "base/android/jni_string.h" |
| 8 #include "base/format_macros.h" | 8 #include "base/format_macros.h" |
| 9 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
| 10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 35 ScopedJavaLocalRef<jobject> CreateJavaProfileFromNative( | 35 ScopedJavaLocalRef<jobject> CreateJavaProfileFromNative( |
| 36 JNIEnv* env, | 36 JNIEnv* env, |
| 37 const AutofillProfile& profile) { | 37 const AutofillProfile& profile) { |
| 38 return Java_AutofillProfile_create( | 38 return Java_AutofillProfile_create( |
| 39 env, | 39 env, |
| 40 ConvertUTF8ToJavaString(env, profile.guid()).obj(), | 40 ConvertUTF8ToJavaString(env, profile.guid()).obj(), |
| 41 ConvertUTF8ToJavaString(env, profile.origin()).obj(), | 41 ConvertUTF8ToJavaString(env, profile.origin()).obj(), |
| 42 ConvertUTF16ToJavaString(env, profile.GetRawInfo(NAME_FULL)).obj(), | 42 ConvertUTF16ToJavaString(env, profile.GetRawInfo(NAME_FULL)).obj(), |
| 43 ConvertUTF16ToJavaString(env, profile.GetRawInfo(COMPANY_NAME)).obj(), | 43 ConvertUTF16ToJavaString(env, profile.GetRawInfo(COMPANY_NAME)).obj(), |
| 44 ConvertUTF16ToJavaString( | 44 ConvertUTF16ToJavaString( |
| 45 env, | 45 env, profile.GetRawInfo(ADDRESS_HOME_STREET_ADDRESS)).obj(), |
| 46 profile.GetRawInfo(ADDRESS_HOME_STREET_ADDRESS)).obj(), | 46 ConvertUTF16ToJavaString(env, profile.GetRawInfo(ADDRESS_HOME_STATE)) |
| 47 .obj(), | |
| 48 ConvertUTF16ToJavaString(env, profile.GetRawInfo(ADDRESS_HOME_CITY)) | |
| 49 .obj(), | |
| 47 ConvertUTF16ToJavaString( | 50 ConvertUTF16ToJavaString( |
| 48 env, | 51 env, profile.GetRawInfo(ADDRESS_HOME_DEPENDENT_LOCALITY)).obj(), |
| 49 profile.GetRawInfo(ADDRESS_HOME_STATE)).obj(), | 52 ConvertUTF16ToJavaString(env, profile.GetRawInfo(ADDRESS_HOME_ZIP)).obj(), |
| 50 ConvertUTF16ToJavaString( | 53 ConvertUTF16ToJavaString( |
| 51 env, | 54 env, profile.GetRawInfo(ADDRESS_HOME_SORTING_CODE)).obj(), |
| 52 profile.GetRawInfo(ADDRESS_HOME_CITY)).obj(), | 55 ConvertUTF16ToJavaString(env, profile.GetRawInfo(ADDRESS_HOME_COUNTRY)) |
| 53 ConvertUTF16ToJavaString( | 56 .obj(), |
| 54 env, | 57 ConvertUTF16ToJavaString(env, profile.GetRawInfo(PHONE_HOME_WHOLE_NUMBER)) |
| 55 profile.GetRawInfo(ADDRESS_HOME_DEPENDENT_LOCALITY)).obj(), | 58 .obj(), |
| 56 ConvertUTF16ToJavaString( | |
| 57 env, | |
| 58 profile.GetRawInfo(ADDRESS_HOME_ZIP)).obj(), | |
| 59 ConvertUTF16ToJavaString( | |
| 60 env, | |
| 61 profile.GetRawInfo(ADDRESS_HOME_SORTING_CODE)).obj(), | |
| 62 ConvertUTF16ToJavaString( | |
| 63 env, | |
| 64 profile.GetInfo(AutofillType(ADDRESS_HOME_COUNTRY), | |
| 65 g_browser_process->GetApplicationLocale())).obj(), | |
| 66 ConvertUTF16ToJavaString( | |
| 67 env, | |
| 68 profile.GetRawInfo(PHONE_HOME_WHOLE_NUMBER)).obj(), | |
| 69 ConvertUTF16ToJavaString(env, profile.GetRawInfo(EMAIL_ADDRESS)).obj(), | 59 ConvertUTF16ToJavaString(env, profile.GetRawInfo(EMAIL_ADDRESS)).obj(), |
| 70 ConvertUTF8ToJavaString(env, profile.language_code()).obj()); | 60 ConvertUTF8ToJavaString(env, profile.language_code()).obj()); |
| 71 } | 61 } |
| 72 | 62 |
| 73 void PopulateNativeProfileFromJava( | 63 void PopulateNativeProfileFromJava( |
| 74 const jobject& jprofile, | 64 const jobject& jprofile, |
| 75 JNIEnv* env, | 65 JNIEnv* env, |
| 76 AutofillProfile* profile) { | 66 AutofillProfile* profile) { |
| 77 profile->set_origin( | 67 profile->set_origin( |
| 78 ConvertJavaStringToUTF8( | 68 ConvertJavaStringToUTF8( |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 110 profile->SetInfo( | 100 profile->SetInfo( |
| 111 AutofillType(ADDRESS_HOME_ZIP), | 101 AutofillType(ADDRESS_HOME_ZIP), |
| 112 ConvertJavaStringToUTF16( | 102 ConvertJavaStringToUTF16( |
| 113 Java_AutofillProfile_getPostalCode(env, jprofile)), | 103 Java_AutofillProfile_getPostalCode(env, jprofile)), |
| 114 g_browser_process->GetApplicationLocale()); | 104 g_browser_process->GetApplicationLocale()); |
| 115 profile->SetInfo( | 105 profile->SetInfo( |
| 116 AutofillType(ADDRESS_HOME_SORTING_CODE), | 106 AutofillType(ADDRESS_HOME_SORTING_CODE), |
| 117 ConvertJavaStringToUTF16( | 107 ConvertJavaStringToUTF16( |
| 118 Java_AutofillProfile_getSortingCode(env, jprofile)), | 108 Java_AutofillProfile_getSortingCode(env, jprofile)), |
| 119 g_browser_process->GetApplicationLocale()); | 109 g_browser_process->GetApplicationLocale()); |
| 120 profile->SetInfo( | 110 profile->SetInfo(AutofillType(ADDRESS_HOME_COUNTRY), |
| 121 AutofillType(ADDRESS_HOME_COUNTRY), | 111 ConvertJavaStringToUTF16( |
| 122 ConvertJavaStringToUTF16( | 112 Java_AutofillProfile_getCountryCode(env, jprofile)), |
| 123 Java_AutofillProfile_getCountry(env, jprofile)), | 113 g_browser_process->GetApplicationLocale()); |
| 124 g_browser_process->GetApplicationLocale()); | |
| 125 profile->SetInfo( | 114 profile->SetInfo( |
| 126 AutofillType(PHONE_HOME_WHOLE_NUMBER), | 115 AutofillType(PHONE_HOME_WHOLE_NUMBER), |
| 127 ConvertJavaStringToUTF16( | 116 ConvertJavaStringToUTF16( |
| 128 Java_AutofillProfile_getPhoneNumber(env, jprofile)), | 117 Java_AutofillProfile_getPhoneNumber(env, jprofile)), |
| 129 g_browser_process->GetApplicationLocale()); | 118 g_browser_process->GetApplicationLocale()); |
| 130 profile->SetInfo( | 119 profile->SetInfo( |
| 131 AutofillType(EMAIL_ADDRESS), | 120 AutofillType(EMAIL_ADDRESS), |
| 132 ConvertJavaStringToUTF16( | 121 ConvertJavaStringToUTF16( |
| 133 Java_AutofillProfile_getEmailAddress(env, jprofile)), | 122 Java_AutofillProfile_getEmailAddress(env, jprofile)), |
| 134 g_browser_process->GetApplicationLocale()); | 123 g_browser_process->GetApplicationLocale()); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 168 CREDIT_CARD_NUMBER, | 157 CREDIT_CARD_NUMBER, |
| 169 ConvertJavaStringToUTF16(Java_CreditCard_getNumber(env, jcard))); | 158 ConvertJavaStringToUTF16(Java_CreditCard_getNumber(env, jcard))); |
| 170 card->SetRawInfo( | 159 card->SetRawInfo( |
| 171 CREDIT_CARD_EXP_MONTH, | 160 CREDIT_CARD_EXP_MONTH, |
| 172 ConvertJavaStringToUTF16(Java_CreditCard_getMonth(env, jcard))); | 161 ConvertJavaStringToUTF16(Java_CreditCard_getMonth(env, jcard))); |
| 173 card->SetRawInfo( | 162 card->SetRawInfo( |
| 174 CREDIT_CARD_EXP_4_DIGIT_YEAR, | 163 CREDIT_CARD_EXP_4_DIGIT_YEAR, |
| 175 ConvertJavaStringToUTF16(Java_CreditCard_getYear(env, jcard))); | 164 ConvertJavaStringToUTF16(Java_CreditCard_getYear(env, jcard))); |
| 176 } | 165 } |
| 177 | 166 |
| 167 /* | |
| 168 ScopedJavaLocalRef<jobject> CreateJavaCountryFromNative( | |
|
aurimas (slooooooooow)
2014/08/01 15:18:21
Can you remove this?
Evan Stade
2014/08/01 18:59:23
oops. Yes.
Evan Stade
2014/08/04 20:36:04
Done.
| |
| 169 JNIEnv* env, | |
| 170 const | |
| 171 */ | |
| 172 | |
| 178 } // namespace | 173 } // namespace |
| 179 | 174 |
| 180 PersonalDataManagerAndroid::PersonalDataManagerAndroid(JNIEnv* env, | 175 PersonalDataManagerAndroid::PersonalDataManagerAndroid(JNIEnv* env, |
| 181 jobject obj) | 176 jobject obj) |
| 182 : weak_java_obj_(env, obj), | 177 : weak_java_obj_(env, obj), |
| 183 personal_data_manager_(PersonalDataManagerFactory::GetForProfile( | 178 personal_data_manager_(PersonalDataManagerFactory::GetForProfile( |
| 184 ProfileManager::GetActiveUserProfile())) { | 179 ProfileManager::GetActiveUserProfile())) { |
| 185 personal_data_manager_->AddObserver(this); | 180 personal_data_manager_->AddObserver(this); |
| 186 } | 181 } |
| 187 | 182 |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 331 g_browser_process->GetApplicationLocale())).Release(); | 326 g_browser_process->GetApplicationLocale())).Release(); |
| 332 } | 327 } |
| 333 | 328 |
| 334 static jlong Init(JNIEnv* env, jobject obj) { | 329 static jlong Init(JNIEnv* env, jobject obj) { |
| 335 PersonalDataManagerAndroid* personal_data_manager_android = | 330 PersonalDataManagerAndroid* personal_data_manager_android = |
| 336 new PersonalDataManagerAndroid(env, obj); | 331 new PersonalDataManagerAndroid(env, obj); |
| 337 return reinterpret_cast<intptr_t>(personal_data_manager_android); | 332 return reinterpret_cast<intptr_t>(personal_data_manager_android); |
| 338 } | 333 } |
| 339 | 334 |
| 340 } // namespace autofill | 335 } // namespace autofill |
| OLD | NEW |