| 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 PersonalDataManager* pdm = PersonalDataManagerFactory::GetForProfile( | |
| 349 GetProfile()); | |
| 350 return service->IsSyncEnabledAndLoggedIn() && | |
| 351 pdm->IsExperimentalWalletIntegrationEnabled(); | |
| 352 } | 346 } |
| 353 | 347 |
| 354 // Returns whether the Wallet import feature is enabled. | 348 // Returns whether the Wallet import feature is enabled. |
| 355 static jboolean IsWalletImportEnabled(JNIEnv* env, jclass clazz) { | 349 static jboolean IsWalletImportEnabled(JNIEnv* env, jclass clazz) { |
| 356 return GetPrefs()->GetBoolean(autofill::prefs::kAutofillWalletImportEnabled); | 350 return GetPrefs()->GetBoolean(autofill::prefs::kAutofillWalletImportEnabled); |
| 357 } | 351 } |
| 358 | 352 |
| 359 // Enables or disables the Wallet import feature. | 353 // Enables or disables the Wallet import feature. |
| 360 static void SetWalletImportEnabled(JNIEnv* env, jclass clazz, jboolean enable) { | 354 static void SetWalletImportEnabled(JNIEnv* env, jclass clazz, jboolean enable) { |
| 361 GetPrefs()->SetBoolean(autofill::prefs::kAutofillWalletImportEnabled, enable); | 355 GetPrefs()->SetBoolean(autofill::prefs::kAutofillWalletImportEnabled, enable); |
| 362 } | 356 } |
| 363 | 357 |
| 364 // 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 |
| 365 // the application locale, or an empty string. | 359 // the application locale, or an empty string. |
| 366 static jstring ToCountryCode(JNIEnv* env, jclass clazz, jstring jcountry_name) { | 360 static jstring ToCountryCode(JNIEnv* env, jclass clazz, jstring jcountry_name) { |
| 367 return ConvertUTF8ToJavaString( | 361 return ConvertUTF8ToJavaString( |
| 368 env, | 362 env, |
| 369 AutofillCountry::GetCountryCode( | 363 AutofillCountry::GetCountryCode( |
| 370 base::android::ConvertJavaStringToUTF16(env, jcountry_name), | 364 base::android::ConvertJavaStringToUTF16(env, jcountry_name), |
| 371 g_browser_process->GetApplicationLocale())).Release(); | 365 g_browser_process->GetApplicationLocale())).Release(); |
| 372 } | 366 } |
| 373 | 367 |
| 374 static jlong Init(JNIEnv* env, jobject obj) { | 368 static jlong Init(JNIEnv* env, jobject obj) { |
| 375 PersonalDataManagerAndroid* personal_data_manager_android = | 369 PersonalDataManagerAndroid* personal_data_manager_android = |
| 376 new PersonalDataManagerAndroid(env, obj); | 370 new PersonalDataManagerAndroid(env, obj); |
| 377 return reinterpret_cast<intptr_t>(personal_data_manager_android); | 371 return reinterpret_cast<intptr_t>(personal_data_manager_android); |
| 378 } | 372 } |
| 379 | 373 |
| 380 } // namespace autofill | 374 } // namespace autofill |
| OLD | NEW |