Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/autofill/options_util.h" | 5 #include "chrome/browser/autofill/options_util.h" |
| 6 | 6 |
| 7 #include "base/prefs/pref_service.h" | |
| 8 #include "chrome/browser/autofill/personal_data_manager_factory.h" | 7 #include "chrome/browser/autofill/personal_data_manager_factory.h" |
| 9 #include "chrome/browser/sync/profile_sync_service.h" | 8 #include "chrome/browser/sync/profile_sync_service.h" |
| 10 #include "chrome/browser/sync/profile_sync_service_factory.h" | 9 #include "chrome/browser/sync/profile_sync_service_factory.h" |
| 11 #include "components/autofill/core/browser/personal_data_manager.h" | 10 #include "components/autofill/core/browser/options_util.h" |
| 12 #include "components/autofill/core/common/autofill_pref_names.h" | |
| 13 | 11 |
| 14 namespace autofill { | 12 namespace autofill { |
| 15 | 13 |
| 16 bool WalletIntegrationAvailableForProfile(Profile* profile) { | 14 bool WalletIntegrationAvailableForProfile(Profile* profile) { |
| 17 ProfileSyncService* service = | 15 return WalletIntegrationAvailable( |
| 18 ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile); | 16 ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile), |
| 19 if (!(service && service->IsSyncEnabledAndLoggedIn() && | 17 *profile->GetPrefs(), |
| 20 service->GetPreferredDataTypes().Has(syncer::AUTOFILL_PROFILE))) { | 18 *PersonalDataManagerFactory::GetForProfile(profile)); |
|
bondd
2015/05/07 21:19:24
LMK if you want me to DCHECK prefs and profile bef
Evan Stade
2015/05/07 21:23:02
DCHECK is just documentation that you expect somet
| |
| 21 return false; | |
| 22 } | |
| 23 | |
| 24 PersonalDataManager* pdm = PersonalDataManagerFactory::GetForProfile(profile); | |
| 25 if (!pdm->IsExperimentalWalletIntegrationEnabled()) | |
| 26 return false; | |
| 27 | |
| 28 // If the user is signed in and the feature is enabled, but no data is being | |
| 29 // synced, hide the option. The user doesn't have a Wallet account. If the | |
| 30 // feature is disabled, we can't know, so show the checkbox. | |
| 31 if (!profile->GetPrefs()->GetBoolean(prefs::kAutofillWalletImportEnabled)) | |
|
Evan Stade
2015/05/11 18:00:38
you inverted this check
| |
| 32 return true; | |
| 33 | |
| 34 // If wallet is preferred but we haven't gotten the sync data yet, we don't | |
| 35 // know, so show the checkbox. | |
| 36 if (!service->GetActiveDataTypes().Has(syncer::AUTOFILL_WALLET_DATA)) | |
| 37 return true; | |
| 38 | |
| 39 return pdm->HasServerData(); | |
| 40 } | 19 } |
| 41 | 20 |
| 42 } // namespace autofill | 21 } // namespace autofill |
| OLD | NEW |