Index: chrome/android/java/src/org/chromium/chrome/browser/preferences/autofill/AutofillProfileBridge.java |
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/preferences/autofill/AutofillProfileBridge.java b/chrome/android/java/src/org/chromium/chrome/browser/preferences/autofill/AutofillProfileBridge.java |
new file mode 100644 |
index 0000000000000000000000000000000000000000..3482fb7c112bc4bb38df3c4cc45be937ef4698c8 |
--- /dev/null |
+++ b/chrome/android/java/src/org/chromium/chrome/browser/preferences/autofill/AutofillProfileBridge.java |
@@ -0,0 +1,68 @@ |
+// Copyright 2015 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. |
+ |
+package org.chromium.chrome.browser.preferences.autofill; |
+ |
+import android.util.Pair; |
+ |
+import org.chromium.base.CalledByNative; |
+ |
+import java.util.ArrayList; |
+import java.util.List; |
+ |
+/** |
+ * Static methods to fetch information needed to create the address fields for the autofill profile |
+ * form. |
+ */ |
+public class AutofillProfileBridge { |
+ /** |
+ * @return A list of supported CLDR region codes. |
newt (away)
2015/01/28 20:20:18
s/A/The
Theresa
2015/01/29 05:22:13
Done.
|
+ */ |
+ public static List<String> getAvailableCountries() { |
newt (away)
2015/01/28 20:20:19
for consistent terminology, how about calling this
Theresa
2015/01/29 05:22:13
Done, kind of. I changed it to getSupportedCountri
|
+ List<String> countries = new ArrayList<String>(); |
+ nativeGetAvailableCountries(countries); |
+ return countries; |
+ } |
+ |
+ /** |
+ * Returns the UI components for the CLDR countryCode provided. The components will be in |
+ * default or Latin order depending on the BCP 47 uiLanguageTag provided. |
+ * |
+ * @param countryCode The CLDR code used to retrieve address components. |
+ * @param uiLanguageTag The current UI language; helps determine the field order |
+ * @return A list containing pairs of strings, where the first element in the pair is the |
+ * component id corresponds to an AddressField enum value in address_field.h, |
+ * and the second element in the pair is the localized component name (intended |
+ * for use as labels in the UI). |
+ */ |
+ public static List<Pair<Integer, String>> getAddressUiComponents(String countryCode, |
newt (away)
2015/01/28 20:20:18
I'd make this package private instead of public. I
Theresa
2015/01/29 05:22:13
I made it package protected. Just returning a Stri
|
+ String uiLanguageTag) { |
+ List<Integer> componentIds = new ArrayList<Integer>(); |
+ List<String> componentNames = new ArrayList<String>(); |
+ List<Pair<Integer, String>> uiComponents = new ArrayList<Pair<Integer, String>>(); |
+ nativeGetAddressUiComponents(countryCode, uiLanguageTag, componentIds, componentNames); |
+ for (int i = 0; i < componentIds.size(); i++) { |
+ uiComponents.add(new Pair<Integer, String>(componentIds.get(i), componentNames.get(i))); |
+ } |
+ return uiComponents; |
+ } |
+ |
+ @CalledByNative |
+ private static void stringArrayToList(String[] array, List<String> list) { |
newt (away)
2015/01/28 20:20:18
Similar methods actually already exist in jni_arra
Theresa
2015/01/29 05:22:13
Yes, I saw that method; it doesn't do what I want
newt (away)
2015/01/29 20:00:36
Agreed. Sadly, despite the plethora of methods in
|
+ for (String s : array) { |
+ list.add(s); |
+ } |
+ } |
+ |
+ @CalledByNative |
+ private static void intArrayToList(int[] array, List<Integer> list) { |
+ for (int s : array) { |
+ list.add(s); |
+ } |
+ } |
+ |
+ private static native void nativeGetAvailableCountries(List<String> countries); |
+ private static native void nativeGetAddressUiComponents(String countryCode, |
+ String uiLanguageTag, List<Integer> componentIds, List<String> componentNames); |
+} |