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

Side by Side Diff: chrome/browser/autofill/android/personal_data_manager_android.cc

Issue 950003002: Show Autofill/Wallet options only when signed in. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: pdm Created 5 years, 10 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 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
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 return false; 345 // TODO(estade): what to do in the IsManaged case?
346 ProfileSyncService* service =
347 ProfileSyncServiceFactory::GetInstance()->GetForProfile(GetProfile());
348 PersonalDataManager* pdm = PersonalDataManagerFactory::GetForProfile(
349 GetProfile());
350 return service->IsSyncEnabledAndLoggedIn() &&
351 pdm->IsExperimentalWalletIntegrationEnabled();
346 } 352 }
347 353
348 // Returns whether the Wallet import feature is enabled. 354 // Returns whether the Wallet import feature is enabled.
349 static jboolean IsWalletImportEnabled(JNIEnv* env, jclass clazz) { 355 static jboolean IsWalletImportEnabled(JNIEnv* env, jclass clazz) {
350 return GetPrefs()->GetBoolean(autofill::prefs::kAutofillWalletImportEnabled); 356 return GetPrefs()->GetBoolean(autofill::prefs::kAutofillWalletImportEnabled);
351 } 357 }
352 358
353 // Enables or disables the Wallet import feature. 359 // Enables or disables the Wallet import feature.
354 static void SetWalletImportEnabled(JNIEnv* env, jclass clazz, jboolean enable) { 360 static void SetWalletImportEnabled(JNIEnv* env, jclass clazz, jboolean enable) {
355 GetPrefs()->SetBoolean(autofill::prefs::kAutofillWalletImportEnabled, enable); 361 GetPrefs()->SetBoolean(autofill::prefs::kAutofillWalletImportEnabled, enable);
356 } 362 }
357 363
358 // Returns an ISO 3166-1-alpha-2 country code for a |jcountry_name| using 364 // Returns an ISO 3166-1-alpha-2 country code for a |jcountry_name| using
359 // the application locale, or an empty string. 365 // the application locale, or an empty string.
360 static jstring ToCountryCode(JNIEnv* env, jclass clazz, jstring jcountry_name) { 366 static jstring ToCountryCode(JNIEnv* env, jclass clazz, jstring jcountry_name) {
361 return ConvertUTF8ToJavaString( 367 return ConvertUTF8ToJavaString(
362 env, 368 env,
363 AutofillCountry::GetCountryCode( 369 AutofillCountry::GetCountryCode(
364 base::android::ConvertJavaStringToUTF16(env, jcountry_name), 370 base::android::ConvertJavaStringToUTF16(env, jcountry_name),
365 g_browser_process->GetApplicationLocale())).Release(); 371 g_browser_process->GetApplicationLocale())).Release();
366 } 372 }
367 373
368 static jlong Init(JNIEnv* env, jobject obj) { 374 static jlong Init(JNIEnv* env, jobject obj) {
369 PersonalDataManagerAndroid* personal_data_manager_android = 375 PersonalDataManagerAndroid* personal_data_manager_android =
370 new PersonalDataManagerAndroid(env, obj); 376 new PersonalDataManagerAndroid(env, obj);
371 return reinterpret_cast<intptr_t>(personal_data_manager_android); 377 return reinterpret_cast<intptr_t>(personal_data_manager_android);
372 } 378 }
373 379
374 } // namespace autofill 380 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698