| 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 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 335 GetPrefs()->SetBoolean(autofill::prefs::kAutofillEnabled, enable); | 335 GetPrefs()->SetBoolean(autofill::prefs::kAutofillEnabled, enable); |
| 336 } | 336 } |
| 337 | 337 |
| 338 // Returns whether the Autofill feature is managed. | 338 // Returns whether the Autofill feature is managed. |
| 339 static jboolean IsAutofillManaged(JNIEnv* env, jclass clazz) { | 339 static jboolean IsAutofillManaged(JNIEnv* env, jclass clazz) { |
| 340 return GetPrefs()->IsManagedPreference(autofill::prefs::kAutofillEnabled); | 340 return GetPrefs()->IsManagedPreference(autofill::prefs::kAutofillEnabled); |
| 341 } | 341 } |
| 342 | 342 |
| 343 // Returns whether the Wallet import feature is available. | 343 // Returns whether the Wallet import feature is available. |
| 344 static jboolean IsWalletImportFeatureAvailable(JNIEnv* env, jclass clazz) { | 344 static jboolean IsWalletImportFeatureAvailable(JNIEnv* env, jclass clazz) { |
| 345 // TODO(estade): what to do in the IsManaged case? | 345 return false; |
| 346 ProfileSyncService* service = | |
| 347 ProfileSyncServiceFactory::GetInstance()->GetForProfile(GetProfile()); | |
| 348 return service->IsSyncEnabledAndLoggedIn(); | |
| 349 } | 346 } |
| 350 | 347 |
| 351 // Returns whether the Wallet import feature is enabled. | 348 // Returns whether the Wallet import feature is enabled. |
| 352 static jboolean IsWalletImportEnabled(JNIEnv* env, jclass clazz) { | 349 static jboolean IsWalletImportEnabled(JNIEnv* env, jclass clazz) { |
| 353 return GetPrefs()->GetBoolean(autofill::prefs::kAutofillWalletImportEnabled); | 350 return GetPrefs()->GetBoolean(autofill::prefs::kAutofillWalletImportEnabled); |
| 354 } | 351 } |
| 355 | 352 |
| 356 // Enables or disables the Wallet import feature. | 353 // Enables or disables the Wallet import feature. |
| 357 static void SetWalletImportEnabled(JNIEnv* env, jclass clazz, jboolean enable) { | 354 static void SetWalletImportEnabled(JNIEnv* env, jclass clazz, jboolean enable) { |
| 358 GetPrefs()->SetBoolean(autofill::prefs::kAutofillWalletImportEnabled, enable); | 355 GetPrefs()->SetBoolean(autofill::prefs::kAutofillWalletImportEnabled, enable); |
| 359 } | 356 } |
| 360 | 357 |
| 361 // Returns an ISO 3166-1-alpha-2 country code for a |jcountry_name| using | 358 // Returns an ISO 3166-1-alpha-2 country code for a |jcountry_name| using |
| 362 // the application locale, or an empty string. | 359 // the application locale, or an empty string. |
| 363 static jstring ToCountryCode(JNIEnv* env, jclass clazz, jstring jcountry_name) { | 360 static jstring ToCountryCode(JNIEnv* env, jclass clazz, jstring jcountry_name) { |
| 364 return ConvertUTF8ToJavaString( | 361 return ConvertUTF8ToJavaString( |
| 365 env, | 362 env, |
| 366 AutofillCountry::GetCountryCode( | 363 AutofillCountry::GetCountryCode( |
| 367 base::android::ConvertJavaStringToUTF16(env, jcountry_name), | 364 base::android::ConvertJavaStringToUTF16(env, jcountry_name), |
| 368 g_browser_process->GetApplicationLocale())).Release(); | 365 g_browser_process->GetApplicationLocale())).Release(); |
| 369 } | 366 } |
| 370 | 367 |
| 371 static jlong Init(JNIEnv* env, jobject obj) { | 368 static jlong Init(JNIEnv* env, jobject obj) { |
| 372 PersonalDataManagerAndroid* personal_data_manager_android = | 369 PersonalDataManagerAndroid* personal_data_manager_android = |
| 373 new PersonalDataManagerAndroid(env, obj); | 370 new PersonalDataManagerAndroid(env, obj); |
| 374 return reinterpret_cast<intptr_t>(personal_data_manager_android); | 371 return reinterpret_cast<intptr_t>(personal_data_manager_android); |
| 375 } | 372 } |
| 376 | 373 |
| 377 } // namespace autofill | 374 } // namespace autofill |
| OLD | NEW |