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

Side by Side Diff: chrome/browser/android/preferences/autofill/autofill_profile_bridge.cc

Issue 1312153003: jni_generator: Pass object parameters as JavaParamRef. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years, 3 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/android/preferences/autofill/autofill_profile_bridge.h" 5 #include "chrome/browser/android/preferences/autofill/autofill_profile_bridge.h"
6 6
7 #include <jni.h> 7 #include <jni.h>
8 8
9 #include "base/android/jni_android.h" 9 #include "base/android/jni_android.h"
10 #include "base/android/jni_array.h" 10 #include "base/android/jni_array.h"
(...skipping 28 matching lines...) Expand all
39 // a suburb). 39 // a suburb).
40 SORTING_CODE, // Sorting code. 40 SORTING_CODE, // Sorting code.
41 POSTAL_CODE, // Zip or postal code. 41 POSTAL_CODE, // Zip or postal code.
42 STREET_ADDRESS, // Street address lines. 42 STREET_ADDRESS, // Street address lines.
43 ORGANIZATION, // Organization, company, firm, institution, etc. 43 ORGANIZATION, // Organization, company, firm, institution, etc.
44 RECIPIENT // Name. 44 RECIPIENT // Name.
45 }; 45 };
46 46
47 } // namespace 47 } // namespace
48 48
49 static ScopedJavaLocalRef<jstring> GetDefaultCountryCode(JNIEnv* env, 49 static ScopedJavaLocalRef<jstring> GetDefaultCountryCode(
50 jclass clazz) { 50 JNIEnv* env,
51 const JavaParamRef<jclass>& clazz) {
51 std::string default_country_code = 52 std::string default_country_code =
52 autofill::AutofillCountry::CountryCodeForLocale( 53 autofill::AutofillCountry::CountryCodeForLocale(
53 g_browser_process->GetApplicationLocale()); 54 g_browser_process->GetApplicationLocale());
54 return ConvertUTF8ToJavaString(env, default_country_code); 55 return ConvertUTF8ToJavaString(env, default_country_code);
55 } 56 }
56 57
57 static void GetSupportedCountries(JNIEnv* env, 58 static void GetSupportedCountries(
58 jclass clazz, 59 JNIEnv* env,
59 jobject j_country_code_list, 60 const JavaParamRef<jclass>& clazz,
60 jobject j_country_name_list) { 61 const JavaParamRef<jobject>& j_country_code_list,
62 const JavaParamRef<jobject>& j_country_name_list) {
61 std::vector<std::string> country_codes = 63 std::vector<std::string> country_codes =
62 ::i18n::addressinput::GetRegionCodes(); 64 ::i18n::addressinput::GetRegionCodes();
63 std::vector<std::string> known_country_codes; 65 std::vector<std::string> known_country_codes;
64 std::vector<base::string16> known_country_names; 66 std::vector<base::string16> known_country_names;
65 std::string locale = g_browser_process->GetApplicationLocale(); 67 std::string locale = g_browser_process->GetApplicationLocale();
66 for (auto country_code : country_codes) { 68 for (auto country_code : country_codes) {
67 const base::string16& country_name = 69 const base::string16& country_name =
68 l10n_util::GetDisplayNameForCountry(country_code, locale); 70 l10n_util::GetDisplayNameForCountry(country_code, locale);
69 // Don't display a country code for which a name is not known yet. 71 // Don't display a country code for which a name is not known yet.
70 if (country_name != base::UTF8ToUTF16(country_code)) { 72 if (country_name != base::UTF8ToUTF16(country_code)) {
71 known_country_codes.push_back(country_code); 73 known_country_codes.push_back(country_code);
72 known_country_names.push_back(country_name); 74 known_country_names.push_back(country_name);
73 } 75 }
74 } 76 }
75 77
76 Java_AutofillProfileBridge_stringArrayToList( 78 Java_AutofillProfileBridge_stringArrayToList(
77 env, ToJavaArrayOfStrings(env, known_country_codes).obj(), 79 env, ToJavaArrayOfStrings(env, known_country_codes).obj(),
78 j_country_code_list); 80 j_country_code_list);
79 Java_AutofillProfileBridge_stringArrayToList( 81 Java_AutofillProfileBridge_stringArrayToList(
80 env, ToJavaArrayOfStrings(env, known_country_names).obj(), 82 env, ToJavaArrayOfStrings(env, known_country_names).obj(),
81 j_country_name_list); 83 j_country_name_list);
82 } 84 }
83 85
84 static ScopedJavaLocalRef<jstring> GetAddressUiComponents( 86 static ScopedJavaLocalRef<jstring> GetAddressUiComponents(
85 JNIEnv* env, 87 JNIEnv* env,
86 jclass clazz, 88 const JavaParamRef<jclass>& clazz,
87 jstring j_country_code, 89 const JavaParamRef<jstring>& j_country_code,
88 jstring j_language_code, 90 const JavaParamRef<jstring>& j_language_code,
89 jobject j_id_list, 91 const JavaParamRef<jobject>& j_id_list,
90 jobject j_name_list) { 92 const JavaParamRef<jobject>& j_name_list) {
91 std::string best_language_tag; 93 std::string best_language_tag;
92 std::vector<int> component_ids; 94 std::vector<int> component_ids;
93 std::vector<std::string> component_labels; 95 std::vector<std::string> component_labels;
94 ::i18n::addressinput::Localization localization; 96 ::i18n::addressinput::Localization localization;
95 localization.SetGetter(l10n_util::GetStringUTF8); 97 localization.SetGetter(l10n_util::GetStringUTF8);
96 98
97 std::string language_code; 99 std::string language_code;
98 if (j_language_code != NULL) { 100 if (j_language_code != NULL) {
99 language_code = ConvertJavaStringToUTF8(env, j_language_code); 101 language_code = ConvertJavaStringToUTF8(env, j_language_code);
100 } 102 }
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 156
155 return ConvertUTF8ToJavaString(env, best_language_tag); 157 return ConvertUTF8ToJavaString(env, best_language_tag);
156 } 158 }
157 159
158 // static 160 // static
159 bool RegisterAutofillProfileBridge(JNIEnv* env) { 161 bool RegisterAutofillProfileBridge(JNIEnv* env) {
160 return RegisterNativesImpl(env); 162 return RegisterNativesImpl(env);
161 } 163 }
162 164
163 } // namespace autofill 165 } // namespace autofill
OLDNEW
« no previous file with comments | « chrome/browser/android/precache/precache_launcher.cc ('k') | chrome/browser/android/preferences/pref_service_bridge.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698