Chromium Code Reviews| Index: chrome/browser/autofill/android/auxiliary_profile_loader_android.cc |
| diff --git a/chrome/browser/autofill/android/auxiliary_profile_loader_android.cc b/chrome/browser/autofill/android/auxiliary_profile_loader_android.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..f74fb9e845cb289e188e7bb1894fd52197c055c5 |
| --- /dev/null |
| +++ b/chrome/browser/autofill/android/auxiliary_profile_loader_android.cc |
| @@ -0,0 +1,99 @@ |
| +// Copyright 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_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__(\ |
|
Ilya Sherman
2013/03/11 22:39:44
nit: Please leave a space before the backslash.
apiccion
2013/03/13 20:17:28
Done.
|
| + env_,\ |
|
Ilya Sherman
2013/03/11 22:39:44
nit: Please leave a space before the backslash.
apiccion
2013/03/13 20:17:28
Done.
|
| + populator_.obj()) |
| + |
| +using base::android::SafeJavaStringToUTF16; |
| + |
| +namespace autofill { |
| + |
| +bool RegisterAuxiliaryProfileLoader(JNIEnv* env) { |
| + return RegisterNativesImpl(env); |
| +} |
| + |
| +AuxiliaryProfileLoaderAndroid::AuxiliaryProfileLoaderAndroid() {} |
| + |
| +AuxiliaryProfileLoaderAndroid::~AuxiliaryProfileLoaderAndroid() { |
| +} |
|
Ilya Sherman
2013/03/11 22:39:44
nit: Please be consistent about "{}" on the same l
apiccion
2013/03/13 20:17:28
Done.
|
| + |
| +void AuxiliaryProfileLoaderAndroid::Init(JNIEnv* env, const jobject& context) { |
| + env_ = env; |
| + populator_ = Java_PersonalAutofillPopulator_create(env_, context); |
| +} |
| + |
| +// Address info |
| +string16 AuxiliaryProfileLoaderAndroid::GetStreet() const { |
| + return SafeJavaStringToUTF16(JAVA_METHOD(getStreet)); |
| +} |
| + |
| +string16 AuxiliaryProfileLoaderAndroid::GetPostOfficeBox() const { |
| + return SafeJavaStringToUTF16(JAVA_METHOD(getPobox)); |
| +} |
| + |
| +string16 AuxiliaryProfileLoaderAndroid::GetNeighborhood() const { |
| + return SafeJavaStringToUTF16(JAVA_METHOD(getNeighborhood)); |
| +} |
| + |
| +string16 AuxiliaryProfileLoaderAndroid::GetRegion() const { |
| + return SafeJavaStringToUTF16(JAVA_METHOD(getRegion)); |
| +} |
| + |
| +string16 AuxiliaryProfileLoaderAndroid::GetCity() const { |
| + return SafeJavaStringToUTF16(JAVA_METHOD(getCity)); |
| +} |
| + |
| +string16 AuxiliaryProfileLoaderAndroid::GetPostalCode() const { |
| + return SafeJavaStringToUTF16(JAVA_METHOD(getPostalCode)); |
| +} |
| + |
| +string16 AuxiliaryProfileLoaderAndroid::GetCountry() const { |
| + return SafeJavaStringToUTF16(JAVA_METHOD(getCountry)); |
| +} |
| + |
| +// Name info |
| +string16 AuxiliaryProfileLoaderAndroid::GetFirstName() const { |
| + return SafeJavaStringToUTF16(JAVA_METHOD(getFirstName)); |
| +} |
| + |
| +string16 AuxiliaryProfileLoaderAndroid::GetMiddleName() const { |
| + return SafeJavaStringToUTF16(JAVA_METHOD(getMiddleName)); |
| +} |
| + |
| +string16 AuxiliaryProfileLoaderAndroid::GetLastName() const { |
| + return SafeJavaStringToUTF16(JAVA_METHOD(getLastName)); |
| +} |
| + |
| +string16 AuxiliaryProfileLoaderAndroid::GetSuffix() const { |
| + return SafeJavaStringToUTF16(JAVA_METHOD(getSuffix)); |
| +} |
| + |
| +// Email info |
| +void AuxiliaryProfileLoaderAndroid::GetEmailAddresses( |
| + std::vector<string16>* email_addresses) const { |
| + SafeJavaStringArrayToStringVector(JAVA_METHOD(getEmailAddresses), |
| + env_, |
| + email_addresses); |
| +} |
| + |
| +// Phone info |
| +void AuxiliaryProfileLoaderAndroid::GetPhoneNumbers( |
| + std::vector<string16>* phone_numbers) const { |
| + SafeJavaStringArrayToStringVector(JAVA_METHOD(getPhoneNumbers), |
| + env_, |
| + phone_numbers); |
| +} |
| + |
| +} // namespace |