Chromium Code Reviews| Index: chrome/browser/autofill/android/auxiliary_profile_loader_impl_android.cc |
| diff --git a/chrome/browser/autofill/android/auxiliary_profile_loader_impl_android.cc b/chrome/browser/autofill/android/auxiliary_profile_loader_impl_android.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..5b7caffc1cc539207fb3ff64169921c68a14de44 |
| --- /dev/null |
| +++ b/chrome/browser/autofill/android/auxiliary_profile_loader_impl_android.cc |
| @@ -0,0 +1,95 @@ |
| +// Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "chrome/browser/autofill/android/auxiliary_profile_loader_impl_android.h" |
| + |
| +#include <vector> |
| + |
| +#include "base/android/jni_android.h" |
| +#include "base/android/jni_array.h" |
| +#include "base/android/jni_local_ref_extensions.h" |
| +#include "base/android/jni_string.h" |
| +#include "jni/PersonalAutofillPopulator_jni.h" |
| + |
| +#define JAVA_METHOD(__jmethod__) Java_PersonalAutofillPopulator_##__jmethod__(\ |
| + env_,\ |
| + populator_.obj()) |
| + |
| +bool RegisterAuxiliaryProfileLoader(JNIEnv* env) { |
| + return RegisterNativesImpl(env); |
| +} |
| + |
| +namespace autofill { |
| + |
| +AuxiliaryProfileLoaderImplAndroid::AuxiliaryProfileLoaderImplAndroid() |
| + : env_(base::android::AttachCurrentThread()), |
|
Ilya Sherman
2013/03/05 00:42:38
nit: Indent this two more spaces.
apiccion
2013/03/09 00:53:41
Done.
|
| + populator_(Java_PersonalAutofillPopulator_create(env_, |
|
Ilya Sherman
2013/03/05 00:42:38
nit: Indent this four more spaces.
|
| + base::android::GetApplicationContext())) {} |
|
Ilya Sherman
2013/03/05 00:42:38
nit: This should either be on the same line as |en
apiccion
2013/03/09 00:53:41
Can't without going over 80 chars.
|
| + |
| +AuxiliaryProfileLoaderImplAndroid::~AuxiliaryProfileLoaderImplAndroid() { |
| +} |
| + |
| +// Address info |
| +string16 AuxiliaryProfileLoaderImplAndroid::GetStreet() const { |
| + return SafeJavaStringToUTF16(JAVA_METHOD(getStreet)); |
|
Ilya Sherman
2013/03/05 00:42:38
Did you mean to add "using base::android::SafeJava
apiccion
2013/03/09 00:53:41
Done.
|
| +} |
| + |
| +string16 AuxiliaryProfileLoaderImplAndroid::GetPostOfficeBox() const { |
| + return SafeJavaStringToUTF16(JAVA_METHOD(getPobox)); |
| +} |
| + |
| +string16 AuxiliaryProfileLoaderImplAndroid::GetNeighborhood() const { |
| + return SafeJavaStringToUTF16(JAVA_METHOD(getNeighborhood)); |
| +} |
| + |
| +string16 AuxiliaryProfileLoaderImplAndroid::GetRegion() const { |
| + return SafeJavaStringToUTF16(JAVA_METHOD(getRegion)); |
| +} |
| + |
| +string16 AuxiliaryProfileLoaderImplAndroid::GetCity() const { |
| + return SafeJavaStringToUTF16(JAVA_METHOD(getCity)); |
| +} |
| + |
| +string16 AuxiliaryProfileLoaderImplAndroid::GetPostalCode() const { |
| + return SafeJavaStringToUTF16(JAVA_METHOD(getPostalCode)); |
| +} |
| + |
| +string16 AuxiliaryProfileLoaderImplAndroid::GetCountry() const { |
| + return SafeJavaStringToUTF16(JAVA_METHOD(getCountry)); |
| +} |
| + |
| +// Name info |
| +string16 AuxiliaryProfileLoaderImplAndroid::GetFirstName() const { |
| + return SafeJavaStringToUTF16(JAVA_METHOD(getFirstName)); |
| +} |
| + |
| +string16 AuxiliaryProfileLoaderImplAndroid::GetMiddleName() const { |
| + return SafeJavaStringToUTF16(JAVA_METHOD(getMiddleName)); |
| +} |
| + |
| +string16 AuxiliaryProfileLoaderImplAndroid::GetLastName() const { |
| + return SafeJavaStringToUTF16(JAVA_METHOD(getLastName)); |
| +} |
| + |
| +string16 AuxiliaryProfileLoaderImplAndroid::GetSuffix() const { |
| + return SafeJavaStringToUTF16(JAVA_METHOD(getSuffix)); |
| +} |
| + |
| +// Email info |
| +void AuxiliaryProfileLoaderImplAndroid::GetEmailAddresses( |
| + std::vector<string16>* strVector) const { |
|
Ilya Sherman
2013/03/05 00:42:38
nit: "strVector" -> "emails"
apiccion
2013/03/09 00:53:41
Done.
|
| + SafeJavaStringArrayToStringVector(JAVA_METHOD(getEmailAddresses), |
| + env_, |
| + strVector); |
| +} |
| + |
| +// Phone info |
| +void AuxiliaryProfileLoaderImplAndroid::GetPhoneNumbers( |
| + std::vector<string16>* strVector) const { |
|
Ilya Sherman
2013/03/05 00:42:38
nit: "strVector" -> "phone_numbers"
apiccion
2013/03/09 00:53:41
Done.
|
| + SafeJavaStringArrayToStringVector(JAVA_METHOD(getPhoneNumbers), |
| + env_, |
| + strVector); |
| +} |
| + |
| +} // namespace |