Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3027)

Unified Diff: chrome/browser/ui/android/autofill/country_adapter_android.cc

Issue 436563005: Turn Autofill country text input into a Spinner. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix findbugs found bugs Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..b47fd1bd8f51baf65f83b1aa448d4720cd5b7744
--- /dev/null
+++ b/chrome/browser/ui/android/autofill/country_adapter_android.cc
@@ -0,0 +1,55 @@
+// Copyright 2014 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/ui/android/autofill/country_adapter_android.h"
+
+#include "base/android/jni_array.h"
+#include "base/android/jni_string.h"
+#include "base/strings/utf_string_conversions.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"
+
+namespace autofill {
+
+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() {}
+
+ScopedJavaLocalRef<jobjectArray> CountryAdapterAndroid::GetItems(
+ JNIEnv* env,
+ jobject unused_obj) {
+ std::vector<base::string16> country_names_and_codes;
+ country_names_and_codes.reserve(
+ 2 * country_combobox_model_.countries().size());
+
+ for (size_t i = 0; i < country_combobox_model_.countries().size(); ++i) {
+ country_names_and_codes.push_back(
+ country_combobox_model_.countries()[i]->name());
+ country_names_and_codes.push_back(base::ASCIIToUTF16(
+ country_combobox_model_.countries()[i]->country_code()));
+ }
+
+ return base::android::ToJavaArrayOfStrings(env, country_names_and_codes);
+}
+
+// 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
« no previous file with comments | « chrome/browser/ui/android/autofill/country_adapter_android.h ('k') | chrome/browser/ui/autofill/country_combobox_model.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698