OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/autofill/android/personal_data_manager_android.h" | 5 #include "chrome/browser/autofill/android/personal_data_manager_android.h" |
6 | 6 |
7 #include "base/android/jni_array.h" | 7 #include "base/android/jni_array.h" |
8 #include "base/android/jni_string.h" | 8 #include "base/android/jni_string.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/format_macros.h" | 10 #include "base/format_macros.h" |
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 Java_PersonalDataManager_personalDataChanged(env, | 298 Java_PersonalDataManager_personalDataChanged(env, |
299 weak_java_obj_.get(env).obj()); | 299 weak_java_obj_.get(env).obj()); |
300 } | 300 } |
301 | 301 |
302 // static | 302 // static |
303 bool PersonalDataManagerAndroid::Register(JNIEnv* env) { | 303 bool PersonalDataManagerAndroid::Register(JNIEnv* env) { |
304 return RegisterNativesImpl(env); | 304 return RegisterNativesImpl(env); |
305 } | 305 } |
306 | 306 |
307 // Returns whether the Autofill feature is enabled. | 307 // Returns whether the Autofill feature is enabled. |
308 static jboolean IsAutofillEnabled(JNIEnv* env, jclass clazz) { | 308 static jboolean IsAutofillEnabled(JNIEnv* env, |
| 309 const JavaParamRef<jclass>& clazz) { |
309 return GetPrefs()->GetBoolean(autofill::prefs::kAutofillEnabled); | 310 return GetPrefs()->GetBoolean(autofill::prefs::kAutofillEnabled); |
310 } | 311 } |
311 | 312 |
312 // Enables or disables the Autofill feature. | 313 // Enables or disables the Autofill feature. |
313 static void SetAutofillEnabled(JNIEnv* env, jclass clazz, jboolean enable) { | 314 static void SetAutofillEnabled(JNIEnv* env, |
| 315 const JavaParamRef<jclass>& clazz, |
| 316 jboolean enable) { |
314 GetPrefs()->SetBoolean(autofill::prefs::kAutofillEnabled, enable); | 317 GetPrefs()->SetBoolean(autofill::prefs::kAutofillEnabled, enable); |
315 } | 318 } |
316 | 319 |
317 // Returns whether the Autofill feature is managed. | 320 // Returns whether the Autofill feature is managed. |
318 static jboolean IsAutofillManaged(JNIEnv* env, jclass clazz) { | 321 static jboolean IsAutofillManaged(JNIEnv* env, |
| 322 const JavaParamRef<jclass>& clazz) { |
319 return GetPrefs()->IsManagedPreference(autofill::prefs::kAutofillEnabled); | 323 return GetPrefs()->IsManagedPreference(autofill::prefs::kAutofillEnabled); |
320 } | 324 } |
321 | 325 |
322 // Returns whether the Wallet import feature is available. | 326 // Returns whether the Wallet import feature is available. |
323 static jboolean IsWalletImportFeatureAvailable(JNIEnv* env, jclass clazz) { | 327 static jboolean IsWalletImportFeatureAvailable( |
| 328 JNIEnv* env, |
| 329 const JavaParamRef<jclass>& clazz) { |
324 return WalletIntegrationAvailableForProfile(GetProfile()); | 330 return WalletIntegrationAvailableForProfile(GetProfile()); |
325 } | 331 } |
326 | 332 |
327 // Returns whether the Wallet import feature is enabled. | 333 // Returns whether the Wallet import feature is enabled. |
328 static jboolean IsWalletImportEnabled(JNIEnv* env, jclass clazz) { | 334 static jboolean IsWalletImportEnabled(JNIEnv* env, |
| 335 const JavaParamRef<jclass>& clazz) { |
329 return GetPrefs()->GetBoolean(autofill::prefs::kAutofillWalletImportEnabled); | 336 return GetPrefs()->GetBoolean(autofill::prefs::kAutofillWalletImportEnabled); |
330 } | 337 } |
331 | 338 |
332 // Enables or disables the Wallet import feature. | 339 // Enables or disables the Wallet import feature. |
333 static void SetWalletImportEnabled(JNIEnv* env, jclass clazz, jboolean enable) { | 340 static void SetWalletImportEnabled(JNIEnv* env, |
| 341 const JavaParamRef<jclass>& clazz, |
| 342 jboolean enable) { |
334 GetPrefs()->SetBoolean(autofill::prefs::kAutofillWalletImportEnabled, enable); | 343 GetPrefs()->SetBoolean(autofill::prefs::kAutofillWalletImportEnabled, enable); |
335 } | 344 } |
336 | 345 |
337 // Returns an ISO 3166-1-alpha-2 country code for a |jcountry_name| using | 346 // Returns an ISO 3166-1-alpha-2 country code for a |jcountry_name| using |
338 // the application locale, or an empty string. | 347 // the application locale, or an empty string. |
339 static ScopedJavaLocalRef<jstring> ToCountryCode(JNIEnv* env, | 348 static ScopedJavaLocalRef<jstring> ToCountryCode( |
340 jclass clazz, | 349 JNIEnv* env, |
341 jstring jcountry_name) { | 350 const JavaParamRef<jclass>& clazz, |
| 351 const JavaParamRef<jstring>& jcountry_name) { |
342 return ConvertUTF8ToJavaString( | 352 return ConvertUTF8ToJavaString( |
343 env, AutofillCountry::GetCountryCode( | 353 env, AutofillCountry::GetCountryCode( |
344 base::android::ConvertJavaStringToUTF16(env, jcountry_name), | 354 base::android::ConvertJavaStringToUTF16(env, jcountry_name), |
345 g_browser_process->GetApplicationLocale())); | 355 g_browser_process->GetApplicationLocale())); |
346 } | 356 } |
347 | 357 |
348 static jlong Init(JNIEnv* env, jobject obj) { | 358 static jlong Init(JNIEnv* env, const JavaParamRef<jobject>& obj) { |
349 PersonalDataManagerAndroid* personal_data_manager_android = | 359 PersonalDataManagerAndroid* personal_data_manager_android = |
350 new PersonalDataManagerAndroid(env, obj); | 360 new PersonalDataManagerAndroid(env, obj); |
351 return reinterpret_cast<intptr_t>(personal_data_manager_android); | 361 return reinterpret_cast<intptr_t>(personal_data_manager_android); |
352 } | 362 } |
353 | 363 |
354 } // namespace autofill | 364 } // namespace autofill |
OLD | NEW |