Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | |
|
aurimas (slooooooooow)
2014/08/01 15:18:21
s/2013/2014
| |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/browser/ui/android/autofill/country_adapter_android.h" | |
| 6 | |
| 7 #include "base/android/jni_string.h" | |
| 8 #include "chrome/browser/autofill/personal_data_manager_factory.h" | |
| 9 #include "chrome/browser/profiles/profile_manager.h" | |
| 10 #include "components/autofill/core/browser/autofill_country.h" | |
| 11 #include "jni/CountryAdapter_jni.h" | |
| 12 | |
| 13 using base::android::ConvertUTF8ToJavaString; | |
| 14 using base::android::ConvertUTF16ToJavaString; | |
| 15 using base::android::ScopedJavaLocalRef; | |
| 16 | |
| 17 namespace autofill { | |
| 18 | |
| 19 /* | |
| 20 ScopedJavaLocalRef<jobject> CreateJavaCountryFromNative( | |
|
aurimas (slooooooooow)
2014/08/01 15:18:21
Can this be deleted?
Evan Stade
2014/08/04 20:36:04
Done.
| |
| 21 JNIEnv* env, | |
| 22 const AutofillCountry& country) { | |
| 23 return Java_AutofillCountry_create( | |
| 24 env, | |
| 25 ConvertUTF8ToJavaString(env, country.)).obj(), | |
| 26 ConvertUTF16ToJavaString(env, profile.origin()).obj()); | |
| 27 } | |
| 28 */ | |
| 29 | |
| 30 CountryAdapterAndroid::CountryAdapterAndroid(JNIEnv* env, jobject obj) | |
| 31 : weak_java_obj_(env, obj) { | |
| 32 country_combobox_model_.SetCountries( | |
| 33 *PersonalDataManagerFactory::GetForProfile( | |
| 34 ProfileManager::GetActiveUserProfile()), | |
| 35 base::Callback<bool(const std::string&)>()); | |
| 36 } | |
| 37 | |
| 38 CountryAdapterAndroid::~CountryAdapterAndroid() { | |
| 39 } | |
| 40 | |
| 41 jint CountryAdapterAndroid::GetItemCount(JNIEnv* unused_env, | |
| 42 jobject unused_obj) { | |
| 43 return country_combobox_model_.GetItemCount(); | |
| 44 } | |
| 45 | |
| 46 ScopedJavaLocalRef<jstring> CountryAdapterAndroid::GetCountryCodeAt( | |
| 47 JNIEnv* env, | |
| 48 jobject unused_obj, | |
| 49 jint position) { | |
| 50 return ConvertUTF8ToJavaString( | |
| 51 env, country_combobox_model_.countries()[position]->country_code()); | |
| 52 } | |
| 53 | |
| 54 ScopedJavaLocalRef<jstring> CountryAdapterAndroid::GetCountryNameAt( | |
| 55 JNIEnv* env, | |
| 56 jobject unused_obj, | |
| 57 jint position) { | |
| 58 return ConvertUTF16ToJavaString(env, | |
| 59 country_combobox_model_.GetItemAt(position)); | |
| 60 } | |
| 61 | |
| 62 // static | |
| 63 bool CountryAdapterAndroid::Register(JNIEnv* env) { | |
| 64 return RegisterNativesImpl(env); | |
| 65 } | |
| 66 | |
| 67 static jlong Init(JNIEnv* env, jobject obj) { | |
| 68 CountryAdapterAndroid* country_adapter_android = | |
| 69 new CountryAdapterAndroid(env, obj); | |
| 70 return reinterpret_cast<intptr_t>(country_adapter_android); | |
| 71 } | |
| 72 | |
| 73 } // namespace autofill | |
| OLD | NEW |