Chromium Code Reviews| Index: chrome/browser/ui/android/autofill/country_adapter_android.cc |
| diff --git a/chrome/browser/ui/android/autofill/country_adapter_android.cc b/chrome/browser/ui/android/autofill/country_adapter_android.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..573507fd6e5fc48d151bdc3f4cf1e4e3a3637fad |
| --- /dev/null |
| +++ b/chrome/browser/ui/android/autofill/country_adapter_android.cc |
| @@ -0,0 +1,73 @@ |
| +// Copyright 2013 The Chromium Authors. All rights reserved. |
|
aurimas (slooooooooow)
2014/08/01 15:18:21
s/2013/2014
|
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "chrome/browser/ui/android/autofill/country_adapter_android.h" |
| + |
| +#include "base/android/jni_string.h" |
| +#include "chrome/browser/autofill/personal_data_manager_factory.h" |
| +#include "chrome/browser/profiles/profile_manager.h" |
| +#include "components/autofill/core/browser/autofill_country.h" |
| +#include "jni/CountryAdapter_jni.h" |
| + |
| +using base::android::ConvertUTF8ToJavaString; |
| +using base::android::ConvertUTF16ToJavaString; |
| +using base::android::ScopedJavaLocalRef; |
| + |
| +namespace autofill { |
| + |
| +/* |
| +ScopedJavaLocalRef<jobject> CreateJavaCountryFromNative( |
|
aurimas (slooooooooow)
2014/08/01 15:18:21
Can this be deleted?
Evan Stade
2014/08/04 20:36:04
Done.
|
| + JNIEnv* env, |
| + const AutofillCountry& country) { |
| + return Java_AutofillCountry_create( |
| + env, |
| + ConvertUTF8ToJavaString(env, country.)).obj(), |
| + ConvertUTF16ToJavaString(env, profile.origin()).obj()); |
| +} |
| +*/ |
| + |
| +CountryAdapterAndroid::CountryAdapterAndroid(JNIEnv* env, jobject obj) |
| + : weak_java_obj_(env, obj) { |
| + country_combobox_model_.SetCountries( |
| + *PersonalDataManagerFactory::GetForProfile( |
| + ProfileManager::GetActiveUserProfile()), |
| + base::Callback<bool(const std::string&)>()); |
| +} |
| + |
| +CountryAdapterAndroid::~CountryAdapterAndroid() { |
| +} |
| + |
| +jint CountryAdapterAndroid::GetItemCount(JNIEnv* unused_env, |
| + jobject unused_obj) { |
| + return country_combobox_model_.GetItemCount(); |
| +} |
| + |
| +ScopedJavaLocalRef<jstring> CountryAdapterAndroid::GetCountryCodeAt( |
| + JNIEnv* env, |
| + jobject unused_obj, |
| + jint position) { |
| + return ConvertUTF8ToJavaString( |
| + env, country_combobox_model_.countries()[position]->country_code()); |
| +} |
| + |
| +ScopedJavaLocalRef<jstring> CountryAdapterAndroid::GetCountryNameAt( |
| + JNIEnv* env, |
| + jobject unused_obj, |
| + jint position) { |
| + return ConvertUTF16ToJavaString(env, |
| + country_combobox_model_.GetItemAt(position)); |
| +} |
| + |
| +// static |
| +bool CountryAdapterAndroid::Register(JNIEnv* env) { |
| + return RegisterNativesImpl(env); |
| +} |
| + |
| +static jlong Init(JNIEnv* env, jobject obj) { |
| + CountryAdapterAndroid* country_adapter_android = |
| + new CountryAdapterAndroid(env, obj); |
| + return reinterpret_cast<intptr_t>(country_adapter_android); |
| +} |
| + |
| +} // namespace autofill |