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_array.h" | 7 #include "base/android/jni_array.h" |
8 #include "base/android/jni_string.h" | 8 #include "base/android/jni_string.h" |
9 #include "base/format_macros.h" | 9 #include "base/format_macros.h" |
10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
(...skipping 25 matching lines...) Expand all Loading... |
36 ScopedJavaLocalRef<jobject> CreateJavaProfileFromNative( | 36 ScopedJavaLocalRef<jobject> CreateJavaProfileFromNative( |
37 JNIEnv* env, | 37 JNIEnv* env, |
38 const AutofillProfile& profile) { | 38 const AutofillProfile& profile) { |
39 return Java_AutofillProfile_create( | 39 return Java_AutofillProfile_create( |
40 env, | 40 env, |
41 ConvertUTF8ToJavaString(env, profile.guid()).obj(), | 41 ConvertUTF8ToJavaString(env, profile.guid()).obj(), |
42 ConvertUTF8ToJavaString(env, profile.origin()).obj(), | 42 ConvertUTF8ToJavaString(env, profile.origin()).obj(), |
43 ConvertUTF16ToJavaString(env, profile.GetRawInfo(NAME_FULL)).obj(), | 43 ConvertUTF16ToJavaString(env, profile.GetRawInfo(NAME_FULL)).obj(), |
44 ConvertUTF16ToJavaString(env, profile.GetRawInfo(COMPANY_NAME)).obj(), | 44 ConvertUTF16ToJavaString(env, profile.GetRawInfo(COMPANY_NAME)).obj(), |
45 ConvertUTF16ToJavaString( | 45 ConvertUTF16ToJavaString( |
46 env, | 46 env, profile.GetRawInfo(ADDRESS_HOME_STREET_ADDRESS)).obj(), |
47 profile.GetRawInfo(ADDRESS_HOME_STREET_ADDRESS)).obj(), | 47 ConvertUTF16ToJavaString(env, profile.GetRawInfo(ADDRESS_HOME_STATE)) |
| 48 .obj(), |
| 49 ConvertUTF16ToJavaString(env, profile.GetRawInfo(ADDRESS_HOME_CITY)) |
| 50 .obj(), |
48 ConvertUTF16ToJavaString( | 51 ConvertUTF16ToJavaString( |
49 env, | 52 env, profile.GetRawInfo(ADDRESS_HOME_DEPENDENT_LOCALITY)).obj(), |
50 profile.GetRawInfo(ADDRESS_HOME_STATE)).obj(), | 53 ConvertUTF16ToJavaString(env, profile.GetRawInfo(ADDRESS_HOME_ZIP)).obj(), |
51 ConvertUTF16ToJavaString( | 54 ConvertUTF16ToJavaString( |
52 env, | 55 env, profile.GetRawInfo(ADDRESS_HOME_SORTING_CODE)).obj(), |
53 profile.GetRawInfo(ADDRESS_HOME_CITY)).obj(), | 56 ConvertUTF16ToJavaString(env, profile.GetRawInfo(ADDRESS_HOME_COUNTRY)) |
54 ConvertUTF16ToJavaString( | 57 .obj(), |
55 env, | 58 ConvertUTF16ToJavaString(env, profile.GetRawInfo(PHONE_HOME_WHOLE_NUMBER)) |
56 profile.GetRawInfo(ADDRESS_HOME_DEPENDENT_LOCALITY)).obj(), | 59 .obj(), |
57 ConvertUTF16ToJavaString( | |
58 env, | |
59 profile.GetRawInfo(ADDRESS_HOME_ZIP)).obj(), | |
60 ConvertUTF16ToJavaString( | |
61 env, | |
62 profile.GetRawInfo(ADDRESS_HOME_SORTING_CODE)).obj(), | |
63 ConvertUTF16ToJavaString( | |
64 env, | |
65 profile.GetInfo(AutofillType(ADDRESS_HOME_COUNTRY), | |
66 g_browser_process->GetApplicationLocale())).obj(), | |
67 ConvertUTF16ToJavaString( | |
68 env, | |
69 profile.GetRawInfo(PHONE_HOME_WHOLE_NUMBER)).obj(), | |
70 ConvertUTF16ToJavaString(env, profile.GetRawInfo(EMAIL_ADDRESS)).obj(), | 60 ConvertUTF16ToJavaString(env, profile.GetRawInfo(EMAIL_ADDRESS)).obj(), |
71 ConvertUTF8ToJavaString(env, profile.language_code()).obj()); | 61 ConvertUTF8ToJavaString(env, profile.language_code()).obj()); |
72 } | 62 } |
73 | 63 |
74 void PopulateNativeProfileFromJava( | 64 void PopulateNativeProfileFromJava( |
75 const jobject& jprofile, | 65 const jobject& jprofile, |
76 JNIEnv* env, | 66 JNIEnv* env, |
77 AutofillProfile* profile) { | 67 AutofillProfile* profile) { |
78 profile->set_origin( | 68 profile->set_origin( |
79 ConvertJavaStringToUTF8( | 69 ConvertJavaStringToUTF8( |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 profile->SetInfo( | 101 profile->SetInfo( |
112 AutofillType(ADDRESS_HOME_ZIP), | 102 AutofillType(ADDRESS_HOME_ZIP), |
113 ConvertJavaStringToUTF16( | 103 ConvertJavaStringToUTF16( |
114 Java_AutofillProfile_getPostalCode(env, jprofile)), | 104 Java_AutofillProfile_getPostalCode(env, jprofile)), |
115 g_browser_process->GetApplicationLocale()); | 105 g_browser_process->GetApplicationLocale()); |
116 profile->SetInfo( | 106 profile->SetInfo( |
117 AutofillType(ADDRESS_HOME_SORTING_CODE), | 107 AutofillType(ADDRESS_HOME_SORTING_CODE), |
118 ConvertJavaStringToUTF16( | 108 ConvertJavaStringToUTF16( |
119 Java_AutofillProfile_getSortingCode(env, jprofile)), | 109 Java_AutofillProfile_getSortingCode(env, jprofile)), |
120 g_browser_process->GetApplicationLocale()); | 110 g_browser_process->GetApplicationLocale()); |
121 profile->SetInfo( | 111 profile->SetInfo(AutofillType(ADDRESS_HOME_COUNTRY), |
122 AutofillType(ADDRESS_HOME_COUNTRY), | 112 ConvertJavaStringToUTF16( |
123 ConvertJavaStringToUTF16( | 113 Java_AutofillProfile_getCountryCode(env, jprofile)), |
124 Java_AutofillProfile_getCountry(env, jprofile)), | 114 g_browser_process->GetApplicationLocale()); |
125 g_browser_process->GetApplicationLocale()); | |
126 profile->SetInfo( | 115 profile->SetInfo( |
127 AutofillType(PHONE_HOME_WHOLE_NUMBER), | 116 AutofillType(PHONE_HOME_WHOLE_NUMBER), |
128 ConvertJavaStringToUTF16( | 117 ConvertJavaStringToUTF16( |
129 Java_AutofillProfile_getPhoneNumber(env, jprofile)), | 118 Java_AutofillProfile_getPhoneNumber(env, jprofile)), |
130 g_browser_process->GetApplicationLocale()); | 119 g_browser_process->GetApplicationLocale()); |
131 profile->SetInfo( | 120 profile->SetInfo( |
132 AutofillType(EMAIL_ADDRESS), | 121 AutofillType(EMAIL_ADDRESS), |
133 ConvertJavaStringToUTF16( | 122 ConvertJavaStringToUTF16( |
134 Java_AutofillProfile_getEmailAddress(env, jprofile)), | 123 Java_AutofillProfile_getEmailAddress(env, jprofile)), |
135 g_browser_process->GetApplicationLocale()); | 124 g_browser_process->GetApplicationLocale()); |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
347 g_browser_process->GetApplicationLocale())).Release(); | 336 g_browser_process->GetApplicationLocale())).Release(); |
348 } | 337 } |
349 | 338 |
350 static jlong Init(JNIEnv* env, jobject obj) { | 339 static jlong Init(JNIEnv* env, jobject obj) { |
351 PersonalDataManagerAndroid* personal_data_manager_android = | 340 PersonalDataManagerAndroid* personal_data_manager_android = |
352 new PersonalDataManagerAndroid(env, obj); | 341 new PersonalDataManagerAndroid(env, obj); |
353 return reinterpret_cast<intptr_t>(personal_data_manager_android); | 342 return reinterpret_cast<intptr_t>(personal_data_manager_android); |
354 } | 343 } |
355 | 344 |
356 } // namespace autofill | 345 } // namespace autofill |
OLD | NEW |